Created
January 23, 2018 14:48
-
-
Save danielbitzer/d33a993b269729751f89c2e385de534d to your computer and use it in GitHub Desktop.
AutomateWoo - Get a list of a user's generated coupons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// please note the _aw_customer_id meta data was added in version 3.5.1 | |
$user_id = 123; //example id | |
$customer = AutomateWoo\Customer_Factory::get_by_user_id( $user_id ); | |
$query_args = [ | |
'post_type' => 'shop_coupon', | |
'posts_per_page' => -1, | |
'orderby' => 'date', | |
'order' => 'ASC', | |
'meta_query' => [ | |
[ | |
'key' => '_is_aw_coupon', | |
'value' => true | |
], | |
[ | |
'key' => '_aw_customer_id', | |
'value' => $customer->get_id() | |
] | |
] | |
]; | |
$query = new \WP_Query( $query_args ); | |
$coupons = $query->posts; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment