• Resolved amber19

    (@amber19)


    I’m setting up a GWP for my client and I want to use this plugin but I’m unsure if it can create certain parameters to exclude specific users.
    I only want users coming to the site from email to be able to get the free gift. How can I build conditions around that with this plugin?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author DecomTeam

    (@decomteam)

    Hi @amber19 giftable doesn’t have that feature, we have user conditional but it would be hard to select all users (+ if users can register) – user conditional was created to give gift to couple (2-4) selected users (like small reward system etc.)

    What you can try (needs custom code) is to dedicate users on registration to different custom user roles then it would be easier to customize other things:

    $user = wp_get_current_user();
    $allowed_roles = array('email_role', 'second_role');
    <?php if( array_intersect($allowed_roles, $user->roles ) ) {  ?>
       // show something to only email_role and second_role users
    <?php } ?>

    in combination with

    
    /**
     * Add another product depending on the cart total
     */
    add_action( 'template_redirect', 'add_product_to_cart' );
    function add_product_to_cart() {
      if ( ! is_admin() ) {
    		global $woocommerce;
    		$product_id = 2831; //replace with your product id
    		$found = false;
    		$cart_total = 30; //replace with your cart total needed to add above item
    
    		if( $woocommerce->cart->total >= $cart_total ) {
    			//check if product already in cart
    			if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
    				foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
    					$_product = $values['data'];
    					if ( $_product->get_id() == $product_id )
    						$found = true;
    				}
    				// if product not found, add it
    				if ( ! $found )
    					$woocommerce->cart->add_to_cart( $product_id );
    			} else {
    				// if no products in cart, add it
    				$woocommerce->cart->add_to_cart( $product_id );
    			}
    		}
    	}
    }
    

    WooCommerce codes: automatically add a product to the cart

    Thread Starter amber19

    (@amber19)

    @decomteam where would I add this custom code in? Is this a tried and true solution? I just want to be able to only offer the free gift to those customers who come to the site from an email campaign. Also, once they click through and go to the site from the email, will the gift automatically be added to their cart if they add the qualifying item to their cart?

    Plugin Author DecomTeam

    (@decomteam)

    Hi @amber19 Giftable doesnt support your use case (tracking user, auto add gift to cart..etc we dont have that).

    I just shared a code that could help you go into right direction, you need to find solution how to track users from email campaign and not mix them with normal users, best way to do that is talk with your developer about custom solution or code to extend an plugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Excluding certain users from getting free gift’ is closed to new replies.