Skip to content

Instantly share code, notes, and snippets.

💭
🍻Cheersing

Dan Cameron dancameron

💭
🍻Cheersing
Block or report user

Report or block dancameron

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dancameron
dancameron / functions.php
Last active Sep 3, 2019
Set Invoice Status to Pending after Form Submission
View functions.php
<?php // don't include this line in your functions.php, since it already starts with it.
function _change_status_of_invoice_submission( SI_Invoice $invoice ) {
$invoice->set_status( 'publish' );
}
add_action( 'si_gravity_forms_integration_invoice_created', '_change_status_of_invoice_submission' );
@dancameron
dancameron / functions.php
Created Aug 30, 2019
Add Currency Code to Invoice Money Formatting
View functions.php
<?php // don't include this line in your functions.php, since it already starts with it.
function _round_sa_formatted_money( $money, $orig_amount, $doc_id ) {
$doc = si_get_doc_object( $doc_id );
if ( '' == $doc ) {
return $money;
}
View logs.txt
<?php
/**
* Updated the method to make sure the vars are being passed.
*/
public static function setAppInfo( $appName, $appVersion = null, $appUrl = null, $appPartnerId = null ) {
error_log( 'vars: ' . print_r( get_defined_vars(), true ) );
self::$appInfo = self::$appInfo ?: [];
self::$appInfo['name'] = $appName;
self::$appInfo['partner_id'] = $appPartnerId;
@dancameron
dancameron / functions.php
Created Aug 20, 2019
Override Months and Years for Sprout Invoices
View functions.php
<?php // don't include this line in your functions.php, since it already starts with it.
function _custom_get_month_options() {
$months = array(
'01' => __( '01 - January', 'sprout-invoices' ),
'02' => __( '02 - February', 'sprout-invoices' ),
'03' => __( '03 - March', 'sprout-invoices' ),
'04' => __( '04 - April', 'sprout-invoices' ),
'05' => __( '05 - May', 'sprout-invoices' ),
'06' => __( '06 - June', 'sprout-invoices' ),
@dancameron
dancameron / functions.php
Created Aug 19, 2019
Override the Language File
View functions.php
<?php // don't include this line in your functions.php, since it already starts with it.
function _override_load_textdomain_for_si( $bool = false, $domain = '', $mofile = '' ) {
if ( 'sprout-invoices' == $domain ) {
return true;
}
return $bool;
}
add_filter( 'override_load_textdomain', '_override_load_textdomain_for_si', 3 );
@dancameron
dancameron / functions.php
Created Aug 13, 2019
Change Status of Invoice after WooCommerce Payment Status Update
View functions.php
<?php // don't include this line in your functions.php, since it already starts with it.
// remove action within SI add-on
remove_action( 'si_invoice_status_updated', array( 'Woo_Payments_Integration', 'maybe_change_order_status' ), 10, 2 );
// recreate action with processing status
function maybe_change_order_status( SI_Invoice $invoice, $status = '' ) {
$order_id = get_post_meta( $invoice->get_id(), self::ORDER_ID_META, true );
if ( ! $order_id ) {
@dancameron
dancameron / functions.php
Created Aug 12, 2019
Prevent Redirection to Invoice after WooCommerce Payment
View functions.php
<?php // don't include this line in your functions.php, since it already starts with it.
remove_action( 'woocommerce_thankyou', array( 'SI_Woo_Payment_Processor', 'redirect_to_invoice_after_payment' ) );
add_filter( 'si_woopay_redirect_back_to_invoice', '__return_false' );
@dancameron
dancameron / functions.php
Created Aug 10, 2019
User Password Shortcode for Ninja Forms
View functions.php
<?php // don't include this line in your functions.php, since it already starts with it.
function _send_user_password( $args = array() ) {
$args['user_pass'] = wp_generate_password();
return $args;
}
add_filter( 'si_create_user_args', '_send_user_password' );
@dancameron
dancameron / functions.php
Created Jul 22, 2019
Customization Based on Client Type
View functions.php
<?php // don't include this line in your functions.php, since it already starts with it.
switch ( SI_Client_Categories::get_client_type( si_get_client_id() ) ) {
case 'client-type-slug1':
"do something";
break;
case 'client-type-slug2':
"do something for this slug";
break;
default:
@dancameron
dancameron / functions.php
Created Jul 3, 2019
Translating Strings in Sprout Invoices
View functions.php
<?php // don't add this line, since your functions.php file already starts with it.
/**
* Example filter will translate/change the string "Description".
* "Description" can be changed to whatever string you'd like to translate/change
* just make sure to change the function name so you don't have any conflicts.
*/
function si_change_strings( $translations, $text, $domain ) {
if ( 'sprout-invoices' === $domain ) {
// Change "Description"
You can’t perform that action at this time.