Jump to content

Paypal module not using override CartCore::getOrderTotal


Tuni-Soft

Recommended Posts

Hello,

 

My module overrides CartCore::getOrderTotal but Paypal module is calculating the total a different way, so the price that I calculate and display on the cart is different than the price displayed on paypal website

 

The paypal is calculating the price directly from the product price
 

private function setProductsList(&$fields, &$index, &$total)
{
foreach ($this->product_list as $product)
  {
    .....

    $fields['L_PAYMENTREQUEST_0_AMT'.$index] = 
    Tools::ps_round($product['price_wt'], $this->decimals);
    $total = $total +($fields['L_PAYMENTREQUEST_0_AMT'.$index]*$product['quantity']);
  }
}

What am I missing ? Is there a better way to change the cart total and add extra expenses?

Link to comment
Share on other sites

I don't think you can consider this a bug, if you have overriden core functionality of Prestashop. 

 

You might consider customizing your version of the Paypal module so that it uses the Cart function instead of trying to itemize the contents of the Cart.

 

You need to consider that the Paypal module is itemizing the contents of the Cart because when the customer is sent to Paypal and reviews their order, they see the entire contents of the cart, and not a single line item with the total cost.

 

Alternatively, you would customize the Paypal module so it includes the 'extra expense' that you have added.

Link to comment
Share on other sites

Thank you for your reply

 

I think it's a bug because it goes against what we expect from other modules

 

I override a method, I expect other module to use it so that in the end all modules would work as a complete solution for the merchant and his clients. Overrides are part of the solution.

 

My module adds product text customizations and in the customization text, it states the cost which would be added, so all infos are conserved in the summary

 

Modifying other modules is not the optimal solutions for me because my clients will evetually update/upgrade Paypal and the same issue will live!

I hope you would agree

Thank you

Link to comment
Share on other sites

The "extra expense" that you are calculating, is that added to each product price, or as an extra line item in the cart?

 

How is that added expense shown within Paypal?  Just in the order total, or in each line item?

 

It would be helpful to see a screen shot of your cart summary as well as the summary from the paypal website.

Link to comment
Share on other sites

First be sure that is not a bug:

1) Delete the override file

2) Enable the default theme

3) Use the payment modules without modifications

4) Now with all default, make your tests again, if problem disappear, you will know that is not a bug

 

Comment the results...

Link to comment
Share on other sites

We already know it is not a bug, the paypal module is not designed to use getOrderTotal from the Cart class.  This is done intentionally.

 

The user can submit their own bug report and PS will determine how they would like to reply.

 

The best we can do now is offer a solution to the OP, if they are willing to listen.

Link to comment
Share on other sites

We already know it is not a bug, the paypal module is not designed to use getOrderTotal from the Cart class.  This is done intentionally.

 

The user can submit their own bug report and PS will determine how they would like to reply.

 

The best we can do now is offer a solution to the OP, if they are willing to listen.

 

Hello,

 

Thank you for your reply

I modified my module to add a new product and add it systematically to cart, this way the extra expenses are represented by a separate item, the product price is calculated in an override of Product::getPriceStatic to sum up the customizations total cost

 

Screenshot:

Cart: post-369615-0-81163700-1413645679_thumb.png

Paypal: post-369615-0-01498900-1413645784_thumb.png

 

What confused me is that "cheque" and "bank wire" modules work with getOrderTotal

 

Solved, Thank you

Edited by unloco (see edit history)
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...