Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Handle inelegible products "free gift" discount#41050

Open
nicosomb wants to merge 22 commits into
PrestaShop:developfrom
nicosomb:issue-39803
Open

Handle inelegible products "free gift" discount#41050
nicosomb wants to merge 22 commits into
PrestaShop:developfrom
nicosomb:issue-39803

Conversation

@nicosomb
Copy link
Copy Markdown
Contributor

@nicosomb nicosomb commented Mar 23, 2026

Questions Answers
Branch? develop
Description? Handle inelegible products "free gift" discount
Type? improvement
Category? BO
BC breaks? no
Deprecations? no
How to test? See the tests list in the issue #39803
UI Tests https://github.com/nicosomb/ga.tests.ui.pr/actions/runs/25320653580
Fixed issue or discussion? #39803
Related PRs N/A
Sponsor company PrestaShop SA

@nicosomb nicosomb added this to the 9.2.0 milestone Mar 23, 2026
@ps-jarvis ps-jarvis added Improvement Type: Improvement develop Branch labels Mar 23, 2026
@github-project-automation github-project-automation Bot moved this to Ready for review in PR Dashboard Mar 23, 2026
@nicosomb nicosomb force-pushed the issue-39803 branch 2 times, most recently from b23e3f4 to 1a6d290 Compare March 23, 2026 15:04
@ps-jarvis
Copy link
Copy Markdown

ps-jarvis commented Mar 23, 2026

This pull request seems to contain new translation strings. I have summarized them below to ease up review:

  • Shop.Notifications.Error
    • The gift product does not exist.
    • The gift product is not available for order.
    • The gift product does not meet the minimum quantity.
    • You cannot have a customizable gift.
    • The gift product is out of stock.
  • Admin.Catalog.Notification
    • This product is not available for order.
    • This product requires a minimum quantity greater than 1.
    • This product has required customization fields.
    • This product is out of stock.
    • To offer a free gift, you first need to add a product to your catalog.
  • Admin.Catalog.Feature
    • Free product
    • When selecting a free product, please ensure it meets the necessary conditions to be offered as a gift.
    • Select free product
    • No product selected
  • Admin.Catalog.Help
    • Select a product from your catalog to offer it for free when this discount is applied.
  • Admin.Navigation.Menu
    • Manage products

(Note: this is an automated message, but answering it will reach a real human)

@nicosomb nicosomb force-pushed the issue-39803 branch 3 times, most recently from 5fd9708 to 95c2d2b Compare March 23, 2026 15:24
@nicosomb nicosomb linked an issue Mar 23, 2026 that may be closed by this pull request
@nicosomb nicosomb marked this pull request as ready for review March 23, 2026 16:21
@nicosomb nicosomb requested a review from a team as a code owner March 23, 2026 16:21
@Hlavtox
Copy link
Copy Markdown
Contributor

Hlavtox commented Mar 23, 2026

What if the user wants to prepare cart rule and then activate the rule and gift together?

@nicosomb
Copy link
Copy Markdown
Contributor Author

ping @ibahloul-ps

@nicosomb
Copy link
Copy Markdown
Contributor Author

@Hlavtox in fact, I don't understand your question. Is this related to this pull request?

@Hlavtox
Copy link
Copy Markdown
Contributor

Hlavtox commented Mar 24, 2026

@nicosomb Of course, what else are you implementing? :-)

You are preventing creating of cart rule if a product is out of stock or disabled, but that essentially prevents you from creating this cart rule in advance.

I think that a merchant should be able to create this cart rule. If the gift product is not enabled or out of stock, the cart rule is just not usable.

ping @kpodemski

@kpodemski
Copy link
Copy Markdown
Contributor

I agree. The validation should be in the applyDiscount layer, not in the back office.

@ibahloul-ps
Copy link
Copy Markdown

You are preventing creating of cart rule if a product is out of stock or disabled, but that essentially prevents you from creating this cart rule in advance.

Hello guys

It should not be the case, we just want to prevent creation/application of discount when a product is not eligible like described here :

  • not available for order
  • minimum quantity for sales > 1
  • customizable (with required field)

everything else must work as before

We agreed on that a few months ago 👍

