Prestashop: [BOOM-4701] Free GIFT is not displayed correctly on cart

Created on 22 Aug 2018  ·  23Comments  ·  Source: PrestaShop/PrestaShop

This issue has been migrated from the Forge. Read the original ticket here.

  • _Reporter:_ tantan199
  • _Created at:_ Fri, 26 Jan 2018 10:50:03 +0100

I added a gift to all products on my store, the problem is that the price of the gift is displayed on the shopping cart page, another problem is that the quantity of the gift is adjustable. See attached pictures.

Because the cart variable from the controller/front/CartController.php filed gets override by another cart variable from the assignGeneralPurposeVariables function in the /classes/controller/ProductListingFrontController.php

Temporary solution is change this code 

'cart' => $this->cart_presenter->present($this->context->cart),

in the assignGeneralPurposeVariables function to 

'cart' => $this->cart_presenter->present($this->context->cart, $shouldSeparateGifts = true),

 

The same problem also exist in the Shopping cart module.

1.7.4.0 1.7.4.1 1.7.6.0 Bug Cart rules FO Minor Shopping carts FO Taxes and Prices To Do Topwatchers

Most helpful comment

Hello @marionf,
As merchants, we encounter many problems because of this issue, this impacts our clients and our customer service team. I understand that you've got a lot on your plate but since the solution has already been identified, we would really appreciate if this could be fixed shortly since it has been affecting us for months already. Is there really nothing you can do for now? Do you have any idea about when it can be fixed please?
Thank you very much for your help!

All 23 comments

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ khouloud.belguith
  • _Created at:_ Fri, 26 Jan 2018 11:02:12 +0100

Hi Jonny,

Would you be willing to make a pull request on GitHub with your code suggestion?
https://github.com/PrestaShop/PrestaShop/tree/develop
Thank you!

Best regards, Khouloud

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ pablo.borowicz
  • _Created at:_ Mon, 29 Jan 2018 16:22:32 +0100

Proposed PR: https://github.com/PrestaShop/PrestaShop/pull/8706

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ marion_francois
  • _Created at:_ Tue, 20 Feb 2018 11:34:41 +0100

Lorsque j'applique une règle panier qui offre un article, il faudrait le même comportement qu'en 1.6 (1.6_behaviour.gif) :

  • au moment de l'ajout d'un produit remplissant les conditions d'une règle panier dans le panier, ne pas tenir compte dans les calculs du prix du cadeau. Actuellement, on ajoute le produit avec son prix et puis on applique une réduction de ce montant.
  • La corbeille pour supprimer un cadeau ne fonctionne pas
  • bien afficher le produit comme cadeau, enlever la possibilité de modifier la quantité et ne plus afficher le prix que ce soit dans le panier et au moment du paiement. 

Capture du 2018-02-20 11-25-39

Si ma règle panier offre un article & une réduction (en montant ou %), un champ "Remise" apparait dans le panier.
Ce champs ne doit pas inclure le montant du produit offert mais uniquement la réduction -> OK.
Pareil pour la ligne orange avec la promo,  elle ne doit pas inclure le montant du produit offert mais uniquement la réduction -> NOK

Capture du 2018-04-17 15-48-03

Capture du 2018-04-17 15-47-50

Dans le cas où j'achète le produit qui est offert, 2 lignes doivent apparaitre dans le panier
Le champs remise ne doit pas inclure le montant du produit offert mais uniquement la réduction -> NOK.
Pareil pour la ligne orange avec la promo,  elle ne doit pas inclure le montant du produit offert mais uniquement la réduction -> NOK

Capture du 2018-04-17 16-12-58

Capture du 2018-04-17 15-55-47

 

Il faudrait également remplacer "Remise - Discount" par "Total bons de réduction - Total vouchers" comme en 1.6, c'était plus claire comme ceci
Louise Bonnard c'est faisable ? Ou il faut faire ça dans une PR ?

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ louise bonnard
  • _Created at:_ Fri, 20 Apr 2018 10:30:28 +0200

/1.7.2/Shop/Theme/Checkout.xlf
src/Adapter/Order/OrderPresenter.php

/1.7.3/Shop/Theme/Checkout.xlf
src/Adapter/Cart/CartPresenter.php

This comment has been migrated from the Forge. Read the original comment here.

  • _Author:_ louise bonnard
  • _Created at:_ Fri, 20 Apr 2018 10:51:55 +0200

Marion F, done !

Do you have any idea about the release which will bring this issue ?

