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:
commit
e849a5e044
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue