Shopify Functions "change_line_price" function

NADevJB
Shopify Partner
1 0 0

In Shopify scripts via ruby you could discount a line item by using the "change_line_price" function. This was agnostic of product variant ID and would only discount the checkout line item. This means if product A was in the cart twice, but was part of a deal if paired with product B, only 1 line item containing product A would be discounted. In shopify functions the product discount API targets a variant ID meaning product A would be discounted twice.

 

Example Cart using Shopify scripts ruby app - Correct functionality
Product A - Discount by 10% if bought with product B
Product B - Discount by 10% if bought with product A

Product A - Not discounted. Must add another product B line item

 

Screenshot 2023-10-18 at 10.56.18.png

checkout.jpg

 

Example cart using Shopify functions product discount API - Incorrect functiaonlity

Product A - Discount by 10% if bought with product B
Product B - Discount by 10% if bought with product A

Product A - Discounted by 10%. Product discount API is targeting variant ID therefor discounting both Product A's.


Does anyone have a solution whereby you can create the "change_line_price" functionality in Shopify functions please.

Reply 1 (1)

MalibuIconic
Shopify Partner
2 0 0

I have only got it to work with "unstable" API as it has the ALL enum attribute.