Abstract_WC_Order_Item_Type_Data_Store::read()
Read a order item from the database.
Method of the class: Abstract_WC_Order_Item_Type_Data_Store{}
No Hooks.
Return
null
. Nothing (null).
Usage
$Abstract_WC_Order_Item_Type_Data_Store = new Abstract_WC_Order_Item_Type_Data_Store(); $Abstract_WC_Order_Item_Type_Data_Store->read( $item );
- $item(WC_Order_Item) (required) (passed by reference — &)
- Order item object.
Changelog
Since 3.0.0 | Introduced. |
Abstract_WC_Order_Item_Type_Data_Store::read() Abstract WC Order Item Type Data Store::read code WC 9.4.2
public function read( &$item ) { global $wpdb; $item->set_defaults(); // Get from cache if available. $data = wp_cache_get( 'item-' . $item->get_id(), 'order-items' ); if ( false === $data ) { $data = $wpdb->get_row( $wpdb->prepare( "SELECT order_id, order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d LIMIT 1;", $item->get_id() ) ); wp_cache_set( 'item-' . $item->get_id(), $data, 'order-items' ); } if ( ! $data ) { throw new Exception( __( 'Invalid order item.', 'woocommerce' ) ); } $item->set_props( array( 'order_id' => $data->order_id, 'name' => $data->order_item_name, ) ); $item->read_meta_data(); }