Merge pull request #18612 from woocommerce/fix/18610-coupon-user-limit-admin-area

Coupon usage check against customer not logged in user in admin
This commit is contained in:
Mike Jolley 2018-01-26 15:03:01 +00:00 committed by GitHub
commit 29760cfdb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -574,7 +574,11 @@ class WC_Discounts {
*/
protected function validate_coupon_user_usage_limit( $coupon, $user_id = 0 ) {
if ( empty( $user_id ) ) {
$user_id = get_current_user_id();
if ( $this->object instanceof WC_Order ) {
$user_id = $this->object->get_customer_id();
} else {
$user_id = get_current_user_id();
}
}
if ( $coupon && $user_id && $coupon->get_usage_limit_per_user() > 0 && $coupon->get_id() && $coupon->get_data_store() ) {