これに対する簡単な答えはおそらく誰かが私を助けてくれるでしょうが、私はJavascriptがあまり得意ではありません。基本的にShopifyでは、液体タグの1つで+ 20%表示されるように価格を設定しました。サイズが在庫切れの場合にカートに追加ボタンを無効にし、価格も在庫切れに変更するJavascriptが少しあるため、これは製品ページとは別にうまく機能します。とにかくここにコードがあります:
<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
}
};
商品リストのページで、次の液体タグを使用して価格を20%追加できます
{{ product.price_min | times:1.20 | money }}
私がする必要があるのは、Javascriptを変更して、出力される価格に1.20を掛けるだけです。誰かがこれを行う方法を知っていますか?ありがとう。