From 332c94c13a13a7cd7568538fd7258a3e47629ed1 Mon Sep 17 00:00:00 2001 From: Jared Burke Date: Thu, 6 Jun 2019 15:37:08 -0500 Subject: [PATCH] Fix fatal error when applying a virtual coupon to an order placed by a guest --- includes/abstracts/abstract-wc-order.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/abstracts/abstract-wc-order.php b/includes/abstracts/abstract-wc-order.php index f144e2056ab..f2e97cf863a 100644 --- a/includes/abstracts/abstract-wc-order.php +++ b/includes/abstracts/abstract-wc-order.php @@ -965,9 +965,10 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order { return $applied; } + $data_store = $coupon->get_data_store(); + // Check specific for guest checkouts here as well since WC_Cart handles that seperately in check_customer_coupons. - if ( 0 === $this->get_customer_id() ) { - $data_store = $coupon->get_data_store(); + if ( $data_store && 0 === $this->get_customer_id() ) { $usage_count = $data_store->get_usage_by_email( $coupon, $this->get_billing_email() ); if ( 0 < $coupon->get_usage_limit_per_user() && $usage_count >= $coupon->get_usage_limit_per_user() ) { return new WP_Error(