Hide Paypal for orders over a set value?

Hi,

Is it possible to hide the Paypal payment button / option for orders over a set value?

Thanks

Nick.

Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    @dabpc,

    Good question. Using Twig and some custom CSS, it would be possible to dynamically hide PayPal as an option once a certain order total is met.

    Could we confirm with you what store this is for? That will help us to ensure the example code we provide would work for your specific set up. If you'd prefer to keep it private, you can whisper it by checking the "Whisper" checkbox and entering my forum username in the box that appears when replying.
  • fc_adamfc_adam FoxyCart Team
    @dabpc,

    Thanks for whispering your store. It looks like you've got a few different payment sets configured for your store, with one payment set just having PayPal enabled, but the other payment sets not having PayPal enabled.

    To confirm, were you looking to be able to offer multiple payment options - like a card option on the checkout, and PayPal at the same time - but then after a specific order total hide PayPal so just the other is available? Or are you wanting to only offer PayPal up to a certain amount, and then only offer a something else over that amount?
  • dabpcdabpc Member
    They were just for testing, I'm just using "default" on the live store.

    >To confirm, were you looking to be able to offer multiple payment options - like a card option on the checkout, and PayPal at the same time - but then after a specific order total hide PayPal so just the other is available?

    Yes, thank you.
  • fc_adamfc_adam FoxyCart Team
    edited July 27
    @dabpc,

    Thanks for confirming. With that in mind, you can use code like this:
    {% set maximum_paypal_value = 50 %}

    <script>
    {% if context == "checkout" %}
    FC.client.on("cart-item-remove.done", function() {
    if (FC.json.total_order > 0) {
    FC.checkout.renderPaymentMethod();
    }
    });
    FC.client.on("cart-item-quantity-update.done", function() {
    FC.checkout.renderPaymentMethod();
    });
    {% endif %}
    FC.client.on("render.done", function() {
    if (FC.json.total_order > {{ maximum_paypal_value }}) {
    $(".fc-action--payment--or, .fc-action--payment--paypal-ec, #fc-payment-method-paypal_ec").remove();
    }
    });
    </script>
    You'll include that code in the "footer" textarea of the "Add custom header and footer code to your templates" option, found on the "configuration" page in the administration. You'll want to edit that first line to match the maximum amount you want to support with PayPal.

    The code also assumes you'll be using the "PayPal Express Checkout (Reference Transactions)" payment integration too.
  • dabpcdabpc Member
    Perfect - working beautifully! I'm liking Foxycart more & more :-)

    With thanks!
  • fc_adamfc_adam FoxyCart Team
    @dabpc,

    Awesome! Glad that worked well for you!
  • dabpcdabpc Member
    @fc_adam, oddly this has stopped working....has anything changed foxycart side? Thanks.
  • fc_adamfc_adam FoxyCart Team
    @dabpc,

    Sorry to hear that. No changes on our side that would impact the approach we detailed earlier.

    Looking at your store, it looks like you've removed PayPal as an option, so I wasn't able to replicate the issue. Were you seeing PayPal still displayed even when the order total was over £50?
  • dabpcdabpc Member
    Thanks for getting back. Yes, I switched it off while it wasn't working as intended. Yes, Paypal was showing when adding items of e.g £400 to cart.
  • fc_adamfc_adam FoxyCart Team
    @dabpc,

    I'm really sorry, my recommended approach above didn't cut it in all situations, and I'd missed that when testing. I've just updated the post above with a better version if you wanted to give that a try instead.
  • dabpcdabpc Member
    Many thanks..I've tried this & it seems to be OK working OK at the moment - many thanks.

    Probably a separate issue , but the Paypal link on "sidecart" doesn't work, but is OK on the checkout page.

    You will see it on my site now. Thanks.
  • fc_adamfc_adam FoxyCart Team
    @dabpc,

    I'm glad that worked for you!

    I believe the PayPal issue may relate to Google Tag Manager - specifically, are you using the native Google Analytics tag within GTM? If so - our GA implementation doesn't currently support that, so can cause issues. If you switch to using a custom HTML tag in GTM, and adding the Google Analytics code manually there, that should get it working. More details on that here: https://wiki.foxycart.com/v/2.0/analytics#setting_up_google_analytics
Sign In or Register to comment.