Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active November 20, 2019 22:17
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/44f5ce5df36d2b9e42c2e802fc77b725 to your computer and use it in GitHub Desktop.
Save Pebblo/44f5ce5df36d2b9e42c2e802fc77b725 to your computer and use it in GitHub Desktop.
Display the return to event cart button before the SPCO content.
<?php // Please do not include the opening PHP tag if you already have one.
add_filter('FHEE__registration_page_wrapper_template__display_time_limit', 'tw_display_return_to_event_list_beginning_spco');
function tw_display_return_to_event_list_beginning_spco($value){
$checkout = EE_Registry::instance()->SSN->checkout();
if ( $checkout instanceof EE_Checkout ) {
// returning to SPCO ?
if ( $checkout->revisit ) {
// no return to cart button for you!
return $value;
}
// and if a payment has already been made and this isn't a revisit
if ( $checkout->transaction instanceof EE_Transaction && EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ) === '' ) {
$last_payment = $checkout->transaction->last_payment();
if ( $last_payment instanceof EE_Payment && $last_payment->status() !== EEM_Payment::status_id_failed && $checkout->transaction->paid() > 0 ) {
return $value;
}
}
// Build and echo the return to cart button
$html = '<a class="return-to-event-cart-mini-cart-lnk mini-cart-view-cart-lnk view-cart-lnk mini-cart-button hide-me-after-successful-payment-js button" href = "' . add_query_arg(
array( 'event_cart' => 'view' ), EE_EVENT_QUEUE_BASE_URL ) . '" ><span class="dashicons
dashicons-cart" ></span >' . apply_filters(
'FHEE__EED_Multi_Event_Registration__view_event_cart_btn_txt', sprintf( __( 'return to %s',
'event_espresso' ), EED_Multi_Event_Registration::$event_cart_name ) ) . '</a >';
echo $html;
// Remove the original return to cart button.
remove_filter(
'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html',
array( 'EED_Multi_Event_Registration', 'return_to_event_cart_button' )
);
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment