Merge pull request #23877 from jdeeburke/fix/apply-coupon-fatal

Fix fatal error when applying a virtual coupon to an order placed by a guest
This commit is contained in:
Claudio Sanches 2019-06-18 16:00:39 -03:00 committed by GitHub
commit e849a5e044
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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(