In 1.7.6.1 still the same - not working :( Somebody know how to fix this?

Hi @tonspeed,

Sorry, it is not fixed yet.

Thanks!

Hi

The fix don't work on my version 1.7.5.2 and i d'ont have any solution to patch this bug.
Have you an Idea ?

Thanks

Hi, I updated it presta to 1.7.6.1 and then the patch worked...

TS

Hi, any news here for this bug ?
We've found a bug if shouldSeparateGifts is set to true : the gifted product quantity is wrong.

@jf-viguier @tonspeed @marionf @khouloudbelguith

Just a notice. I tried the proposed fix in #8706.

It fixes the issue and is_gift variable is working properly, BUT it makes the totals total nonsense. See the video: https://drive.google.com/file/d/1cPGuuNIDaG1wg9yq42uIrJuX2dmXm5Z6/view?usp=sharing

EDIT: Totals are wrong only in cart. When you finish the order, everything is alright.

It seems that it doubles the quantity of all products in cart, which are given as a gift.
You get 1 as gift. You want 1 extra. In product totals, it calculates 4 pieces.
You get 1 as gift. You want 2 extra. In product totals, it calculates 6 pieces.
etc.

The PR is rebased and fix this bug https://github.com/PrestaShop/PrestaShop/pull/16573
Can this pr be included in 1.7.6.3 or 1.7.7 ? Why waiting for 1.7.8 ?

Hello @jf-viguier

Not in 1.7.6.3 because we fix in patch versions only regressions of the last minor (1.7.6.0)
And the bug fixed by this PR isn't a regression of 1.7.6.0

And I don't think it will be for 1.7.7 because we are very close to the freeze
We need to stay focus on "must-have" items if we don't want to delay the 1.7.7

@marionf Can you try to push it in the team? There were several PR's regarding discounts and gift calculations. We could have this whole gift&discounts issue fixed.

Again, it's nice everyone works on BO, but FO is what sells and keeps the merchants alive. 👍

@marionf It's just few lines of code that fix a major bug, please add it to the 1.7.7.
I agree with @Hlavtox : my merchants doesn't understand why bugs in commercial actions are not
considered majors and still be relegated to the Saint Glin Glin ;-)
The original issue has two years old.

i agree... its very frustrating...

Any change can produce regressions, no matter how small it is. Even it's just one character, it can produce unpredictable side effects as long as code is coupled and not covered by automated tests. Proof of that is that despite all our efforts, we end up having to release patch versions after each minor release.

This is why we try to be as strict as possible in terms of what goes in which version. Old bugs are fixed in minor versions, and new ones (regressions) in patch versions. In patch versions we only accept bug fixes for new regressions in order to ensure that no we aren't adding new bugs in the previous minor: it's no use fixing old bugs if we are adding new ones. We think that this strategy should lead to a progressively decreasing global number of bugs.

Regardless of patch or minor version, at one point we need to stop adding last minute things, or else we'll keep on adding and adding stuff and pushing release forever. We've seen this too many times now, which is why we try and restrain from from doing that. The last thing we'd want is having further delay a release because of a regression introduced by an unscheduled last minute fix.

Any news here ?

Hello @marionf,
As merchants, we encounter many problems because of this issue, this impacts our clients and our customer service team. I understand that you've got a lot on your plate but since the solution has already been identified, we would really appreciate if this could be fixed shortly since it has been affecting us for months already. Is there really nothing you can do for now? Do you have any idea about when it can be fixed please?
Thank you very much for your help!

@florianeb-meme @jf-viguier @micka-fdz @tonspeed @Azeus1980 @benlecoqartisans

Hi, this is a temporary fix for displaying gifts properly in 1.7.7 beta2 or final. Should work for 1.7.6 also.

classes/controller/FrontController.php

  1. Find assignGeneralPurposeVariables function.
  2. Change 'cart' => $this->cart_presenter->present($this->context->cart), to 'cart' => $this->cart_presenter->present($this->context->cart, true),

src/Adapter/Presenter/Cart/CartPresenter.php

  1. Find present function.
  2. Change
if ($shouldSeparateGifts) {
    $rawProducts = $cart->getProductsWithSeparatedGifts();
} else {
    $rawProducts = $cart->getProducts(true);
}

to
$rawProducts = $cart->getProducts(true);

  1. Add this right before return
if ($shouldSeparateGifts) {       
  $rawProducts = $cart->getProductsWithSeparatedGifts();
  $products = array_map([$this, 'presentProduct'], $rawProducts);
  $products = $this->addCustomizedData($products, $cart);
}

hi @Hlavtox
i tried your temporary fix but still no $product.is_gift value present in product Array.
i noticed that this value disappears when the $rawProduct is passed through "presentProduct" in array_mapping!

Since we had no news on the related PR since October 7th (https://github.com/PrestaShop/PrestaShop/pull/17825#issuecomment-704815404), this topwatcher issue is back to the _to do_ column to be completed.

Was this page helpful?
0 / 5 - 0 ratings