Quantity discount at check out

Topic summary

A user seeks help implementing a quantity-based discount system for specific products in their Shopify store. The requirements include:

Discount Structure:

  • “2 for X” pricing on select products
  • Customers can mix variants within the same product to reach quantity of 2
  • Discounts apply in multiples of 2 (e.g., 4 items = discount on all 4; 3 items = discount on 2, full price on 1)
  • No cross-product mixing allowed

Display Preferences:

  • Discount shown at cart level, not product page
  • Per-item discount display rather than total order discount
  • Avoid bundle/discount apps that force “bundle and save” boxes on product pages

Technical Approach:
A PageFly support representative (Theodore) responded with a JavaScript/Liquid script solution to check cart quantities and apply discounts to qualifying products. The implementation involves adding code to the cart template file (cart.liquid) before the closing body tag.

Current Status:
The discussion remains unresolved—Theodore’s code snippet appears corrupted or failed to post correctly, and the original poster has requested a repost of the intended solution.

Summarized with AI on November 9. AI used: claude-sonnet-4-5-20250929.

Hello,

I am looking for help with code to provide a volume/quantity discount for specific products in my store. Here are the details:

  • I would like to offer a “2 for X” discount on specific products
  • The customer should be able to select different variants within a product to get to a quantity of 2.
  • Do not mix and match products – this would only apply to that specific product.- I would like the discount to be shown in the cart, not at the product level
  • I’ve tried using bundle/discount apps and have had issues with every one where I am forced to add a “bundle and save” box to the product level and I do not want this.- Discount should apply to multiples of 2
  • If the customer purchases 2 items, they will get a discount on each item. If the customer purchases 3 quantity of the same item, they will get a discount on 2, but pay full price for the 3rd item. Likewise – if a customer purchases 4 quantity of an item, they will get a discount on each pair- When a customer meets the quantity expectation I would like the discount to be shown per item vs. a discount on the total order.

I’ve been searching and searching and cannot find the answers I need. Shopify help center provides the following liquid code for cart quantity, but I’m not sure how to adjust it for what I need - or if this is the correct function to use.

{% comment %} Cart quantity {% endcomment %}

{{ cart | line_items_for: product | sum: ‘quantity’ }}

{{- ‘products.product.quantity.in_cart’ | t: quantity: cart_qty -}}

Would greatly appreciate any help!

thanks,

Alexandra

Hi @Varria ,
This is Theodore from PageFly - Shopify Page Builder App.

  1. We’ll use a script to check the cart for specific products and their quantities.
  2. If a product has a quantity that’s a multiple of 2 (2, 4, 6, etc.), a discount will be applied per item.
  3. The discount will only be applied to the specific product, not affecting other items in the cart.

Steps:

  1. Create a Script Tag:
    • Go to your Shopify admin panel > Online Store > Themes.
    • Click on “Actions” beside your active theme and select “Edit code.”
    • In the “Layout” folder, find the theme file that displays your cart contents (usually cart.liquid).
    • Paste the following code snippet before the closing tag:

Best regards,
Theodore | PageFly

Hi Theodore,

Can you repost the code you intended to give in your last comment? It didn’t post.

Appreciate your help!

Thanks,

Alexandra