Hello,
I have a B2B site and I display product priced ex.Vat as well as with VAT so the customer can view both by toggling between classes.
When the page loads the displays
when toggled the second price which is initially hidden is then displayed and hides the first price.
Below I have added this code to the product-price snippet within the empire theme.
It works for a product without variants.
However when a product has variants the price will display correctly for whatever variant it selected, but the toggled ex.Vat price only shows the original variants price for all the variants no matter which one is selected.
Does anyone know how I can write within the to select the current variant. Every combination I try to write within the {{ price | divided_by : 1.2 | money }} comes back as either 0.00 or still displays the original variants price only. Its seems I can’t apply a calculation to a variant price.
<div class="price__current {% if emphasize_price %}price__current--emphasize{% endif %} {% if on_sale %}price__current--on-sale{% endif %}" data-price-container>
{%- capture price_html -%}
<div class="price-container label">
<!-- Display the first price -->
<span class="inc-vat-price" data-price>{{ price | money }} {{ product.metafields.sold-by-the.volume }}</span>
<!-- Display the second price, initially hidden -->
<span class="ex-vat-price"><span class="smaller">Ex.VAT</span>{{ price | divided_by : 1.2 | money }} {{ product.metafields.sold-by-the.volume }}</span>
</div>
{%- endcapture -%}
Within the Js file is the data-price details put can’t see anyway this will help
this.variantFields = {
$priceContainer: this.$details.find('[data-price-container]'),
$priceMoney: this.$details.find('[data-price-container] [data-price]'),
$compareAtPrice: this.$details.find('[data-price-compare-container]'),
$compareAtPriceMoney: this.$details.find('[data-price-compare-container] [data-price-compare]'),
$badge: this.$details.find('[data-badge-sales]'),
$badgeRange: this.$details.find('[data-badge-sales-range]'),
$badgeSingle: this.$details.find('[data-badge-sales-single]'),
$sku: this.$details.find('[data-product-sku]'),
stockLevels: this.$details[0].querySelectorAll('[data-stock-level]'),
unitPrice: this.$details[0].querySelector('[data-unit-price]'),
totalQuantity: this.$details[0].querySelector('[data-total-quantity]'),
unitPriceAmount: this.$details[0].querySelector('[data-unit-price-amount]'),
unitPriceMeasure: this.$details[0].querySelector('[data-unit-price-measure]'),
taxLine: this.$details[0].querySelector('[data-tax-line]'),
hiddenComparePrice: this.$details[0].querySelector('[data-compare-price-hidden]'),
hiddenCurrentPrice: this.$details[0].querySelector('[data-current-price-hidden]'),
hiddenComparePriceRange: this.$details[0].querySelector('[data-compare-price-range-hidden]'),
hiddenCurrentPriceRange: this.$details[0].querySelector('[data-current-price-range-hidden]')
};
Thanks