The Cart Transform API line items costs
Doesn’t reflect the price, after a discount has been applied.
This just seems misleading then
The cost of the merchandise line that the buyer will pay at checkout.
I have a case where I have a native automated discount, which changes the price of the product.
But when I read that price with any of the Cart line cost methods, I just get the original price in return.
Any way to overcome this, and actually either get the discount applied, or just get the actual adjusted price?
One quick thought here would be to utilize that automatic discount in the code to pre-discount the price for your other code to utilize since it seems getting the discounted price natively is not supported there yet.
Not necessarily ideal but a quick workaround for now.
Frankly the discount codes and automatic discounts code apply after the transforms, I am unsure, but it would explain why you cannot see such price within the transforms.
1 Like
Not sure I understand how you would connect the automatic discount to set a pre-discount?
I can’t access the discount information via the Cart Transform, so I would have an entirely new extension running, or what are you thinking?
I was thinking you hard-code in what the discount would be, percentage or fixed, and then adjust the price within the transforms using that… In a way that is easily adjustable moving forward, of course.
Not a fan of the hard-coded values, wen’t in another direction. Posting solution next
My goal were to change the title of a product in the cart, when achieving certain discounts (but always when the product price = 0).
My solution for this, ended up being using the Cart Ajax Update endpoint, once registrering any discounts value on the line_item, from the /cart.json
data, and setting my own line_item properties, with the discounts data. And then using those properties to adjust the titles.
Sorry for any confusion, I did not mean to hard-code it directly into the theme code itself, but utilizing some sort of Theme Setting or metafield value that you pull in so that it could be remotely configured in a sense.
1 Like