[-] Project : Fixes PSCFV-11593. Added code to load the customer when a non-user calls the Product::getPriceStatic method #1312
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Bug - Product::getPriceStatic returns wrong price when called from Paypal
I have created an issue here : http://forge.prestashop.com/browse/PSCFV-11593
Reproducing from the bug tracker.
Steps to reproduce the bug
The Cause
While validating the paypal order, paypal checks the cart total against the mc_gross (the total amount paid at paypal) value posted by paypal. Only when the two totals match an order is created. The static function Cart::getOrderTotal() returns without applying the Catalog price rule (In this case the Cart:getOrderTotal() method returns $66.05 instead of $61.03).
The Fix
On investigating further, this is what I found :
Cart::getOrderTotal() calls another static method Product::getPriceStatic(). This Product::getPriceStatic() method uses the group ID to calculate the catalog price rules. The group ID is determined like this in line 2514:
$id_group = (int)Group::getCurrent()->id;
The above line checks for the customer in the context. When Paypal posts the data, $id_group is returned as 1 which is the group of the visitor. Instead it should return the group of the customer ID. Since the group returned is visitor, no discount is applied and hence the difference in the cart totals.