I am trying to pre-generate the WooCommerce shipping address with customer data. It's working for all areas except shipping_postcode Any ideas what I'm doing wrong?
// add_filter hook ('woocommerce_checkout_fields', 'custom_override_checkout_fields'); // Inclined in our function - $ field passes through the filter! Function custom_override_checkout_fields ($ field) {$ customer_id = get_current_user_id (); $ Field ['shipping'] ['shipping_first_name'] ['default'] = gate_user_mata ($ customer_id, $ name 'shipping_first_name' is true); $ Field ['shipping'] ['shipping_last_name'] ['default'] = get_user_meta ($ client_ id, $ name. 'Shipping_last_name' is true); $ Field ['shipping'] ['shipping_company'] ['default'] = get_user_meta ($ client_id, $ name. 'Shipping_company', is true); $ Field ['shipping'] ['shipping_add_1'] ['default'] = get_user_meta ($ client_ id, $ name. 'Shipping_address_1', is true); $ Field ['shipping'] ['shipping_ address_2'] ['default'] = gate_asser_mata ($ client_ id, $ name. 'Shipping_address_2', true); $ Field ['shipping'] ['shipping,'] ['default'] = get_user_meta ($ customer_id, $ name. 'Shipping_city' is true); $ Field ['shipping'] ['shipping_postcode'] ['default'] = meets _merica ($ customer_id, $ name 'shipping_postcode' is true); $ Field ['shipping'] ['shipping_country'] ['default'] = gate_asser_mata ($ customer_id, $ name 'shipping_creative', true); $ Field ['shipping'] ['shipping_state'] ['default'] = million_ager_amata ($ customer_id, $ name is 'shipping_state', true); Return $ field; }
I have also tried to do a simple task with any luck:
$ fields ['shipping'] ['shipping_postcode'] [ 'Default'] = "90210";
We have found an alternative solution for this.
This line does not work for any reason:
$ fields ['shipping'] ['shipping_postcode'] ['default'] = get_user_meta ($ customer_id, $ Name is 'shipping_postcode', true);
But this code completes what we want:
$ woocommerce-> Customer- & gt; Set_shipping_postcode (get_user_meta ($ customer_id, $ name. Shipping_postcode ', true));
Comments
Post a Comment