Abstract_WC_Order_Data_Store_CPT::update_post_meta( WC_Order $order )
Helper method that updates all the post meta for an order based on it’s settings in the WC_Order class.
Description Description
Parameters Parameters
- $order
-
(Required) Order object.
Source Source
File: includes/data-stores/abstract-wc-order-data-store-cpt.php
protected function update_post_meta( &$order ) { $updated_props = array(); $meta_key_to_props = array( '_order_currency' => 'currency', '_cart_discount' => 'discount_total', '_cart_discount_tax' => 'discount_tax', '_order_shipping' => 'shipping_total', '_order_shipping_tax' => 'shipping_tax', '_order_tax' => 'cart_tax', '_order_total' => 'total', '_order_version' => 'version', '_prices_include_tax' => 'prices_include_tax', ); $props_to_update = $this->get_props_to_update( $order, $meta_key_to_props ); foreach ( $props_to_update as $meta_key => $prop ) { $value = $order->{"get_$prop"}( 'edit' ); $value = is_string( $value ) ? wp_slash( $value ) : $value; if ( 'prices_include_tax' === $prop ) { $value = $value ? 'yes' : 'no'; } $updated = $this->update_or_delete_post_meta( $order, $meta_key, $value ); if ( $updated ) { $updated_props[] = $prop; } } do_action( 'woocommerce_order_object_updated_props', $order, $updated_props ); }
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |