Migrate the actual querying of the underlying data structure.
Move it into the relative class for tidiness, and have it be called via an access function.
This commit is contained in:
parent
4692afacdd
commit
a17addae0a
|
@ -1588,7 +1588,7 @@ class WC_Cart {
|
|||
// Usage limits per user - check against billing and user email and user ID
|
||||
if ( $coupon->usage_limit_per_user > 0 ) {
|
||||
$check_emails = array();
|
||||
$used_by = array_filter( (array) get_post_meta( $coupon->id, '_used_by' ) );
|
||||
$used_by = $coupon->get_used_by();
|
||||
|
||||
if ( is_user_logged_in() ) {
|
||||
$current_user = wp_get_current_user();
|
||||
|
|
|
@ -284,6 +284,18 @@ class WC_Coupon {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get records of all users who have used the current coupon.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_used_by() {
|
||||
$_used_by = (array) get_post_meta( $this->id, '_used_by' );
|
||||
// Strip out any null values.
|
||||
return array_filter( $_used_by );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error_message string
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue