if user has any purchase with specific tax term
-
hello,
i’m trying to create an IF condition to detect if user has any purchase inside specific taxonomy term.
all my EDD downloads are assigned to a term from a taxonomy called like product_type
i want to know if user has any purchase at all or not
and if user has any purchase i want to know if user purchases any download from “TypeA” term of product_type or not.so far i got this :
<?php // instead of "1" below, i have to check all complete purchases to find any purchases matching product_type taxonomy terms i guess. $PurchasedItems = edd_get_users_purchases( get_current_user_id(), 1, false, 'complete' ); if ($PurchasedItems) { foreach ( $PurchasedItems as $PurchasedItem ) { $PurchasedItemsInfo = edd_get_payment_meta_cart_details( $PurchasedItem->ID, false ); if ( $PurchasedItemsInfo ) { foreach ( $PurchasedItemsInfo as $PurchasedItemInfo ) { $PurchasedItemID = $PurchasedItemInfo['id']; } } } if (has_term('typea', 'product_type', $PurchasedItemID)) { echo 'Type A Purchases: '; } elseif (has_term('typeb', 'product_type', $PurchasedItemID)) { echo 'Type B Purchases: '; } } ?>
but it’s detecting only first purchase and not checking all purchases…
can you guys help me with this please ?
is there any better way to do this ?Thanks.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘if user has any purchase with specific tax term’ is closed to new replies.