APIs to update the price of a product based on input value and a base price metafileld

Cindy29
Visitor
2 0 0

Hi everyone, i need assistance with a task. When submitting a product form, the product's price, determined by multiplying the base price per meter of fabric (retrieved from a metafield) with a user-input value, needs to be updated. This price change should only affect the current session, not the entire inventory. I've already set up a serverless function to fetch the base price per meter using the product ID. Could you guide me on how to adjust the cart session price using GraphQL APIs, without creating a custom app? Or do you have other solutions? 

Replies 2 (2)

SBD_
Shopify Staff
1826 268 395

Hey @Cindy29 

 

One approach would be to set the price as 'per meter' and then treat the quantity (user input) as the number of meters. This would also eliminate the external request - would this suit?

Scott | Developer Advocate @ Shopify 

Cindy29
Visitor
2 0 0
Yes I thought of that, but I need lengths in decimals (0.25m, 0.50m, 0,66m
…).
Any input can be valid.