Updating the price on the default Shopify Price theme block when the variant is changed
Show an updated price as customers switch between variants
<div id='prp__product-price'>
<span class='price product-single__price' id='price'>{{ product.selected_or_first_available_variant.price | money }}</span>
</div>
<script>
// Listen for the custom event to detect variant changes
document.addEventListener('prp::variant::changed', function (event) {
const variant = event.detail.variant;
if (variant && variant.priceFormatted) {
// Get the price element
const priceElement = document.querySelector('#prp__product-price .price');
if (priceElement) {
// Update the price with the new value
priceElement.innerHTML = variant.priceFormatted;
}
}
});
</script>PreviousBlocking Checkout Shipping/Pick-up options based on the option selected on the Product pageNextIncluding Rental Dates in your Shopify Order Confirmation Emails
Last updated