Abstract_WC_Order_Data_Store_CPT::set_order_props()
Set the properties of an object and log the first error found while doing so.
Method of the class: Abstract_WC_Order_Data_Store_CPT{}
No Hooks.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->set_order_props( $order, $props );
- $order (required) (passed by reference — &)
- -
- $props(array) (required)
- The properties to set.
Abstract_WC_Order_Data_Store_CPT::set_order_props() Abstract WC Order Data Store CPT::set order props code WC 9.4.2
private function set_order_props( &$order, array $props ) { $errors = $order->set_props( $props ); if ( ! $errors instanceof WP_Error ) { return; } $order_id = $order->get_id(); $logger = WC()->call_function( 'wc_get_logger' ); foreach ( $errors->get_error_codes() as $error_code ) { $property_name = $errors->get_error_data( $error_code )['property_name'] ?? ''; $error_message = $errors->get_error_message( $error_code ); $logger->warning( sprintf( /* translators: %1$s = order ID, %2$s = order id, %3$s = error message. */ __( 'Error when setting property \'%1$s\' for order %2$d: %3$s', 'woocommerce' ), $property_name, $order_id, $error_message ), array( 'error_code' => $error_code, 'error_message' => $error_message, 'order_id' => $order_id, 'property_name' => $property_name, ) ); } }