Fix fatal error when applying a virtual coupon to an order placed by a guest

This commit is contained in:
Jared Burke 2019-06-06 15:37:08 -05:00
parent 9eca72849d
commit 332c94c13a
1 changed files with 3 additions and 2 deletions

View File

@ -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(