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:
- How to automatically apply woocommerce product title to all product images alt tags?
- How to have a custom display for both woocommerce archive and product-category pages? [closed]
- WP_Query | Help me create a search term with an ‘OR’ relation?
- The values of custom fields are not available functions.php
- Use wc_enqueue_js only on specific pages – nested add_action
- Replace existing content from specific WooCommerce admin orders list column
- Woocommerce – How to get products which have a sale between 20% to 40%? [closed]
- Woocommerce filter cart and category specific quantity [closed]
- Use is_product_category() properly
- How to get woocommerce cart content without an action?
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- Changing Woocommerce flat rate every nth number of items
- Woocommerce product download URL
- How to select WooCommerce products by post_meta and order them
- Limiting woocommerce line_total decimal length
- How can I use wp_query to show all product data using just the products ID?
- write custom woocommerce templates and forms
- Get stock by custom meta field on all Woocommerce variable products
- Set a condition based on WooCommerce checkout city field while placing order
- Call global variable array() in woocommerce child/template
- Remove price from Woocommerce variable product dropdown menu
- Issue adding sub category programmatically
- Get and insert order email address to the PHP template inside HTML text
- If no products are on sale – hide ID or class
- do search in two site and show the result in first site
- Which field should I edit to make the checkbox marked by default?
- How can I pass a custom/dynamic product to the Woocommerce cart?
- How to get private property in parent class into extended class?
- Replace Woocommerce “add to cart” to be “Download” button [closed]
- Woocommerce Email attachments not working – file not being attached
- Add post with approval by the admin
- Woocommerce display one random product via php
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- Seo Friendly Filter URLs
- customize woocommerce templates and display store on home
- WC_Customer delete function returns error
- Display attribute on shop page after the title
- CSS change in woo commerce Place Order Text [closed]
- WooCommerce – Moving Product Price to the Left of Add to Cart Button [closed]
- Exclude product attributes from taxonomy terms loop
- WP All Import / Update stock quantity from multiple XML files
- Woocommerce: remove total sum from new order’s email [closed]
- WordPress WP_Query without query GET parameters
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- Alter Woocommerce product archive structure
- Have Woocommerce show product price if id, when not logged in
- custom post type with role Vendor
- WooCommerce: Display product categories to make IF statement
- Modify WooCommerce used to get all orders in dashboard
- Replace category title with category description in woocommerce
- Add Custom Category Description When Empty
- I am having issue in divi woocomerce checkout module. (DIVI theme)
- Add a product category to a specific product via a button
- Woocommerce display orders with products from specific categories to specific admins
- Display div if category has a specific parent
- global $product is empty string when passed into function
- Run a sql (update) after 12 hours after the user login. Woocommerce users
- Use PHP Class in WordPress functions
- Use Search Term in html link and redirect
- Don’t update modified post date when user add a product review or comment?
- How do I change the “login” label in My Account page to “Registered Customer”
- Customize the “Available for back order” text for specific variation
- How to remove the replace the product image by video on shop page conditionally
- How to get content on a blank basket/cart page in a custom theme with woocommerce
- get_filtered_term_product_counts – Get product terms if any products
- How to import woocommerce custom fields data into another site?
- How to add custom attribute to all outofstock and all instock products automatically?
- Site infected by link
- Woocommerce – if selected attribute term equals
- split 1 cart item into instock and back ordered
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- Add Product Permalink in woocommerce admin order page
- sessionStorage saves input value in browser but it is not loaded in the form field
- Adding a widget under an ‘Add to Cart’ button through a PHP snippet
- Woocommerce Related Product by 2 taxonomy
- WooCommerce – Add Shipping class below each product in Shopping Cart page
- Hide price excluding tax when price is empty
- WooCommerce Custom Tab with ACF Repeater Field
- Woocommerce variation with radio button + price
- Display text of price (minus 20%) on every product page in a sentence.
- Display product attributes for current product
- How to remove image on single product and get product to span page?
- Adding placeholder text field to woocommerce checkout [closed]
- Getting custom field data from cart page to checkout page in woocomerce [closed]
- Send a custom notification to customer on WooCommerce cancelled order status
- How to code bulk order form in wordpress
- FATAL ERROR , Sommerce Theme [closed]
- Woocommerce linking variations
- Custom field fetch error on woocommerce pdf invoice
- posts_clauses drop ACF get_field function
- 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