To achieve what you want you’re better creating an associative array and then walking over it with a foreach
loop as shown below :
$data = array(
'_shipping_first_name' => $order->get_billing_first_name(),
'_shipping_last_name' => $order->get_billing_last_name(),
'_shipping_company' => $order->get_billing_company(),
'_shipping_address_1' => $order->get_billing_address_1(),
'_shipping_address_2' => $order->get_billing_address_2(),
'_shipping_postcode' => $order->get_billing_postcode(),
'_shipping_city' => $order->get_billing_city(),
'_shipping_state' => $order->get_billing_state(),
'_shipping_country' => $order->get_billing_country()
);
foreach ( $data as $meta_key => $meta_value ) {
update_post_meta( $order_id, $meta_key, $meta_value );
}
Related Posts:
- Woocommerce get selected shipping zone id for the current user
- Query WooCommerce orders grouped by several order statuses
- How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- Automatically check the option “Enable stock management at product level” on product creation
- How to show order data by multiple ID?
- Problem with Woocommerce REST API Authentication
- Remove General Tab and Plugin Tab in Settings in Woocommerce
- WooCommerce – Display variation custom field value [closed]
- Woocommerce HTML email option unavailable
- How to add SVG icon above product tab title
- How to change / delete product short description in Woocommerce
- How to trash multiple post/product programmatically
- OrderItem get_total() returns lower value than $order_item->get_product()->get_price() * quantity
- Change the URL of an image from wp_get_attachment_image_src except in the frontpage
- Setting up 2 SMTP accounts: 1 for wordpress and 1 for woocommerce
- WooCommerce – Reset quantity input field when variation changes
- Custom Text in WooCommerce Order Processing Email Based on Products
- woocommerce subscriptions – get expiration date [closed]
- Automatically remove a canceled order in Woocommerce
- How can I apply_filters from inside a function?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Different Minimum Order Amounts based on Shipping Zone [closed]
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Displaying Woocommerce Product Category in WordPress
- Displaying custom taxonomy on WooCommerce product page
- Change “add to cart” button color based on Woocommerce product category [closed]
- Add to cart function not working for first product when cart is empty [closed]
- Woocommerce : Can’t get product info in loop
- WooCommerce custom product dimensions
- Is there a way to hook or call a custom woocomerce template that is not part of the default templates of woocommerce?
- get taxonomy thumbnail and use it as a variable in code
- Single Quotes in .php file doesn’t load website
- get_total () returns 0 – woocommerce [closed]
- email alert for product availability
- How to rename woocommerce-billing-fields
- WooCommerce pages looks unstyled
- Disable if there are no children – Woocommerce
- Create a package of products as one Item in woocommerce?
- fetch woocommerce product with custom taxonomy
- After disabling WPML multi currency, the currency is still handled by the WPML
- How can i programmatically change the SKU of a product based on product variation?
- Execute PHP code only with specific user role
- Add a custom WooCommerce settings tab with sections
- Checking page before applying image restrictions while uploading
- How to sort WooCommerce products page by latest in-stock items first?
- WP_Query for woocommerce products with a pattern as a post_title
- WordPress Fresh Install Errors (Woocommerce specifically now)
- Generate images with html2canvas and the woocommerce api
- Woocommerce – Exclude variation attribute on specific variation
- Get WooCommerce products with similar SKU
- PHP function for horizontal Woocommerce thumbnails and badges
- Use CSS tag inside PHP code
- Set ACF on order during checkout
- Hide payment method based on user role AND minimum cart value
- WooCommerce display price before add to cart [closed]
- Get the same SKU from woocommerce itself for simple and variable products
- Woocommerce checkout page – custom field checkbox value into email
- WooCommerce function not working correctly after moving from the functions.php into a class
- Filter for product subcategory listing page load
- Reduce Stock Based on Custom Variation Field Rather than Attribute (Working Script)
- Set notification if is two product category in cart
- WooCommerce – template_redirect if is_checkout AND order has been paid?
- AJAX to add to cart multiple products woocommerce
- Make WooCommerce product categories only show images on homepage
- ACF under category name in shop page [closed]
- WooCommerce Quantity in Dropdown menu instead of clasic [closed]
- WP_Query To Display Product Of Brand On Taxonomy Page
- Reverse Cross-Sells (WooCommerce)
- Hot to edit WooCOmmerce dashboard?
- WooCommerce subcategories help
- WooCommerce multiple custom fields code
- Search function not working
- loop to return tags in woocommerce in alphabetical order?
- How to have more than one ID included in the exclude command?
- I was wondering if it’s possible to implement card.js on WordPress
- wp_query beginner
- Woocommerce custom field on emails outputs ‘Array’
- WordPress using get_term to retreive slug not working as expected
- Can’t make product images clickable
- WooCommerce – Print Processing orders [closed]
- Hide cart when empty [closed]
- WooCommerce Custom Pagination
- Order woo products, but first products must be with acf fields
- Warning: Attempt to read property “term_id” on int – Woocommerce
- Show button in header when product custom field is not empty
- WordPress 6.1.1 UTF8 Slug Limit Increase
- How call WordPress shortcode inside function file
- Woocommerce Convert existing order to the cart
- strict custom php script on specific product category [closed]
- How to change shipping method title based on cart amount?
- How to add SKU and remove product title from WooCommerce url?
- Product Search in search.php
- using custom pages for myaccount in woocommerce
- PHP Add products to cart with WooCommerce Addons
- Woocommerce, via php snippet: How to get product price and divide it by a number from an attribute, and then display the new price via php/html?
- “Joined in” or “Member since” displayed on single store page and then using shortcode to add
- How to do SEO friendly filters urls?
- WooCommerce coupon codes in order overview HPOS
- Woocommerce target first product thumbnail in loop to load a larger image