Answer the question
In order to leave comments, you need to log in
Bitrix. How to update the price when choosing a size?
The product has a certain number of sizes, a price is attached to each size.
I need to make sure that when choosing a size, the price changes depending on what price is set for this size. I was able to display the sizes, but how to update the price
? :
<select class="input-select" >
<?foreach($arResult['SIZES'] as $id => $size):?>
<option value="<?=$id?>"><?=$size?></option>
<?endforeach;?>
</select>
Answer the question
In order to leave comments, you need to log in
hang an on-change event on your select. Next, I change the value of the element with the price to the desired one, depending on the selected size
<select onchange="showPrice(this);" class="input-select" >
<?foreach($arResult['SIZES'] as $id => $size):?>
<option value="<?=$id?>" data-price><?=$size?></option>
<?endforeach;?>
</select>
function showPrice(e) {
$('.total_cost').html(e.options[e.selectedIndex].getAttribute('data-price'));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question