| @@ 377-403 (lines=27) @@ | ||
| 374 | /** |
|
| 375 | * Read Meta Data from the database. Ignore any internal properties. |
|
| 376 | */ |
|
| 377 | protected function read_meta_data() { |
|
| 378 | $this->_meta_data = array(); |
|
| 379 | ||
| 380 | if ( ! $this->get_id() ) { |
|
| 381 | return; |
|
| 382 | } |
|
| 383 | ||
| 384 | $cache_key = WC_Cache_Helper::get_cache_prefix( 'order_meta' ) . $this->get_id(); |
|
| 385 | $cached_meta = wp_cache_get( $cache_key, 'order_meta' ); |
|
| 386 | ||
| 387 | if ( false !== $cached_meta ) { |
|
| 388 | $this->_meta_data = $cached_meta; |
|
| 389 | } else { |
|
| 390 | global $wpdb; |
|
| 391 | ||
| 392 | $raw_meta_data = $wpdb->get_results( $wpdb->prepare( "SELECT meta_id, meta_key, meta_value FROM {$wpdb->postmeta} WHERE post_id = %d ORDER BY meta_id", $this->get_id() ) ); |
|
| 393 | ||
| 394 | foreach ( $raw_meta_data as $meta ) { |
|
| 395 | if ( in_array( $meta->meta_key, $this->get_internal_meta_keys() ) ) { |
|
| 396 | continue; |
|
| 397 | } |
|
| 398 | $this->_meta_data[ $meta->meta_id ] = (object) array( 'key' => $meta->meta_key, 'value' => $meta->meta_value ); |
|
| 399 | } |
|
| 400 | ||
| 401 | wp_cache_set( $cache_key, $this->_meta_data, 'order_meta' ); |
|
| 402 | } |
|
| 403 | } |
|
| 404 | ||
| 405 | /** |
|
| 406 | * Update Meta Data in the database. |
|
| @@ 428-454 (lines=27) @@ | ||
| 425 | /** |
|
| 426 | * Read Meta Data from the database. Ignore any internal properties. |
|
| 427 | */ |
|
| 428 | protected function read_meta_data() { |
|
| 429 | $this->_meta_data = array(); |
|
| 430 | ||
| 431 | if ( ! $this->get_id() ) { |
|
| 432 | return; |
|
| 433 | } |
|
| 434 | ||
| 435 | $cache_key = WC_Cache_Helper::get_cache_prefix( 'order_itemmeta' ) . $this->get_id(); |
|
| 436 | $cached_meta = wp_cache_get( $cache_key, 'order_itemmeta' ); |
|
| 437 | ||
| 438 | if ( false !== $cached_meta ) { |
|
| 439 | $this->_meta_data = $cached_meta; |
|
| 440 | } else { |
|
| 441 | global $wpdb; |
|
| 442 | ||
| 443 | $raw_meta_data = $wpdb->get_results( $wpdb->prepare( "SELECT meta_id, meta_key, meta_value FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id = %d ORDER BY meta_id", $this->get_id() ) ); |
|
| 444 | ||
| 445 | foreach ( $raw_meta_data as $meta ) { |
|
| 446 | if ( in_array( $meta->meta_key, $this->get_internal_meta_keys() ) ) { |
|
| 447 | continue; |
|
| 448 | } |
|
| 449 | $this->_meta_data[ $meta->meta_id ] = (object) array( 'key' => $meta->meta_key, 'value' => $meta->meta_value ); |
|
| 450 | } |
|
| 451 | ||
| 452 | wp_cache_set( $cache_key, $this->_meta_data, 'order_itemmeta' ); |
|
| 453 | } |
|
| 454 | } |
|
| 455 | ||
| 456 | /** |
|
| 457 | * Update Meta Data in the database. |
|