0
我想使billing_last_name
不需要,如果選擇本地取貨。必填結帳字段根據送貨方式 - Woocommerce
嘗試這樣的事:
function xa_remove_billing_checkout_fields($fields) {
$shipping_method ='local_pickup'; // Set the desired shipping method to hide the checkout field(s).
global $woocommerce;
$chosen_methods = WC()->session->get('chosen_shipping_methods');
$chosen_shipping = $chosen_methods[0];
if ($chosen_shipping == $shipping_method) {
$fields['billing']['billing_last_name'][ 'required' ] = false;
}
return $fields;
}
但它不工作。
有沒有合適的解決方案?
這應該正常工作。請讓我們看看鉤子。你到哪裏去了? –
哦,我認爲這是問題,我沒有寫鉤子。我應該怎麼做? –
我已經爲您提供了答案,請參閱第一行(add_filter)。 –