html 在购物车页面上收取运费
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 在购物车页面上收取运费相关的知识,希望对你有一定的参考价值。
<script>
Shopify.Cart = Shopify.Cart || {};
Shopify.Cart.DeliveryCharge = {};
Shopify.Cart.DeliveryCharge.set = function(data) {
jQuery.ajax({
type: 'POST',
url: '/cart/update.js',
data: data,
dataType: 'json',
success: function() { location.href = '/cart'; }
});
};
Shopify.Cart.DeliveryCharge.product = {{ linklists.delivery-charge.links.first.object | to_json }};
$('#select-first-two-digits-of-your-postal-code-delivery-charge').change(function() {
var data = {};
switch( $(this).find('option:selected').index() ) {
case 0:
Shopify.Cart.DeliveryCharge.set( {
updates: {
Shopify.Cart.DeliveryCharge.product.variants[0].id: 1,
Shopify.Cart.DeliveryCharge.product.variants[1].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[2].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[3].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[4].id: 0
}, attributes: {
select-first-two-digits-of-your-postal-code-delivery-charge: '01-$5.00'
}
} );
break;
case 1:
Shopify.Cart.DeliveryCharge.set( {
updates: {
Shopify.Cart.DeliveryCharge.product.variants[0].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[1].id: 1,
Shopify.Cart.DeliveryCharge.product.variants[2].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[3].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[4].id: 0
}, attributes: {
select-first-two-digits-of-your-postal-code-delivery-charge: '02-$8.00'
}
} );
break;
case 2:
Shopify.Cart.DeliveryCharge.set( {
updates: {
Shopify.Cart.DeliveryCharge.product.variants[0].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[1].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[2].id: 1,
Shopify.Cart.DeliveryCharge.product.variants[3].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[4].id: 0
}, attributes: {
select-first-two-digits-of-your-postal-code-delivery-charge: '03-$10.00'
}
} );
break;
case 3:
Shopify.Cart.DeliveryCharge.set( {
updates: {
Shopify.Cart.DeliveryCharge.product.variants[0].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[1].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[2].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[3].id: 1,
Shopify.Cart.DeliveryCharge.product.variants[4].id: 0
}, attributes: {
select-first-two-digits-of-your-postal-code-delivery-charge: '30-39 $5.00'
}
} );
break;
case 4:
Shopify.Cart.DeliveryCharge.set( {
updates: {
Shopify.Cart.DeliveryCharge.product.variants[0].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[1].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[2].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[3].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[4].id: 1
}, attributes: {
select-first-two-digits-of-your-postal-code-delivery-charge: '41-49 $3.00'
}
} );
break;
default:
Shopify.Cart.DeliveryCharge.set( {
updates: {
Shopify.Cart.DeliveryCharge.product.variants[0].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[1].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[2].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[3].id: 0,
Shopify.Cart.DeliveryCharge.product.variants[4].id: 0
}, attributes: {
select-first-two-digits-of-your-postal-code-delivery-charge: ''
}
} );
}
});
</script>
以上是关于html 在购物车页面上收取运费的主要内容,如果未能解决你的问题,请参考以下文章