Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Plugin Name: All Products for WooCommerce Subscriptions - Disable Coupons for Products on Subscription
* Plugin URI: https://woocommerce.com/products/all-products-for-woocommerce-subscriptions/
* Description: Use this snippet to prevent coupons from applying to cart items on Subscription.
* Version: 1.0
* Author: SomewhereWarm
* Author URI: https://somewherewarm.gr/
* Developer: Jason Kytros
*
*
* Copyright: © 2020 Jason Kytros (jask@somewherewarm.gr).
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
add_filter( 'woocommerce_coupon_is_valid_for_product', 'apfs_disable_for_products_on_subscription', 10, 4 );
function apfs_disable_for_products_on_subscription( $is_valid, $product, $instance, $values ) {
if ( ! empty( $values[ 'wcsatt_data'][ 'active_subscription_scheme' ] ) ) {
$is_valid = false;
}
return $is_valid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment