Skip to content

Instantly share code, notes, and snippets.

@contemplate
Created December 11, 2023 17:31
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 contemplate/54998642d927fdb49b110a85db8b8d30 to your computer and use it in GitHub Desktop.
Save contemplate/54998642d927fdb49b110a85db8b8d30 to your computer and use it in GitHub Desktop.
WooCommerce Subscription: custom recurring total on checkout for a switch order with coupon applied
// Recurring Total line items
add_filter( 'woocommerce_subscription_price_string', 'wc_subscription_recurring_price_string', 10, 2 );
function wc_subscription_recurring_price_string( $subscription_string, $subscription_details ) {
if ( ( is_checkout() && ! is_wc_endpoint_url() ) ) {
$recurring_amount = $subscription_details['recurring_amount'];
//If this is a switch order with a Specific Coupon applied
if( WC()->cart->get_total( 'edit' ) == 0.00 && WC()->cart->has_discount( 'COUPON-NAME-HERE' ) && strpos($recurring_amount, '149.00') !== false){
return $recurring_amount . ' / 1st year<br>then $199.00 / year';
} else {
return $subscription_string;
}
}
return $subscription_string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment