Abstract_WC_Order_Data_Store_CPT::update_post_meta
Helper method that updates all the post meta for an order based on it's settings in the WC_Order class.
Метод класса: Abstract_WC_Order_Data_Store_CPT{}
Хуки из метода
Возвращает
null. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->update_post_meta( $order );
- $order(WC_Order) (обязательный) (передается по ссылке — &)
- Order object.
Список изменений
| С версии 3.0.0 | Введена. |
Код Abstract_WC_Order_Data_Store_CPT::update_post_meta() Abstract WC Order Data Store CPT::update post meta WC 10.4.2
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;
}
}
/**
* Action fired after updating order properties.
*
* @param WC_Abstract_Order $order Order object.
* @param string[] $updated_props Array of updated properties.
*
* @since 2.7.0
*/
do_action( 'woocommerce_order_object_updated_props', $order, $updated_props );
}