Okay
  Public Ticket #3190405
Hide all payment options until limit reached
Closed

Comments

  •  5
    Julian started the conversation

    How can I hide all payment options until the minimum order is reached on the cart page? For some reason, some of them are still available. In our case, PayPal (see attachment). Strangely, PayPal payment is not available on the checkout page. Basically, B2BKing hides all payment methods correctly as selected in B2BKing -> Groups via the checkboxes, but on the cart page, it hides everything except the Paypal button container/option. That also makes the minimum order message disappear after only being shown for a second (see ticket #3190424). 

    If I disable PayPal Smart Button on the Cart page, all problems go away, but that also removes the option for all user roles, which is not ideal as we need B2C and Guest customers to have this payment option on the cart page as well as at the checkout page.

    If it helps, we're using the official PayPal for WooCommerce plugin powered by PayPal and built by Angelleye (a certified PayPal developer and official PayPal partner).

    This has happened in the past with the Wholesale Suite, and they gave me this  code to use, but I can't manage to replicate it with B2BKing; the site keeps crashing:

    add_action( 'wp_head' , function() {
      global $wc_wholesale_prices_premium;
      $user_wholesale_role = $wc_wholesale_prices_premium->wwpp_wholesale_roles->getUserWholesaleRole();
      if( !empty( $user_wholesale_role ) ) {
        
        //your hide paypal payment for wholesale

        echo '<style type="text/css">.angelleye_ppcp-button-container{display:none;}</style>'; }
    });


    Please help when possible. Thank you

    Julian @ thelovingnature.co.uk

  •  2,619
    WebWizards replied

    Hi Julian,


    1) Something I would suggest to try is to go to B2BKing -> Dynamic Rules and create a 'Payment Method Min / Max Order' rule for the PayPal method. Perhaps this rule can also hide that Smart Button element.

    It would look like this:

    6375918344.png



    However, the problem seems to be that that Smart Button does not follow general WooCommerce rules - it's probably added through a different mechanism.


    2) If the above doesn't work, then I think I have a way with a similar code snippet.

    Should that 'smart button' be hidden for all users when the order total is less than $100?


    Kind regards,

    Stefan



  •  5
    Julian replied

    Hi Stefan, thanks for your quick reply. 

    I tried the proposed dynamic rule, but that smart container/element is still shown on the cart page. Paypal method is successfully hidden on the checkout page as per my settings in B2BKing -> Groups -> Shipping and Payments Methods via the checkboxes, but not on the Cart Page. 

    So frustrating; perhaps a similar code to the one I mentioned in my first post would help? I tried and can't make it work. Ideally, the plugin should hide it as it does with Amazon smart button and all the other options. 

    "Should that 'smart button' be hidden for all users when the order total is less than $100?"

    No, it has to be hidden only from my wholesale customers as per my settings in B2BKing -> Groups -> Shipping and Payments Methods. The plugin does hide all my other payment methods successfully for B2B customers everywhere (checkout and cart pages) and leaves only the BACS option as needed in our case. However, for some reason, the Paypal button is still shown on the cart page, making it possible for the customers to pay directly from the cart page, which is not okay.

  •  2,619
    WebWizards replied

    I looked into this now using the login you provided in the other ticket.


    I think their plugin is basically adding that as a simple button, without checking whether the PayPal payment method is enabled or not. I think they probably are simply checking if their plugin is enabled, but didn't think to check whether it's enabled at checkout as a payment method.


    I added some CSS to your site to hide that button for B2B users (always). It would still show to logged out users and to logged in B2C users. Hope I understood that correctly but if not please clarify.