Line Items properties

How can i change line item properties of the order when the discount of the product is more than 50% using Shopify function?

i used this let result = await applyCartLinesChange({
type: ‘updateCartLine’,
id: id,
attributes: [{
key: ‘_sale’,
value: ‘final sale’
}]
})
}

Hi Prerana,

It doesn’t look like Shopify Functions provides the functionality to directly modify line items within the cart. The cart is part of the client-side storefront, and Shopify Functions operates on the server side. A better approach might be to use Shopify’s Storefront API (which all apps now have access to) or AJAX API on the client-side. These APIs let you interact with cart contents before the order is placed, allowing you to add or modify line item properties.

Hope this helps - take a look at the Storefront API and if you’re still having issues reply here and we look into this further!

Hi @Prerana

Seems like you don’t need script for this, request you to try below mentioned steps to achieve the same.

Modify main-product.liquid where you can add additional product attribute if discount match to your requirement.

Whenever user will hit the add to cart or checkout button attribute will be there in cart.

Hope this will help…

Liam, do you mean i can’t use a shopify checkout UI extension with a storefront Api to update line item attribute on checkout ?