最後我達到了解決方案。
我已經設置爲運送方式(店內取貨&本地配送)。並隱藏未經檢查的運輸方式。一旦客戶改變了該選項(點擊自定義單選按鈕)即Pickup Radio Button &發送單選按鈕。在皮卡單選按鈕檢查我設置商店皮卡運輸方法檢查和觸發運行阿賈克斯和更新購物車總計&運費金額的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 >>形狀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>
<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>