How can i Update Custom Pricing on “Add to Cart” via Shopify Frontend Cart API

Topic summary

A developer is building a Shopify app that allows store owners to create custom product bundles with discounted pricing. The challenge is applying custom prices to cart items when customers select these bundles.

Core Issue:
Shopify’s Cart API (/cart/add.js) doesn’t support setting custom prices on line items for security reasons. Prices are controlled through the admin panel and cannot be overridden via the frontend API.

Suggested Solutions:

  1. Discount Codes/Automatic Discounts - Set up discounts in Shopify admin or generate them programmatically via Admin API (applies at checkout, not in cart subtotal)

  2. Hidden Bundle Product Variants - Create hidden products/variants representing bundles at discounted prices, add these to cart instead of individual items (requires managing inventory/fulfillment separately)

  3. Shopify Functions - Use custom pricing logic during checkout (Shopify Plus only)

  4. Visual Price Display - Use JavaScript to show discounted prices in cart UI while actual discount applies at checkout (may confuse customers if not clearly communicated)

Status: The discussion remains open with the developer following up via direct message for additional assistance.

Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

I am currently developing a Shopify app that enables store owners to create custom product packages (e.g., “Buy 2 items and get a discounted price”). Instead of the customer manually selecting a quantity, the frontend displays these predefined package options set by the store owner.

On the frontend, when a customer selects a bundle option, I use Shopify’s Cart API (/cart/add.js) to add the product to the cart with the specified quantity. However, I’ve encountered a challenge: while I can successfully send the quantity, I am unable to apply a custom price to the line item through the standard Cart API.

I would like to know the correct approach to apply a custom discounted price to items added to the cart based on the bundle logic defined by the store owner.

1 Like

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:

  1. 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.

  1. 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.

  1. 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.

  1. 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

I’ve Mailed you please check