How to translate change_line_price and change_properties from Script Editor into Shopify Function?

Shopify Partner
18 2 7

I have a few very simple scripts in the script editor that need to be converted into Shopify Functions. I need to be able to do two things with Shopify Functions:


1. Discount the prices of line items in the cart on an item by item basis. For example, offer a 10% discount on one item and a 20% discount on another. This is accomplished in the Script Editor with the change_line_price method.


2. Add/remove properties from line items in the cart. This is accomplished in the Script Editor with the change_properties method.


Shopify claims that the Product Discount API can be used to replace the change_line_price method, but it only allows me to offer one discount value at a time. For example, I can offer either a 10% discount or a 20% discount for items, but I can not offer a 10% discount for one item and a 20% discount for another. I have also not been able to figure out a way to change line item properties from within a Shopify Function using the Product Discount API.


Can someone please point me in the right direction here?







Replies 0 (0)