WordPress Codesnippets

woocommerce get customer address

				
					
				
			

customer_id, ‘billing_postcode’, true ),
‘country’ => get_user_meta( $customer_id, ‘billing_country’, true )
);

This code retrieves the billing address details for a WordPress user by extracting the address information from the user meta. The first line of code assigns the current user’s ID to the variable ‘$customer_id’. Then, an array is created that contains the billing address fields such as first and last name, company, address 1 and 2, city, state, postcode, and country. The details are extracted from the user meta corresponding to the customer’s ID.

Was this code snippet helpful?
YesNo

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmatically save post

This code creates a WordPress post with the values of the ‘post_title’ and ‘post_content’ variables. It sets the post status to ‘publish’ and the author

Read More »

Create order programmatically

This code creates a new post in the WordPress database with post type ‘shop_order’, post title ‘Order #12345’, post status ‘wc-processing’, and ping status ‘closed’.

Read More »