Add a conditional to match `inc_usage_count()`
Otherwise, for empty $used_by values, it will fire off a needless db query.
This commit is contained in:
parent
40dfb59bde
commit
4692afacdd
|
@ -271,6 +271,7 @@ class WC_Coupon {
|
|||
$this->usage_count--;
|
||||
update_post_meta( $this->id, 'usage_count', $this->usage_count );
|
||||
|
||||
if ( $used_by ) {
|
||||
/**
|
||||
* We're doing this the long way because `delete_post_meta( $id, $key, $value )` deletes
|
||||
* all instances where the key and value match, and we only want to delete one.
|
||||
|
@ -281,6 +282,7 @@ class WC_Coupon {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error_message string
|
||||
|
|
Loading…
Reference in New Issue