Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hey @riodeloja
I'll assume that the theme version is 4.10.3, if so, you can replace the theme.min.js.liquid file with the code provided on the link https://cdn.shopify.com/s/files/1/0278/3828/3836/files/installmentJS.txt?v=1680540697.
The variant price is divided by 12 and adds 20.44%.
If you need to change the rate, with the file opened, press CTRL + F and search for the value 1.2044. Change the highlighted value to the updated rate.
On the product-template file from the snippets folder, add the following HTML before the last div of the capture produce_price.
<span id="InstallmentPrice">
ou em até 12x de <span class="product-installment__price"> <span class="money">{{ price | divided_by: 12 | times: 1.2044 | round:2 | money }} </span></span>
</span>
The installment price will update when changing the variant selected.
is there a way to do this in dawn theme ??
i have tried to implement similar code to display installments under the price, but it is not working when different variant with different price is selected, i mean, it doesnt update the installment calculation
<div id="installments-info">
<!-- Initial installment information -->
{% assign initialVariant = product.selected_or_first_available_variant %}
{% assign initialVariantPrice = initialVariant.price %}
{% assign initialInstallments = initialVariantPrice | divided_by: 12 %}
12 meses de {{ initialInstallments | money }}
</div>
<script>
// Function to update installment information based on selected variant
function updateInstallmentsInfo(variant) {
var variantPrice = variant.price;
var installments = variantPrice / 12;
var installmentsInfo = document.getElementById('installments-info');
installmentsInfo.innerHTML = '12 meses de ' + (installments).toFixed(2);
}
// Listen for variant selection event
document.addEventListener('variant:changed', function(event) {
var selectedVariant = event.detail.variant;
updateInstallmentsInfo(selectedVariant);
});
</script>
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024