My app creates a product for each bundle, which supports cart transformation - expand and merge operations.
There is a common request. Users want to exclude a bundle from the existing discounts. This is because the bundle has been eligible for a bundle discount. The stores don’t want to offer an extra discount on the bundle. But I don’t find any way to do so. The stores can only check each discount and exclude the bundle products manually, which causes a headache. Is there an easier way to do so?
I want to post the thread with regards to discounts. But I don’t find a relevant board for discounts here.
I’m not sure what level of access your app/you would have on your client’s shops, but you could create a collection specifically for those bundled items and exclude that collection from any discounts. Let me know if this works for you - happy to keep looking into this if needed
@Alan_G My app can access products, collections, discounts, orders, etc.
Sometimes, the users may have many existing discounts, either created by themselves or created via 3rd party apps. It may be hard to edit these discounts one by one manually.
The logic is something if (at least a cart line item has a specific attribute, or with a special tag, or a bundle group) AND there is a discount => then don’t allow checkout.
I’m afraid the discount is not available in the cart but only in checkout
Hey again @Benny_Chan, you’re right that cart validation functions don’t have direct access to discount fields in their input - they can only see line item attributes, prices, and metafields.
You should be able to implement a workaround by adding attributes to bundle line items (like is_bundle_component: true), more info here and comparing the actual price against an expected bundle price stored in a metafield on the product(s) itself to detect if additional discounts have been applied.
This approach does have some limitations since you can’t see which specific discounts are applied and you would need to make additional Storefront API calls to get the metafield of the bundled product, it could help prevent checkout when unwanted double-discounting is detected on bundles.
You should also be able to use Shopify Functions for discounts to exclude certain products at the discount calculation level rather than trying to validate after discounts are applied if you wanted to take a look at that route.
Let me know if I can clarify anything as always on my end here - happy to help!
If I can detect a discount in the cart transform function, what can I do to prevent a discount from being applied? I can’t call a storefront API in the function either.
One of my use cases is to use the cart transform function with expand operation. expand: The adjustment is based on the bundle product price.
I give a bundle discount via the bundle product, e.g. $100. But I can’t stop other discounts from applying on checkout.
Hey @Benny_Chan, sorry again for the stale links, here are the current docs for Discount Functions and the cart-lines API:
and
Just to set expectations: Discount Functions let you make your bundle discount non-stackable, but it can’t prevent existing merchant/other app order-level (rather than product-level) discounts from applying to the bundle products. Just wanted to confirm as well that Cart or Checkout Functions still don’t receive any discount data, so they can’t block a discount directly.
Right now the best current way to keep extra discounts off a bundle is to keep those products in a “Bundle Products” collection and make sure every other discount excludes that collection. Your app can automate the heavy lifting by updating all current discounts and patching new ones via the Admin API if needed. Let me know if anything’s unclear or if you hit a snag, more than I’m happy to help.
@Benny_Chan :
Assuming your app creates a bundle product in shopify. I suggest setting some tag or associate it with some collection.
The discount function should not apply discount to any product with a specific tag or if its in a speicfic collection.
Questions :
Is my assumption that these bundles exist in shopify as bundle products.
You are not creating bundles using merge of cart transform.
Even if other apps are used for discount calculation then the tag rule shall be applied to the apps so that these apps exclude and do not allow product discount.
Summary :
When you create a bundle apply a tag.
All apps that apply discount shall have rules that make sure that this specific tagged product is execluded from discount.
@Benny_Chan : A request to share a use case with following data so that I have a clarity to respond.
What rules are applied by your discount app.
Is your app creating a bundle as an admin activity( not via cart transform ) from product if so share some data so that we have a clarity on how the bundle is created.
What product are merged to create a bundle( I think this will not have any issue as once cart transform is done then the discounts will not be applied ) or
What products are split from a bundle and converted to individual products.
The confusion for me is :
is your app creating bundlees as well form admin or is it just using cart tranform but not creating any bundles.