Skip to content

Instantly share code, notes, and snippets.

@NickGreen
Last active December 10, 2019 23:53
Show Gist options
  • Save NickGreen/c575cdbebbef6e3b843f70056f352a5a to your computer and use it in GitHub Desktop.
Save NickGreen/c575cdbebbef6e3b843f70056f352a5a to your computer and use it in GitHub Desktop.
Remove any product coupons from products in the cart, that have a recurring scheme applied to it from All Products for WooCommerce Subscriptions
<?php
// Set the product discount amount to zero if it has a recurring scheme
add_filter( 'woocommerce_coupon_get_discount_amount', 'zero_discount_for_excluded_products', 12, 5 );
function zero_discount_for_excluded_products( $discount, $discounting_amount, $cart_item, $single, $coupon ){
if ( false != ( $cart_item[ 'wcsatt_data' ][ 'active_subscription_scheme' ] ) )
$discount = 0;
return $discount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment