Created
May 17, 2022 15:30
-
-
Save robertstaddon/4d488e22aa109aa5a8bf5b462621725c to your computer and use it in GitHub Desktop.
Remove Square Digital Wallet Payments for Smart Coupons Products that Autogenerate Coupons
This file contains 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
add_filter( 'wc_square_digital_wallet_js_args', function ( $args ) { | |
if ( isset( WC()->cart ) && class_exists( 'WC_Smart_Coupons' ) ) { | |
$sc = WC_Smart_Coupons::get_instance(); | |
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { | |
$product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); | |
$coupon_titles = $sc->get_coupon_titles( array( 'product_object' => $product ) ); | |
if ( $coupon_titles ) { | |
$args['payment_request'] = array(); | |
} | |
} | |
} | |
return $args; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment