• Resolved Erfan MHDi

    (@erfanmhd)


    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.

    • This topic was modified 4 years ago by Erfan MHDi.
    • This topic was modified 4 years ago by Erfan MHDi.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @erfanmhd

    Sorry for my late response.

    As you said “Instead of “1” below, i have to check all complete purchases to find any purchases matching product_type taxonomy terms i guess.”

    Yes you are right. It is number of purchases to fetch.

    Plugin Support Mihai Joldis

    (@misulicus)

    Because there have not been any recent updates to this topic we’ll be changing the status to resolved. If you have any further questions you can start a new thread or head over to our support page to submit your request if it is related to one of our available extensions

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.