#Unit Price Modification Medusa Cart

13 messages · Page 1 of 1 (latest)

oblique sentinel
#

Hey @burnt wolf what you want i think is custom line item prices. Where the default bheaviour is for the line item unit price to be derived from the variant price, you can create a custom api route and workflow, to add an item to a cart, overriding the default behaviour with your own logic.

Here is an official guide showcasing how to do this in the context of real time Precious metal pricing API: https://docs.medusajs.com/resources/examples/guides/custom-item-price

In your particular case, it is a matter of deciding inside your workflow, how you are going to access these json files and match them with the corresponding variant, to override the unit_price

Explore Medusa's recipes, API references, configurations, storefront guides, and more.

burnt wolf
#

Id be happy to just "hardcode" a product to the cart, but it wont let me modify unit_price, for good reason im sure.

oblique sentinel
#

But you already have this vendor and auto site generation implemented with Medusa? I am trying to understand your ucrrent setup vs what you are trying to achieve

burnt wolf
oblique sentinel
#

so in Medusa you only have 1 product entity which includes all of the objecs in the JSON file as variants? As i said, the default addToCartWorkflow computes the unit_price based on the variant price.

If this is not what you want, then a similar approach to that of the guide i shared i think will be enough

burnt wolf
#

Think it worked 😫

#

Thank you

oblique sentinel
#

glad to hear that, did you go for the custom workflow route>

burnt wolf
#

This MedusaJS is one complex beast lol

oblique sentinel
#

Looks good to me

#

complex, but also allows to do really complex stuff with ease as long as you know the framework. And even when you don't know something, the amazing community has your back 💪

burnt wolf
#

or suspend lol