Check if order exists while check if COD is available

This commit is contained in:
Claudio Sanches 2021-03-17 13:20:46 -03:00
parent f6b4614225
commit 3a629efc4b
1 changed files with 1 additions and 1 deletions

View File

@ -132,7 +132,7 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
$order = wc_get_order( $order_id );
// Test if order needs shipping.
if ( 0 < count( $order->get_items() ) ) {
if ( $order && 0 < count( $order->get_items() ) ) {
foreach ( $order->get_items() as $item ) {
$_product = $item->get_product();
if ( $_product && $_product->needs_shipping() ) {