Jump to content

Payment methods based on total cart amount


las3r

Recommended Posts

Hiya there,
 
One of my clients would like me to set up a feature that is not yet available in PS16 in my opinion. He'd like the payment methods to be active based on the total cart price. He's selling some high end gear (10k-15k euros) and we'd like to prevent users to pay with credit card (and do a bank transfer in stead). This is -of course- due to the collected fees by our payment providers (10-15k a pop * 3%...).
 
Hence I was looking into building a simple module for this. I was wondering whether I could use an existing hook to prevent payment methods to appear based on settings the user placed).
 
I've found the following hooks for payment:

1. displayPayment (Called when needing to build a list of the available payment solutions, during the order process. Ideal location to enable the choice of a payment module that you have developed.)

I think this won't work because this is to ADD a custom payment method to the list of possible choices for the consumer. Am I right?

 

2. displayBeforePayment (Called when displaying the list of available payment solutions. Ideal location to redirect the user instead of displaying said list (i.e., 1-click PayPal checkout)

I think it would be possible to redirect to a (module-)page that shows all the payment methods based on the options the users entered in the backend.

 

The issue I have with the second option is that this will override default prestashop behaviours (and plugins that are ment to work on the payment page), thus making it unusuable for the public domain (I would like to release a plugin for free after I'm done with this).

 

Any idea what my options are? Please feel free to correct me where I'm wrong :)

Link to comment
Share on other sites

I think you have to use the override. You need to override the payment options (Highly likely in the PaymentModule class). Check the cart contents to see what the costs are. If they go over the limit you need to not echo the payment option (or make it unclickable). 

Link to comment
Share on other sites

the easiest way is to edit each of the payment modules, locate the hookPayment function, and then add your custom logic to this function.

 

The hookPayment function is what makes the payment method appear during checkout.  So if you add your logic for order amount, and you do not want that payment method to appear, then just return false.

Link to comment
Share on other sites

First off, thanks for your thoughts!

 

payment system in PS is bad

 

I think need all change:

 

1. after checkout: close cart and make order

2. then SHOW order details with selection of payments methods - there may to do filter on order price etc conditions for payments methods

I think this choice was made due to the law here in Europe (PrestaShop is french from origin). Here in the EU it works like this: Shop law persists that you only have a legally binding option to hand over the product (= valid order) once the customer pays, unless your terms say otherwise. This means that the user first needs to pay (and the payment needs to be done correctly) before the order is legally binding for both the shop and the customer. 

 

I do understand that this might not be ideal (in some cases I had issues with this as well) but it's what we have to work with :)

 

I think you have to use the override. You need to override the payment options (Highly likely in the PaymentModule class). Check the cart contents to see what the costs are. If they go over the limit you need to not echo the payment option (or make it unclickable). 

 

Right, I was aiming for a better (reusable) solution that allows this to be done without the need for overriding base classes due to the low compatibility of newer versions.

 

the easiest way is to edit each of the payment modules, locate the hookPayment function, and then add your custom logic to this function.

 

The hookPayment function is what makes the payment method appear during checkout.  So if you add your logic for order amount, and you do not want that payment method to appear, then just return false.

 

I thought of this, but this won't work as a module I think - I want to prevent hacking and slashing variables from controllers to the .tpl files in order to provide standard behaviour. Your solution would work for sure though :) 

 

Any other thoughts?

Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...