Prestashop: [1.7.7] $cart->getProductsWithSeparatedGifts() does not contain required information

Created on 26 Jun 2020  路  11Comments  路  Source: PrestaShop/PrestaShop

Steps to Reproduce

  1. Create a cart rule that gives free gift to order.
  2. Go to FO and recreate this situation.
  3. Call $this->context->cart->getProductsWithSeparatedGifts() somewhere in the code or from your module and print it.
  4. is_gift value in the gifted product should be 1, it's empty.

Cause
$refresh = true in getProductsWithSeparatedGifts()

Additional information

  • PrestaShop version: 1.7.7
  • PHP version: 7.2
1.7.7.x Bug No change required

All 11 comments

Thanks for opening this issue! We will help you to keep its state consistent

Ping @PrestaShop/prestashop-core-developers

馃啓

Hello @Hlavtox, thank you for the issue, I just tried to reproduce it, but I didn't manage, here's what I did:

1/ In BO, I created a cart rule with a free gift
2/ In FO, I added one product in my cart, meeting the conditions for the free gift
3/ In FO, cart page, I see that the free gift is correctly added, and when I call $this->context->cart->getProductsWithSeparatedGifts(), I see that the product I added to the cart has is_gift set to false, and the product added as a free gift has is_gift set to true, which is the normal behavior.

Maybe this bug manifests itself in more specific conditions?

I close this issue until a clearly reproducible scenario is defined.

@matthieu-rolland @matks @Progi1984 @jf-viguier

  1. Add this to cart.
  2. Refresh page and see the output. No is_gift=true anywhere.
    http://test.trendo.cz/art/5-today-is-a-good-day-framed-poster.html

BTW @matthieu-rolland, how it can work for you when the logic that sets this flag is disabled by a condition that is not met?
1

@Hlavtox I'm not familiar with this feature, but it just does work when I debug in the backend, whether it is in the cart, or on the product page, without doing anything special. Am I missing something obvious? I'm reopening the issue, I'll take the time to debug this.

Meanwhile, could you tell me where exactly do you call $this->context->cart->getProductsWithSeparatedGifts() from ?

Capture d鈥檈虂cran 2020-08-12 a虁 17 52 58

@Hlavtox it seems like your 1.7.7 is not up to date, your second capture does not match the code of this method on 1.7.7:

https://github.com/PrestaShop/PrestaShop/blob/4ad2a245ad117db10eeec696537b6808d5666a03/classes/Cart.php#L767

@matthieu-rolland I will confirm with the latest code and let you know. But if its fixed - good!

yeah, right

@matthieu-rolland @matks Fixed in current 1.7.7 code! You were right. 馃殌

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Van-peterson picture Van-peterson  路  3Comments

hiousi picture hiousi  路  3Comments

Prestaworks picture Prestaworks  路  3Comments

vincent-dp picture vincent-dp  路  3Comments

marionf picture marionf  路  3Comments