Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active October 23, 2017 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/2cda262898bffdf002e53270aa3196d2 to your computer and use it in GitHub Desktop.
Save Pebblo/2cda262898bffdf002e53270aa3196d2 to your computer and use it in GitHub Desktop.
Example of how you can override the PROMO.update_payment_info_table method. This is a copy of the original function with the code to automatically submit the registration when the payment amount == 0 commented out.
<?php //Please do not include the opening PHP tag if you already have one
function tw_my_custom_promo_submit(){
wp_add_inline_script(
'espresso_promotions',
"jQuery( document ).ready(function() {
PROMO.update_payment_info_table = function( response ) {
//SPCO.console_log( 'payment_info', response.return_data.payment_info, true );
jQuery('#spco-payment-info-table' ).find('tbody').html( response.return_data.payment_info );
SPCO.scroll_to_top_and_display_messages( SPCO.main_container, response, true );
if ( typeof response.return_data.cart_total !== 'undefined' ) {
var payment_amount = parseFloat( response.return_data.cart_total );
SPCO.main_container.trigger( 'spco_payment_amount', [ payment_amount ] );
if ( payment_amount === 0 ) {
SPCO.enable_submit_buttons();
//SPCO.main_container.find( '.spco-next-step-btn' ).trigger( 'click' );
}
}
}
});"
);
}
add_action( 'wp_enqueue_scripts', 'tw_my_custom_promo_submit', 50 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment