How to apply discount on only 1 quantity of a product in cart?

Shopify Partner
5 0 1

I want to create a hard-coded upsell product in my cart, where the user clicks on the product's "ADD" button and the product will be added to cart with a discount on it's original price. 

My requirements:
- Not use Shopify Scripts (do not own shopify plus)
- The product will have a discount of XX% applied on it only, not anything else in the cart (noting that other discounts will apply as well regularly).
- The discount will apply only on the upsell product, if there is another product of the same type and variant in cart but is not THE upsell product, it will be the original price.
- The solution should not use a variant workaround, where I create a hidden variant with the discounted price. 
- The "discount" applied can be a discount code applied on the specific instance of the upsell product, or by manipulating the price, either way is fine by me.
- The behaviour is the same as all upsell apps on the store.

Firstly, can this be done without Shopify Functions? If not, how do I implement this using Shopify Functions? The docs for shopify functions are very layered and nested and are a bit difficult for me to navigate as a junior dev. Any help is highly appreciated.

Replies 0 (0)