Skip to content
This repository was archived by the owner on Jun 15, 2022. It is now read-only.

Commit 8852ebd

Browse files
committed
If a matching order row was not found, WC_Order_Data_Store_Custom_Table::read_order_data() should return an *empty* array
1 parent 1a3e09a commit 8852ebd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

includes/class-wc-order-data-store-custom-table.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function read_order_data( &$order, $post_object ) {
7575
*
7676
* @param WC_Order $order The order object.
7777
*
78-
* @return object The order row, as an associative array.
78+
* @return array The order row, as an associative array.
7979
*/
8080
public function get_order_data_from_table( $order ) {
8181
global $wpdb;
@@ -85,7 +85,13 @@ public function get_order_data_from_table( $order ) {
8585
'SELECT * FROM ' . esc_sql( $table ) . ' WHERE order_id = %d LIMIT 1',
8686
$order->get_id()
8787
), ARRAY_A ); // WPCS: DB call OK.
88-
$post = get_post( $order->get_id() );
88+
89+
// Return early if there's no matching row in the orders table.
90+
if ( empty( $data ) ) {
91+
return array();
92+
}
93+
94+
$post = get_post( $order->get_id() );
8995

9096
// Expand anything that might need assistance.
9197
if ( isset( $data['prices_include_tax'] ) ) {

0 commit comments

Comments
 (0)