Skip to content

Instantly share code, notes, and snippets.

@robertstaddon
Created May 17, 2022 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertstaddon/4d488e22aa109aa5a8bf5b462621725c to your computer and use it in GitHub Desktop.
Save robertstaddon/4d488e22aa109aa5a8bf5b462621725c to your computer and use it in GitHub Desktop.
Remove Square Digital Wallet Payments for Smart Coupons Products that Autogenerate Coupons
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