You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Anil K Patel (Jira)" <ji...@apache.org> on 2026/07/03 10:46:00 UTC
[jira] [Commented] (OFBIZ-3634) ProductPromoWorker PROMO_GWP hard-codes a required inventory check
[ https://issues.apache.org/jira/browse/OFBIZ-3634?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18093402#comment-18093402 ]
Anil K Patel commented on OFBIZ-3634:
-------------------------------------
Took a fresh look at this on current trunk.
The behavior is still there, though it has moved. Promo actions were refactored out of ProductPromoWorker into pluggable services, and the gift-with-purchase action now lives in the productPromoActGiftGWP service (ProductPromoActionServices.groovy). It still hard-requires inventory for the gift - the comment in the code even says "even though the store may not require inventory for purchase, we will always require inventory for gifts" - and an out-of-stock gift is simply dropped from the cart. Adam's 2010 patch no longer applies against that refactored code, and the proposed PPIP_PRODUCT_INV condition was never added, so the "patch available" state here is misleading. On the plus side, the virtual-product case Adam was unsure about is now handled - the service checks inventory per variant.
The more useful thing I can add is on the requirement itself. Looking at how ecommerce retailers actually run gift-with-purchase programs, an out-of-stock gift is rarely something you want to backorder - holding an order open for a zero-value free item is usually the wrong outcome. What these programs tend to need instead is to substitute the out-of-stock gift with an approved equivalent so the order keeps moving, to tie the gift's lifecycle to the qualifying paid line so that if the paid item is cancelled or short-shipped the gift goes with it, and to enforce per-customer limits so the gift is not farmed. Those are order-management and fulfillment behaviors, decided at allocation and routing time, not a single inventory toggle in the cart.
Seen that way, the original request - make the cart-time inventory check optional so the gift can backorder - solves a narrow slice, and I would argue at the wrong layer. Requiring inventory for the gift at cart time is a reasonable and safe default, and the richer handling belongs in order orchestration rather than in the promotion engine.
So my suggestion is to close this one. The specific patch is obsolete, and the real-world need is better served at the fulfillment layer than by a backorder flag in the promo cart. If anyone is actually relying on backordered gifts, or wants a minimal cart-level option regardless, please say so and we can reconsider.
> ProductPromoWorker PROMO_GWP hard-codes a required inventory check
> ------------------------------------------------------------------
>
> Key: OFBIZ-3634
> URL: https://issues.apache.org/jira/browse/OFBIZ-3634
> Project: OFBiz
> Issue Type: Bug
> Components: order
> Reporter: Adam Heath
> Priority: Major
> Attachments: PROMO_GWP_inventory_check.patch
>
>
> PROMO_GWP processing always requires the gifted item to have available inventory. There is no way to have that configurable, no way to have the free item get backordered.
> The attached patch removes the inventory check on *real* products, and instead created a new condition, PPIP_PRODUCT_INV, so that *any* promo can pass/fail based on an inventory check.
> I did not commit this patch, because the full fix would need to handle virtual products as well. I don't understand how PROMO_GWP works with virtual products when doing inventory, so I need help with that.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)