• Hello,

    I would like to send emails to my customer having one of their wishlist product going out-of-stock. In order to do so, I need to get the list of potential receivers.
    Is there a way to do that ?
    Thank you

Viewing 1 replies (of 1 total)
  • Plugin Support Antonio La Rocca

    (@therock130)

    Hi there

    first of all, I’d like to specify that, in another version of the plugin, we have an automatic system that emails users when one of the products in their wishlist is back in stock
    You can read more about this in our landing page ??

    Regarding your specific question, I think you could retrieve a list of items using a custom snippet of code that queries wishlist database directly
    For example, consider the following snippet of code:

    function yith_wcwl_users_by_product( $product_id ) {
    	$list = array();
    
    	try {
    		$data_store = WC_Data_Store::load( 'wishlist-item' );
    	} catch ( Exception $e ) {
    		return $list;
    	}
    
    	$items = $data_store->query(
    		array(
    			'product_id'  => $product_id,
    			'user_id'     => false,
    			'session_id'  => false,
    			'wishlist_id' => 'all',
    		)
    	);
    
    	if ( empty( $items ) ) {
    		return $list;
    	}
    
    	foreach ( $items as $item ) {
    		/**
    		 * Wishlist item
    		 *
    		 * @var $item YITH_WCWL_Wishlist_Item
    		 */
    		$user = $item->get_user();
    
    		if ( ! $user ) {
    			continue;
    		}
    
    		$list[] = $user->user_email;
    	}
    
    	return $list;
    }

    This function will return a list of email addresses of customers with a specific product in wishlist (it requests product id as only input)

Viewing 1 replies (of 1 total)
  • The topic ‘Getting list of customer having a specific item in their wishlist’ is closed to new replies.