我遇到了 WooCommerce 订阅的“订阅的所有产品”WooCommerce 扩展程序的问题。
我到处找,去年在这个网站上找到了这个:
function disable_coupons_for_subscription_products( $is_valid, $coupon, $discount ){
// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item ) {
// Check for subscription products using "All products for subscription" add on
if ( isset($cart_item['wcsatt_data']['active_subscription_scheme'])
&& ! empty($cart_item['wcsatt_data']['active_subscription_scheme']) ) {
$is_valid = false; // Subscription product found: Make coupons "not valid"
break; // Stop and exit from the loop
}
}
return $is_valid;
}
但这将完全禁用优惠券,例如,
如果我的购物车中有两种产品,其中一种设置为重复使用,另一种设置为一次性购买,我不能使用一次性购买商品的优惠券。
我要么必须单独购买两次,要么不使用优惠券。
有没有办法解决这个问题?