Quantity discount at check out

Quantity discount at check out

Varria
Tourist
11 0 2

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 %}

<span id="CartQuantity-{{ section.id }}" data-product-url="{{ product.url }}" data-section-id="{{ section.id }}" data-variant-id="{{ product.selected_or_first_available_variant.id }}">

{{ cart | line_items_for: product | sum: 'quantity' }}

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

</span>

 

 

Would greatly appreciate any help!

 

thanks,

Alexandra 

Replies 2 (2)

PageFly-Theodor
Shopify Partner
691 86 100

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 </body> tag:


Best regards,
Theodore | PageFly

Please let me know if it works by giving it a Like or marking it as a solution!


PageFly - #1 Page Builder for Shopify merchants.


All features are available from Free plan. Live Chat Support is available 24/7.

Varria
Tourist
11 0 2

Hi Theodore, 

 

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

 

Appreciate your help!

 

Thanks,

Alexandra