• Resolved Edith Allison

    (@terragirl)


    I need to programmatically disable the PP button in mini cart, cart and checkout for a Minimum Order Modification. For standard Woo payment buttons I can do this with remove_action() but for this plugin I cannot find a way how to handle this.

    Can you advise if there’s a way to disable the PayPal payment buttons? The code I use looks like this:

    if ( WC()->cart->subtotal_ex_tax < $minimum  ) {	
      if( is_cart() ) {
        remove_action( 'woocommerce_proceed_to_checkout', 'wc_get_pay_buttons', 10 );
        remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
      }
    }
    • This topic was modified 2 years, 10 months ago by Edith Allison. Reason: typo
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Syde Niklas

    (@niklasinpsyde)

    Hi @terragirl,

    PayPal Payments with quite differently compared to the Standard integration. Removing the button module programmatically is possible but not the most trivial task for now. Only hiding the button instead of removing it entirely may be a bit easier by utilizing the render hooks we added, but this won’t work for all usecases.
    There is a discussion about a similar request here. Also here are more details about the underlying architecture that causes it to work like this.

    But in the coming months, we aim to provide features and dedicated documentation for third-party developers to better be able to customize PayPal Payments to your needs.
    Anyway, I hope that helps a bit to clarify.

    Kind regards,
    Niklas

    Thread Starter Edith Allison

    (@terragirl)

    Thank you @niklasinpsyde for the reply and the link to resources, that’s very useful! Even if it’s not feasible to to use on live site it’s given me a much better understanding of the plugin architecture.

    At the moment I’m using the clunky method of hiding the button through CSS but it only works correctly on first page load. Changes on cart page don’t reload the button which is “stuck” at how it showed on first page load.

    If you do add features to support removal of button for Minimum Order Value than please consider adding the reloading of the button as part of the refreshed cart fragment when items are changed on cart page.

    Plugin Support Syde Niklas

    (@niklasinpsyde)

    Hi @terragirl,

    Apologies for not getting back sooner!
    A filter to disable the smart buttons was added a few updates ago: https://github.com/woocommerce/woocommerce-paypal-payments/blob/998a327ebcb5d961f0105736011795ee54ed2ffd/modules/ppcp-button/src/Assets/SmartButton.php#L1308
    But you probably noticed since you commented on the linked issue.

    There have also been improvements regarding the handling of AJAX reloads (for example on the cart page) since your report.
    There will be more customization options in the future and the credit for this goes to a third-party developer, but I hope this helps.

    Since the feature exists now and this thread is a tad older, I’ll mark it resolved.
    If you have any follow-up questions, I suggest reaching out privately from here: https://paypal.inpsyde.com/docs/request-support/
    Or by creating a new thread.
    Thank you!

    Kind regards,
    Niklas

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Programmatically disable PP button’ is closed to new replies.