2
通過Javascript添加20%到產品價格可能有一個簡單的答案,有人可以幫助我,但我並不擅長Javascript。基本上在Shopify中,我已經設置了一個液體標籤顯示的價格+ 20%。除了產品頁面之外,這很有效,因爲有一點Javascript會禁用添加到購物車按鈕,如果尺寸缺貨並將價格更改爲缺貨。反正這裏是代碼:Shopify
<script>
var selectCallback = function(variant, selector) {
if (variant && variant.available) {
// valid variant selected
$('#add-to-cart').removeClass('disabled').removeAttr('disabled').val('Add to Cart'); // remove unavailable class from add-to-cart button, and re-enable button
if (variant.compare_at_price == 0){
$('.product-title .price').html(''+Shopify.formatMoney(variant.price, "{{shop.money_format}}")+' Excluding VAT');
} else {
$('.product-title .price').html('<span>'+Shopify.formatMoney(variant.price, "{{shop.money_format}}") + '</span> <del>' + Shopify.formatMoney(variant.compare_at_price, "{{shop.money_format}}") + ' Excluding VAT</del>');
}
} else {
// variant doesn't exist
$('#add-to-cart').addClass('disabled').attr('disabled', 'disabled').val('Sold Out'); // set add-to-cart button to unavailable class and disable button
var message = variant ? "Sold Out" : "Unavailable";
$('.product-title .price').text(message); // update price-field message
}
};
在產品列表頁面,我可以用下面的液體標籤
{{ product.price_min | times:1.20 | money }}
所有我需要做的就是修改JavaScript加20%的價格所以它輸出的價格乘以1.20。有誰知道一種方法來做到這一點?謝謝。
作品的魅力。非常感謝! – Bantros
然後請標記爲答案:) – iJade
我會,我必須等待8分鐘:) – Bantros