You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, i'm trying to create a product with a single variant.
I created a custom service to calculate the price based on the selected height and width of the customer. When adding the item to the cart, i call a custom API route with the variant id, height and width, and add the cart item with the correct calculated unit_price.
I use generateLineItem for this and the cartService to add it. I can confirm through a simple db query that the unit_price has been set correctly.
Calling the cart API route directly also shows the correct unit_price.
However, using the nextjs-starter project, when i refresh the page, I suspect the priceStrategy service gets called and overrides the unit_price.
I tried implementing a custom priceStrategy to calculate the unit_price on the fly, but this service also calculates stuff for the product page. I also cannot inject the product and cart dependencies (cyclic dependency injection).
Any ideas? How can i tell the engine to not overwrite my unit_price with a variant?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, i'm trying to create a product with a single variant.
I created a custom service to calculate the price based on the selected height and width of the customer. When adding the item to the cart, i call a custom API route with the variant id, height and width, and add the cart item with the correct calculated unit_price.
I use generateLineItem for this and the cartService to add it. I can confirm through a simple db query that the unit_price has been set correctly.
Calling the cart API route directly also shows the correct unit_price.
However, using the nextjs-starter project, when i refresh the page, I suspect the priceStrategy service gets called and overrides the unit_price.
I tried implementing a custom priceStrategy to calculate the unit_price on the fly, but this service also calculates stuff for the product page. I also cannot inject the product and cart dependencies (cyclic dependency injection).
Any ideas? How can i tell the engine to not overwrite my unit_price with a variant?
Beta Was this translation helpful? Give feedback.
All reactions