@kpodemski
Copy link
Copy Markdown
Contributor

@ibahloul-ps

minimum quantity for sales > 1

Makes sense.

customizable (with required field)

Makes sense.

not available for order

Does not make sense. You may want to add a product for the gift that isn't normally available to order, I think. Cc @Hlavtox

@Hlavtox
Copy link
Copy Markdown
Contributor

Hlavtox commented Mar 25, 2026

@kpodemski That won't work. A gift must be normally orderable product.

IMHO this is how it should be and this should be the current behavior:

  • not available for order - block creation
  • minimum quantity for sales > 1 - block creation
  • customizable (with required field) - block creation
  • not in stock - allow creation, block application. This can even be random. The product can go to zero temporarily, until you restock it. If you open the cart rule edit during this time, you won't be able to suddenly save it?
  • disabled - allow creation, block application

You may want to add a product for the gift that isn't normally available to order.

Yeah, you may want, but you cannot do it. I have many examples where we want to give gifts and we don't want people to order it separately. Cannot do it in PrestaShop and we won't be able to do it even with the new discount system. I have to do all kinds of hacks to hide the product, block it from ordering, hiding it from search etc.

Unfortunately, basically no usecase I know of has been resolved with the new discount UI...

Comment thread classes/CartRule.php Outdated
@ibahloul-ps
Copy link
Copy Markdown

IMHO this is how it should be and this should be the current behavior:

  • not available for order - block creation
  • minimum quantity for sales > 1 - block creation
  • customizable (with required field) - block creation
  • not in stock - allow creation, block application. This can even be random. The product can go to zero temporarily, until you restock it. If you open the cart rule edit during this time, you won't be able to suddenly save it?
  • disabled - allow creation, block application

We are aligned, that is exactly the purpose of the related issue 👍

Yeah, you may want, but you cannot do it. I have many examples where we want to give gifts and we don't want people to order it separately.

What do you mean? Can you share some examples plz 🙏

@Hlavtox
Copy link
Copy Markdown
Contributor

Hlavtox commented Mar 25, 2026

@ibahloul-ps

What do you mean? Can you share some examples plz 🙏

You know how sometimes you get a drink, some sample of perfume or whatever, and it has Not for individual sale on it written?

This is the same case - I had many cases where our company, or my other clients, wanted to give some product as a gift, but we didn't want to sell it separately. For example, a pack of coffee. So, you create a product, set it's price to zero, so the total amounts of orders is not affected. (see #38325). Create the cart rule etc. All good.

But, if a price is zero, you don't want people to be able to order it, so what you can do is to set visibility to "Nowhere", you can write "Not for individual sale" into the description. But some "curious customer" will always find it and create a new order with 0 CZK for 5 packs of coffee. :-D

@kpodemski
Copy link
Copy Markdown
Contributor

@Hlavtox

Exactly, that's one of the common cases I've seen. I've always had to modify the core to prevent ordering some sample products as individual items.

@nicosomb
Copy link
Copy Markdown
Contributor Author

@Hlavtox @kpodemski thanks to your review, i made some changes.
if it's not OK for @ibahloul-ps, i can easily remove this commit and we can keep what I've done previously.

return [true, $this->translator->trans('This product has required customization fields.', [], 'Admin.Catalog.Notification')];
}

$stockQuantity = (int) ($productRow['stock_quantity'] ?? 0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this should not turn the discount into a disabled state; this part should be tested dynamically in the checkValidity function (and probably already is)

jolelievre
jolelievre previously approved these changes May 19, 2026
Copy link
Copy Markdown
Contributor

@jolelievre jolelievre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nicosomb

mattgoud
mattgoud previously approved these changes May 20, 2026
@nicosomb
Copy link
Copy Markdown
Contributor Author

mattgoud
mattgoud previously approved these changes May 22, 2026
tleon
tleon previously approved these changes May 22, 2026
boherm
boherm previously approved these changes May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

develop Branch Hook Contribution Improvement Type: Improvement Waiting for author Status: action required, waiting for author feedback Waiting for QA Status: action required, waiting for test feedback

Projects

Status: Need 2nd approval

Development

Successfully merging this pull request may close these issues.

Free gift product - Inelegible products