Jump to content

Prestashop 1.4.11.0 PayPal 3.5.7 total amount


ciapol

Recommended Posts

Hi all,

 

This is no ask for help, but just information about how to solve problem with total amount in paypay, when using Prestashop 1.4.11.0 and PayPal 3.5.7 module. Total price in presta card was (for example) 42.26 Euro, but when i click to pay with paypal, the total amount was 42.24 Euro - few cents less (usually 1-2 cents). That problem exists because PrestaShop and PayPal module use difference calculates (with rounds...). How to solved it? There is two ways: change presta code or change paypal code. I decided to change presta code because it was little strange (duplicate calculates!).

 

To repair this go to /shop folder/classes/Cart.php in line around 419 there was:

 

 

$tax_rate = Tax::getProductTaxRate((int)$row['id_product'], (int)$this->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$row['total_wt'] = Tools::ps_round($row['price'] * (float)$row['cart_quantity'] * (1 + (float)$tax_rate / 100), 2);

I comment it and added this:

 

//$tax_rate = Tax::getProductTaxRate((int)$row['id_product'], (int)$this->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
//$row['total_wt'] = Tools::ps_round($row['price'] * (float)$row['cart_quantity'] * (1 + (float)$tax_rate / 100), 2);
$row['price_wt'] = Tools::ps_round($row['price_wt'], 2);
$row['total_wt'] = $row['price_wt'] * (int)($row['cart_quantity']);

 

Anyway, that wasn't a point. The point of problem was in line around 941. I changed code to look like below:

// Here taxes are computed only once the quantity has been applied to the product price
//$price = Product::getPriceStatic((int)$product['id_product'], false, (int)$product['id_product_attribute'], 2, NULL, false, true, $product['cart_quantity'], false, (int)$this->id_customer ? (int)$this->id_customer : NULL, (int)$this->id, ($this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));

$total_ecotax = $product['ecotax'] * (int)$product['cart_quantity'];
//$total_price = $price * (int)$product['cart_quantity'];
$total_price = $product['total'];
if ($withTaxes)
{
//$total_price = ($total_price - $total_ecotax) * (1 + (float)Tax::getProductTaxRate((int)$product['id_product'], (int)$this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) / 100);
//$total_ecotax = $total_ecotax * (1 + Tax::getProductEcotaxRate((int)$this->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) / 100);
//$total_price = Tools::ps_round($total_price + $total_ecotax, 2);
$total_price = $product['total_wt'];
}

 

I attached the final Cart.php file.

 

PS. Code that was topped "//tomala" was changed.

Cart.php

Edited by ciapol (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...