首页 文章

Woocommerce在结帐页面上删除运费

提问于
浏览
0

在我的项目中,结帐页面上有2个单选按钮,其中包含选项:Pickup Radio ButtonShipping Radio Button .

当用户选择Pickup选项时 . 然后,它显示拾取位置(存储在自定义表中) . 当用户选择船舶选项时 . 它显示了woocommerce“运送到不同的地址?”选项 .

现在,如果用户选择“提取”,我想通过AJAX删除运费吗?选项 . 如果用户选择“发货”,则重新添加运费?选项 .

请帮帮我 .

1 回答

  • 1

    最后我达成了解决方案 .

    我已经开始发货方式(商店皮卡和本地送货) . 并隐藏未经检查的送货方式 . 一旦客户更改了选项(点击自定义单选按钮),即选择单选按钮和运输单选按钮 . 在Pickup单选按钮上选中我正在设置商店取货运送方法以检查并触发运行ajax的jquery功能并更新购物车总额和运费金额 . 另一方面,我隐藏了本地送货方式单选按钮 . 同样的事情正在发生,反之亦然 .

    style.css文件

    .woocommerce ul#shipping_method li input {
       position: absolute; left: -25px; 
    }
     .woocommerce ul#shipping_method li {
      margin: 0; overflow: hidden; padding: 0; position: relative;
      text-indent: 0; display: none; 
    } 
    .woocommerce.pickup ul#shipping_method li:first-child {
      display: block;
     } 
    .woocommerce.ship ul#shipping_method li:last-child {
      display: block;
    }
    

    jQuery的

    $('[name="order_type"]').on("change",function(){
       /* Pickup Radio Button / Shipping Radio Button ?*/
        showHideOrderTypeOptions();
    });
    function showHideOrderTypeOptions()
    {
      var order_type = $('[name="order_type"]:checked').val();
      if(order_type == "Ship")
      {
          $(".shipping_address, #ship-to-different-address").show();
          $(".store-locations-wrapper").hide();
          $("#store_address_id").val("");
          $("#ship-to-different-address-checkbox").attr("checked",true);
          $('[name="store_address"]').attr("checked",false);
          $(".woocommerce").removeClass('pickup').addClass("ship");
          $("#shipping_method li").eq(1).find("input").trigger("click");
      }
      else
      {
          $(".shipping_address, #ship-to-different-address").hide();
          $(".store-locations-wrapper").show();
          $("#ship-to-different-address-checkbox").attr("checked",false);
          $(".woocommerce").removeClass('ship').addClass("pickup");
          $("#shipping_method li").eq(0).find("input").trigger("click");
      }
    

    }

    woocommerce >> form-billing.php

    <div class="order-type-wrapper">
        <h3>Order Type - </h3>
        <input id="order-type-pickup" class="input-radio" <?php checked( $order_type, 'Pickup' ); ?> type="radio" name="order_type" value="Pickup" />
        <label for="order-type-pickup" class="radio"><?php _e( 'Pick up?', 'woocommerce' ); ?></label>
    
        &nbsp;
        <input id="order-type-ship" class="input-radio" <?php checked( $order_type, 'Ship' ); ?> type="radio" name="order_type" value="Ship" />
        <label for="order-type-ship" class="radio"><?php _e( 'Ship?', 'woocommerce' ); ?></label>
    </div>
    <div class="store-locations-wrapper">
        <input type="hidden" id="store_address_id" name="store_address_id" value="<?php echo $store_address_id; ?>" />
        <h3>Pickup Location</h3>
      Store locations goes here.
    </div>
    

相关问题