我寫了創建以下的自定義結賬字段woocommerce插件:複製定製woocommerce領域爲默認字段
billing_street_name
billing_house_number
billing_house_number_suffix
shipping_street_name
shipping_house_number
shipping_house_number_suffix
我也添加到了後臺管理頁面,但因爲我不能掛接到get_formatted_billing_address & get_formatted_shipping_address(其均用於顯示writepanel-order_data.php和shop_order.php地址)我想將它們複製到默認這樣billing_address_1 & shipping_address_1:
billing_address_1 = billing_street_name + billing_house_number + b illing_house_number_suffix
我試着用以下的(初步)代碼來做到這一點:
add_action('woocommerce_process_checkout_field_billing_address_1', array(&$this, 'combine_street_number_suffix'));
public function combine_street_number_suffix() {
$key = $_POST['billing_street_name'] . ' ' . $_POST['billing_house_number'];
return $key;
}
,但不工作 - 我不認爲$ _ POST變量被都傳遞?
這裏的鉤子是如何在課堂上-WC-checkout.php創建:
// Hook to allow modification of value
$this->posted[ $key ] = apply_filters('woocommerce_process_checkout_field_' . $key, $this->posted[$key]);