Marko Krizan
Marko Krizan

Reputation: 83

How do i add product option or a variant that increments the price - shopify?

I'm creating a custom feature on a Shopify theme and I need to add product options or variants that each increment a price by a certain amount.

For example, if I want to have wrapping on a product, that costs 10$ extra. I don't want to create a "wrapped" variant that costs product price + 10$, I want it to be dynamically calculated because I will be adding multiple such choices.

I then need to add the product to the cart via the Shopify AJAX API, so I will be needing to specify such added options in the request body somehow and have Shopify calculate the final price.

How would I go about doing this?

Upvotes: 0

Views: 1633

Answers (1)

drip
drip

Reputation: 12933

Prices in Shopify are attached to variants.

To say it simply you can't modify the price of a variant in any way. The price is set on creation of the variant and you can't modify the variant price from the front-end.

If you plan to modify the price based on the user input you need to create predefined variants for each option and change the selected variant based on the user input.

If you still want real dynamic price you will need to look for some kind of an App that will support this functionality.

Upvotes: 0

Related Questions