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 在购物车页面上收取运费的主要内容,如果未能解决你的问题,请参考以下文章

从 WooCommerce 中的订单总额中删除运费总额

Magento 1.4 - PayPal Payments Standard 有时不收取运费

PP REST API 收取税费和运费而无需发送地址?

如何将运费从购物车发送到贝宝 [关闭]

在购物车和结帐时将运费金额向右移动

使用 cURL 计算 Paypal Express Checkout 运费