Check before getting order classname to see if it exists. (#35207)
This commit is contained in:
parent
80cbb9dcdc
commit
8848e4aa47
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Check whether order has classname before returning.
|
|
@ -233,7 +233,7 @@ class WC_Order_Factory {
|
||||||
*/
|
*/
|
||||||
private static function get_class_name_for_order_id( $order_id ) {
|
private static function get_class_name_for_order_id( $order_id ) {
|
||||||
$classname = self::get_class_names_for_order_ids( array( $order_id ) );
|
$classname = self::get_class_names_for_order_ids( array( $order_id ) );
|
||||||
return $classname[ $order_id ];
|
return $classname[ $order_id ] ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1824,4 +1824,15 @@ class OrdersTableDataStoreTests extends WC_Unit_Test_Case {
|
||||||
$this->sut->read_multiple( $orders );
|
$this->sut->read_multiple( $orders );
|
||||||
$this->assertFalse( $should_sync_callable->call( $this->sut, $order ) );
|
$this->assertFalse( $should_sync_callable->call( $this->sut, $order ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @testDox Make sure get_order return false when checking an order of different order types without warning.
|
||||||
|
*/
|
||||||
|
public function test_get_order_with_id_for_different_type() {
|
||||||
|
$this->toggle_cot( true );
|
||||||
|
$this->disable_cot_sync();
|
||||||
|
$product = new \WC_Product();
|
||||||
|
$product->save();
|
||||||
|
$this->assertFalse( wc_get_order( $product->get_id() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue