Shopify 价格变化方程
Shopify price variation equation
我正在使用 Shopify Debut 主题,我想以某种方式将增值税 (7%) 添加到变体的价格中。
静态价格我可以开始工作,但是当更改具有不同价格的变体时,hQuery 会覆盖它,我不知道如何通过 jQuery.
更改它
这是来自 theme.js
的 jQuery 片段
/**
* Trigger event when variant price changes.
*
* @param {object} variant - Currently selected variant
* @return {event} variantPriceChange
*/
_updatePrice: function(variant) {
if (
variant.price === this.currentVariant.price &&
variant.compare_at_price === this.currentVariant.compare_at_price
) {
return;
}
this.$container.trigger({
type: 'variantPriceChange',
variant: variant
});
},
对于主题模板中的单一价格变化,我使用了这个有效但不适用于 jQuery 的片段。
{{ compare_at_price | times:1.07 | money }}
的完整源文件
与 liquid 相同,但在 JS 中,找到这些行:
// On sale
if (variant.compare_at_price > variant.price) {
$regularPrice.html(
theme.Currency.formatMoney(
variant.compare_at_price,
theme.moneyFormat
)
);
$salePrice.html(
theme.Currency.formatMoney(variant.price, theme.moneyFormat)
);
$priceContainer.addClass(this.classes.productOnSale);
} else {
// Regular price
$regularPrice.html(
theme.Currency.formatMoney(variant.price, theme.moneyFormat)
);
}
添加替换为:
// On sale
if (variant.compare_at_price > variant.price) {
$regularPrice.html(
theme.Currency.formatMoney(
variant.compare_at_price * 1.07,
theme.moneyFormat
)
);
$salePrice.html(
theme.Currency.formatMoney(variant.price * 1.07, theme.moneyFormat)
);
$priceContainer.addClass(this.classes.productOnSale);
} else {
// Regular price
$regularPrice.html(
theme.Currency.formatMoney(variant.price * 1.07, theme.moneyFormat)
);
}
我正在使用 Shopify Debut 主题,我想以某种方式将增值税 (7%) 添加到变体的价格中。
静态价格我可以开始工作,但是当更改具有不同价格的变体时,hQuery 会覆盖它,我不知道如何通过 jQuery.
更改它这是来自 theme.js
的 jQuery 片段/**
* Trigger event when variant price changes.
*
* @param {object} variant - Currently selected variant
* @return {event} variantPriceChange
*/
_updatePrice: function(variant) {
if (
variant.price === this.currentVariant.price &&
variant.compare_at_price === this.currentVariant.compare_at_price
) {
return;
}
this.$container.trigger({
type: 'variantPriceChange',
variant: variant
});
},
对于主题模板中的单一价格变化,我使用了这个有效但不适用于 jQuery 的片段。
{{ compare_at_price | times:1.07 | money }}
的完整源文件
与 liquid 相同,但在 JS 中,找到这些行:
// On sale
if (variant.compare_at_price > variant.price) {
$regularPrice.html(
theme.Currency.formatMoney(
variant.compare_at_price,
theme.moneyFormat
)
);
$salePrice.html(
theme.Currency.formatMoney(variant.price, theme.moneyFormat)
);
$priceContainer.addClass(this.classes.productOnSale);
} else {
// Regular price
$regularPrice.html(
theme.Currency.formatMoney(variant.price, theme.moneyFormat)
);
}
添加替换为:
// On sale
if (variant.compare_at_price > variant.price) {
$regularPrice.html(
theme.Currency.formatMoney(
variant.compare_at_price * 1.07,
theme.moneyFormat
)
);
$salePrice.html(
theme.Currency.formatMoney(variant.price * 1.07, theme.moneyFormat)
);
$priceContainer.addClass(this.classes.productOnSale);
} else {
// Regular price
$regularPrice.html(
theme.Currency.formatMoney(variant.price * 1.07, theme.moneyFormat)
);
}