Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Re: Order Discounts

Order Discounts

cvwat
New Member
5 0 0

We are a collective store and I want to be able to offer discounts from the store, but when I do an order discount the discount gets evenly split between all of the products (and product vendors). Is there a way for the discount to come off the order but not affect the product price? 

Replies 13 (13)

cvwat
New Member
5 0 0

Added note, these are for an in store POS system.

Ahmad31
Shopify Partner
109 9 8

 

Apply the discount at the order level, without altering the individual product prices.

You can add a "discount line item" in the checkout process to reduce the total order price. This way, the product prices remain the same, and vendors receive the correct revenue for their products.

 

Love my work? Buy me a coffee!
Need a Shopify Developer: Email me Or Chat on Whatsapp
If you found my solution helpful, please like and accept it. Your support is greatly appreciated!
cvwat
New Member
5 0 0

Is that the same as a "Custom Cart Discount"? I don't see "discount line item" listed.

Ahmad31
Shopify Partner
109 9 8

 

A custom cart discount applies a percentage or fixed amount discount at the checkout stage. Shopify natively supports this via discount codes or automatic discounts.

The discount is applied to the total order value, which gets distributed across all the products in the cart. This may reduce the final amount each vendor receives in a multi-vendor store.

 

Love my work? Buy me a coffee!
Need a Shopify Developer: Email me Or Chat on Whatsapp
If you found my solution helpful, please like and accept it. Your support is greatly appreciated!
Ahmad31
Shopify Partner
109 9 8

You can write a custom script that applies a discount at the cart level without changing individual product prices. This ensures that the discount reduces the total cost but doesn't impact the product breakdown for vendors.
Example of script:


DISCOUNT_RATE = 0.20


Input.cart.line_items.each do |line_item|

next if line_item.variant.product.gift_card?


line_item.change_line_price(line_item.line_price * (1 - DISCOUNT_RATE), message: "20% Cart Discount")
end

Output.cart = Input.cart

Love my work? Buy me a coffee!
Need a Shopify Developer: Email me Or Chat on Whatsapp
If you found my solution helpful, please like and accept it. Your support is greatly appreciated!
cvwat
New Member
5 0 0

Oh man, this is way over my head! 😬

cvwat
New Member
5 0 0

Thank you for all your help! Are you able to tell me where I can locate the "discount line item" that you previously mentioned?

Ahmad31
Shopify Partner
109 9 8
  1. Log in to Your Shopify Admin Panel: Go to your Shopify store admin by logging in at your-store-name.myshopify.com/admin.

  2. Navigate to Discounts:

    • On the left sidebar, click on "Discounts."
    • This will take you to a page where you can view all existing discounts and create new ones.
  3. Create a New Discount:

    • Click on "Create discount" on the top right.
    • You can choose between:
      • Discount code: A code that customers enter at checkout.
      • Automatic discount: Automatically applied at checkout without needing a code.
  4. Configure the Discount:

    • For discount codes:
      • Enter a code (e.g., SAVE10).
      • Set the discount type (percentage, fixed amount, free shipping, etc.).
      • Specify the amount, usage limits, and any applicable conditions.
    • For automatic discounts:
      • Specify the discount type and conditions for when it should be applied.
  5. Save the Discount:

    • After filling in the required fields, click "Save" to activate the discount.

For Shopify Plus Users:

  1. Log in to Your Shopify Admin Panel: Use the same link as above to access your admin panel.

  2. Navigate to Discounts:

    • Click on "Discounts" in the left sidebar.
  3. Create or Edit Discounts:

    • You can create discounts just like standard Shopify users, but Plus users also have the option to create more advanced discounts using Shopify Scripts.
  4. Use Shopify Scripts:

    • Go to "Apps" in the left sidebar, then select "Script Editor."
    • From here, you can create scripts that apply discounts dynamically based on various conditions (e.g., cart value, specific products, customer tags).
  5. Write the Script:

    • Use the Ruby code to specify your discount logic (like the examples I provided earlier).
Love my work? Buy me a coffee!
Need a Shopify Developer: Email me Or Chat on Whatsapp
If you found my solution helpful, please like and accept it. Your support is greatly appreciated!
Igold
Tourist
16 0 1

I also have Plus and I would like to give a discount not on the entire cart but only on the product I decide to give a discount on, what script method?

Ahmad31
Shopify Partner
109 9 8

# Define the product you want to discount
DISCOUNT_PRODUCT_ID = 1234567890 # Replace with the actual product ID
DISCOUNT_PERCENT = 20 # Define the percentage discount

# Loop through the items in the cart
Input.cart.line_items.each do |line_item|
product = line_item.variant.product

# Apply discount only to the specified product
if product.id == DISCOUNT_PRODUCT_ID
line_item.change_line_price(line_item.line_price * (1 - DISCOUNT_PERCENT / 100.0), message: "Custom Discount Applied")
end
end

# Output the modified cart
Output.cart = Input.cart

Love my work? Buy me a coffee!
Need a Shopify Developer: Email me Or Chat on Whatsapp
If you found my solution helpful, please like and accept it. Your support is greatly appreciated!
Ahmad31
Shopify Partner
109 9 8

How to Get the Product ID:

  • In Shopify Admin, go to Products.
  • Open the specific product.
  • Look at the URL; the product ID will be the last number in the URL (after /products/).
Love my work? Buy me a coffee!
Need a Shopify Developer: Email me Or Chat on Whatsapp
If you found my solution helpful, please like and accept it. Your support is greatly appreciated!
Igold
Tourist
16 0 1

I don't want to select a specific variant, so I would like to give discount sometimes separately in the cart for some products.

Igold
Tourist
16 0 1

The issue is that I want to offer a discount option for all my products, but I won't be offering a discount on all of them during the sale.