You’re correct that Shopify’s Cart API (/cart/add.js) doesn’t support setting a custom price directly on a line item for security and consistency reasons. Shopify controls product pricing through the product and variant settings in the admin panel, so you can’t override prices via the frontend cart API.
Here are a few recommended approaches to handle this:
- Use Discount Codes or Automatic Discounts
If the bundle discount is consistent (e.g., “Buy 2, get 20% off”), you can:
Set up automatic discounts in the Shopify admin, or
Generate discount codes programmatically using the Admin API and apply them at checkout.
However, this only works at checkout and not directly in the cart subtotal.
- Create a Hidden “Bundle” Product Variant
A common workaround is:
Create a new, hidden product or variant that represents the bundle with the discounted price.
When a customer selects a bundle, add this hidden product to the cart instead of the individual items.
Make sure to manage inventory and fulfillment logic accordingly, since you’re not actually adding individual SKUs.
- Use Shopify Functions & Custom Apps (Shopify Plus Only)
If you’re on Shopify Plus, you can:
Use Shopify Functions to create custom pricing logic that runs during checkout.
This allows you to apply precise bundle logic and pricing dynamically.
- Modify the Cart Display (Visual Price Changes)
If none of the above options are viable, you can:
Add custom JavaScript to visually display the discounted price in the cart UI.
Clearly note that the actual price will update at checkout via a discount code.
Keep in mind: Visual-only discounts can be confusing if not clearly communicated, and the customer will still see the original item prices until checkout unless a discount is applied.
If you need help with it you can dm