Я написал плагин для 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_streetname + billing_house_number + billing_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 вообще передается?
вот как создается хук в class-wc-checkout.php:
// Hook to allow modification of value
$this->posted[ $key ] = apply_filters( 'woocommerce_process_checkout_field_' . $key, $this->posted[$key] );