Skip to content

Instantly share code, notes, and snippets.

View dancameron's full-sized avatar

Dan Cameron dancameron

View GitHub Profile
@dancameron
dancameron / functions.php
Last active September 3, 2019 21:10
Set Invoice Status to Pending after Form Submission
<?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 August 30, 2019 15:48
Add Currency Code to Invoice Money Formatting
<?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;
}
<?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 August 20, 2019 16:10
Override Months and Years for Sprout Invoices
<?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 August 19, 2019 20:51
Override the Language File
<?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 August 13, 2019 15:14
Change Status of Invoice after WooCommerce Payment Status Update
<?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 August 12, 2019 15:49
Prevent Redirection to Invoice after WooCommerce Payment
<?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 August 10, 2019 00:47
User Password Shortcode for Ninja Forms
<?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 July 22, 2019 18:37
Customization Based on Client Type
<?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 July 3, 2019 16:59
Translating Strings in Sprout Invoices
<?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"