Jump to content

Prestashop 1.7 cart object product price update


Recommended Posts

Hello all, I am new to community started with PS 1.7 :)

 

I’m developing a custom payment method module for prestashop 1.7. which interacts with local credit card gateway.

The idea is to send the cart’s total price with additional percentage fee to the payment gateway which works well, but upon confirmation (when the gateway send back values and new total price)

 

I want to update the products prices in the cart object with that additional fee so that I can store it as an order and display it on the order-confirmation page and confirmation emails.

Now, since the cart object total value doesn’t match the total returned from the payment gateway, when I try to write the validateOrder() I get the “payment error” message instead of “payment accepted”.

 

I know there are some PS modules that let you set additional fees regarding payment option but I don’t need to get this displayed as additional fee, just update the product prices in cart/order just before confirmation.

 

How to simply update the product prices in cart object from the module controller?

Some example code would be appreciated.

Thank you

Edited by kigor (see edit history)
Link to comment
Share on other sites

Ok, I’ve managed to change order prices to match the prices returned from the payment gateway. 

 

I copied and extended the validateOrder() function from the core controller PaymentMethod class into the custom plugin main class and modified it to accept the $percentage additional parameter that gets sent into it upon the order validation in the plugin’s front controller validation.php.

The extension actually added up the percentage to all the prices (products and totals) that get written in the order object and sent in the validation emails.

 

Hopefully that approach will help someone.

Link to comment
Share on other sites

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...