Updating product price if additional features selected

Nata
New Member
2 0 2

Hi guys, 

I added a custom option to the product, and, if chosen, the price on the page is updated. However this price change does not reflect in the cart. Could anyone help figure out what the issue is and how to fix it?

Here are the relevant code snippets:
 


<span class="product-price" itemprop="price" id="price">{{ variant.price | money }}</span>

<select class="product-variants custom" id="custom" name="custom">
           <option data-price="0" value="0">None</option>
    <option data-price="40.00" value="+1.50">+1.50</option>
     <option data-price="40.00" value="+2.00">+2.00</option>                   
    <option data-price="40.00" value="+2.50">+2.50</option>
</select>
                      
var basePrice = +($('#price').html().match(/\d+\.\d+/)[0]);

$(".custom").change(function() {
  newPrice = basePrice;
  $(".custom option:selected").each(function() {
    newPrice += +$(this).attr('data-price');
  });

  $("#price").html('$' + newPrice.toFixed(2));
 


Any help or advice is much appreciated!
~N.

Jason
Shopify Expert
10354 155 1990

For the price to be reflected in the cart you must either:

  • add a variant of that amount.
  • add an additional product to the cart to cover the difference

Any reason why you're not using built in variants for this?

What led you to think that updating the price in the html would change the price of the variant. If that worked, customers could change the html shown to just be 0 and get everything for free.

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.


★ http://freakdesign.com.au ★
0 Likes
Nata
New Member
2 0 2

Thanks for your response, Jason.

"What led you to think that updating the price in the html would change the price of the variant."

Nothing did. Yet it seemed like it is logical to START with the HTML change to achieve the desired result. I apologize if this logic is flawed. Not sure what led you to think I would be posting here if I knew exactly how to make the change I need...

"Any reason why you're not using built in variants for this?"

There is. I need to add customized options to about 150 product, which will be made ONLY IF customers order. They are not in the general inventory and I don't want/need to SKU them as variants. Hope you understand the logic here.

Is adding an additional product is the only option then? Please advise if you have further suggestions.

~N.

Tawny_Reynolds
Tourist
4 0 2

I would also love to know how to do this.  Managing variants gets really arduous when I have every necklace in 10 colors and 3 chain lengths.  I've been wanting to add other earring options (hooks, posts, clip-ons) for ages, but the data entry is really putting me off.  It also actually makes it impossible for me to track inventory - I assemble all items at the time of order, so an 18" pendant and 20" pendant are not coming from different inventory, just with a different "add-on" (chain length).

hzlvn
New Member
2 0 1

Were you able to figure out how to do this? I'm having the same dilemma :<

Sahib1
Tourist
6 0 2

@KetanKumar Sir, Can you please help me with this.

I have 3 variants and some additional options, and want to change the price when person selects that additional option which is Grip in my case.

Please have a look to that page here -> https://rxnu2ckwli47upn2-56207114416.shopifypreview.com/products/graphite-design-mad-pro

Thank you in advance

KetanKumar
Shopify Partner
18849 1978 6981

@Sahib1 

sorry for this issue shopify allow only shopify admin variant change condition addition doesn't work please  add main variant grip then check

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help
Shopify Expert | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing
Sahib1
Tourist
6 0 2

@KetanKumar Thank you for getting back Sir, 

I already have three variants, so it will not allow me to have more. 

To solve that, I coded those additional options by creating a new product template but now I am trying to add the option [Grip] price on the top of variant price via coding and reflect it in the cart which will be now product price + grip price

Here is an example I saw on one of the store -> https://www.txgstore.com/products/callaway-big-bertha-b21-driver-custom-driver-head-callway-driver-h...

In the above store, when I try to build the full product, it adds the price of custom option on the top of variant price.

Can you please guide me to how can I achieve that?

 

KetanKumar
Shopify Partner
18849 1978 6981

@Sahib1 

sorry for your last one shopify is limited customization admin doesn't allow to custom price 

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help
Shopify Expert | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing
0 Likes