Support » Plugin: WooCommerce Stripe Payment Gateway » Remove payment request buttons on selected product pages

  • Resolved rainerd

    (@coresince84)


    Hey there,

    I know there is a hook to remove the payment request buttons from all product pages, but I am looking for a solution to add if statements to specify specific products not having the buttons. Background is the well known issue that custom fields of products are ignored in the process. Is there a solution for this? All my approaches to wrap add_filter( ‘wc_stripe_hide_payment_request_on_product_page’, ‘__return_true’ ); into a condition failed so far.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Doug – a11n

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @coresince84

    Great question! I tried a few ways with this myself but I wasn’t successful so I’ll ask one of the developers to take a look if they can.

    Thanks,

    Thread Starter rainerd

    (@coresince84)

    I solved it already with an If Statement and a custom field checkbox on the single product page backend to set if the product should not have the buttons. Will post the code later.

    Plugin Support Doug – a11n

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @coresince84

    I only now saw your reply but I wanted to reply here with one solution:

    add_filter( 'wc_stripe_hide_payment_request_on_product_page', function( $hide, $post ) {
        if ( $post->ID === 36 ) { // Change 36 to the Product ID that you want to hide
            return true;
        }
        return $hide;
    }, 10, 2 );

    As you’ve mentioned you have a solution and I’ve tested this solution and it works, I’ll mark this as Resolved.

    Thanks,

    Thread Starter rainerd

    (@coresince84)

    Thanks. This is my solution, based on a custom field called “hide_payment_request_buttons_apple_pay” to be more scalable and setting being adjustable via the product editor.

    add_action( 'woocommerce_before_single_product', 'woo_control_payment_request' );
    function woo_control_payment_request() {
       if ( get_field( 'hide_payment_request_buttons_apple_pay' ) ) {
       add_filter( 'wc_stripe_hide_payment_request_on_product_page', '__return_true' );
       }
    }
    • This reply was modified 2 years, 1 month ago by rainerd.
    • This reply was modified 2 years, 1 month ago by rainerd.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove payment request buttons on selected product pages’ is closed to new replies.