WooCommerce: get and set shipping & billing address's postcode
How do I set/get the Postcode(Zip-code) in woocommerce? Is there a function for this? ie., can I set the zip code through any function? I would also like to know, how to populate this field with my data(say 546621) if the user is not logged in? You can do the following to get/set billing/shipping postcodes, To set the values, $customer = new WC_Customer(); $customer->set_postcode('123456'); //for setting billing postcode $customer->set_shipping_postcode('123456'); //for setting shipping postcode If you just want to fetch the postcodes, you can fetch it from the user meta table itself,