on 2025 May 15 2:40 PM
Background
I need to offer a bundle promotion on my Hybris storefront where purchasing a qualifying product X entitles the customer to choose one item Y from a predefined list. The Y items may be completely free or discounted (e.g. 50% off).
Requirements
Product Detail Page (PDP)
Display a promotion widget on X’s PDP listing several eligible Y products.
Pre-select one of the Y items by default, but allow the shopper to pick any other.
Shopping Cart Behavior
When X is added to cart, automatically add the selected Y as a separate line item with its adjusted price (0 or discounted).
If the customer changes or re-adds X, a new Y line item must be created (not merged).
Removing X must not remove Y, but should strip Y of its promotional discount (i.e. revert Y to full price).
The customer must be able to remove Y independently.
Questions
What’s the recommended way to model this in Hybris’s promotion engine?
Should I use a Catalog-Level “Bundle” promotion or a Cart-Level “Buy X, Get Y” rule with custom actions?
Are there sample rule conditions/actions or extension points you’d suggest to handle the selectable gift list and the cart-line logic above?
Any pointers—rule definitions, code snippets or storefront-customization tips—would be greatly appreciated!
Request clarification before answering.
I think your requirement can be divided into several parts:
1. Discount Logic
It seems your discount requirement is a straightforward "Buy X, Get Y" scenario. You can define two containers (X and Y) with qualifying product conditions and use the Percentage discount on partner products action to apply the desired discount.
2. Storefront Display
By default, SAP Commerce creates ProductForPromotionSourceRule records after a promotion is published. These records are managed inside the DefaultProductConditionResolutionStrategy class when the y_qualifying_products condition is defined. Similarly, category-related records are created inside the DefaultCatConditionResolutionStrategy class when the y_qualifying_categories condition is defined.
These records are used to display promotions on the storefront. You can leverage them to display products from the Y list when a product from the X list is viewed. However, this may require additional processing of the promotion rule, as these records only contain the product code and the rule.
Alternatively, you might create additional records to explicitly relate X and Y products. Note that the ConditionResolutionStrategy interface does not have access to actions, so you may want to work with the RuleCompilerListener's afterCompile() method. Debugging this method during promotion compilation can help identify where to extract the needed information.
3. Automatically Adding the Product to the Cart
Once the user sees the Y products on the PDP and selects one, the implementation should be simple. You would receive the second product in a form, and when the user clicks "Add to Cart," both products (X and Y) can be added together.
4. Creating a New Entry for Each Discounted Product
This part is a bit tricky. By default, SAP Commerce merges cart entries for the same product. However, in CommerceCartParameter, there's a parameter called createNewEntry. If it's set to true, the product added will not be merged with existing entries in the DefaultCommerceAddToCartStrategy class.
This behavior can help you add the Y product as a separate entry. Still, it requires thorough testing in different scenarios. It also raises several questions:
These are design decisions that should be clearly defined. Also, test how the promotion behaves when there are multiple entries for the same product. Although it should work, the default merging behavior might lead to unexpected issues.
5. Independent Removal of Entries
This should be straightforward. Since you're not using the Free Gift action of the promotion engine, each cart entry behaves independently. If product X is removed, the promotion condition is no longer satisfied, and product Y will revert to its full price.
I hope this helps,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
33 | |
22 | |
17 | |
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.