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
    @dabpc,

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

    {% if order_total > maximum_paypal_value %}
    <style>
    .fc-action--payment--or,
    .fc-action--payment--paypal-ec {
    display: none;
    }
    </style>
    {% endif %}

    <script>
    FC.client.on("render.done", function() {
    if (FC.json.total_order > {{ maximum_paypal_value }}) {
    $("#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!
Sign In or Register to comment.