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