次のカスタム チェックアウト フィールドを作成する 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 にコピーしたいと思います。このような:
請求先住所 1 = 請求先住所 + 請求先番号 + 請求先番号サフィックス
私は次の(初歩的な)コードでこれをやろうとしました:
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 変数がまったく渡されないと思いますか?
class-wc-checkout.php でフックを作成する方法は次のとおりです。
// Hook to allow modification of value
$this->posted[ $key ] = apply_filters( 'woocommerce_process_checkout_field_' . $key, $this->posted[$key] );