Created
January 13, 2025 15:16
-
-
Save plugin-republic/9ce9fb85a176dae76ab8ea78ad114ce1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Exclude child products from coupons | |
*/ | |
add_filter( 'woocommerce_coupon_is_valid_for_product', function( $valid, $product, $coupon, $values ) { | |
if ( ! empty( $values['product_extras']['price_with_extras_discounted'] ) ) { | |
$price = $values['product_extras']['original_price']; | |
$price_discounted = $values['product_extras']['price_with_extras_discounted']; | |
if ( $price != $price_discounted ) { | |
$valid = false; | |
} | |
} | |
return $valid; | |
}, 9999, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment