Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[-] Project : Fixes PSCFV-11593. Added code to load the customer when a non-user calls the Product::getPriceStatic method #1312

Closed
wants to merge 1 commit into from

Conversation

ibndawood
Copy link

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

  1. Login to the Administration Panel and go to Price Rules -> Catalog Price Rules.
  2. Create a Catalog Price Rule which will offer all the customers (which means this discount is not applied for visitors or Guests) will get a discount of 6.25% (or any amount). (See : CatalogPriceRules.png)
  3. Now add any product to the cart, register and login as a customer. Now the shopping cart summary will have the discount applied. (See : ShoppingCartSummary.png)
  4. Now make a purchase using paypal.
  5. No Order will be created.

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.

… a non-user calls the Product::getPriceStatic method
@rGaillard
Copy link
Contributor

Hi Ibrahim,

Thank you for you contribution and your bugfix.
However, we can't accept PRs on our master branch, i made some modification and patch this bug on our development branch, see
bcc3ca2

Best Regards,

@rGaillard rGaillard closed this Aug 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants