• Resolved jamesjohnsonw

    (@jamesjohnsonw)


    Hey there, I made a thread earlier about creating exclusive to bundle products. I thought I’d done it and closed the thread but, alas I have not. So, I have a bundle of 2 live products and I want to add 3 other products which should be exclusive to the bundle and, not available to purchase individually (see here: http://prntscr.com/127g7gv)

    I tried creating the products but set them to ‘Hidden’ and set the price to nothing: http://prntscr.com/127xiwr

    They come up in the bundled products list because they are ‘in stock’ but, you can’t click on them as they are ‘hidden’: http://prntscr.com/127xjql

    Even if users manage to find the link to the ‘bundle exclusive product’, they are greeted with a product page but, there is no option to purchase because there is no price associated with the product: http://prntscr.com/127xlkw

    Unfortunately, this also means, they can’t purchase the bundle. Is there any way I can hide a product from the site but, still make it ‘purchasable’ but, only through a bundle?

    Thanks, /JJ

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi @jamesjohnsonw,

    If you just want to sell some products in bundles, but not as individual products in your shop, you can prevent customers from finding them and adding to the cart by doing two things:

    1/ Disable “Link to individual product” by choosing “No” for this option in WPClever >> Product Bundles. https://prntscr.com/12est26

    2/ Hide them from your shop archive and search by adjusting their visibility to Hidden.
    https://prntscr.com/128t62r

    Regards

    • This reply was modified 5 years, 1 month ago by miemie.
    Thread Starter jamesjohnsonw

    (@jamesjohnsonw)

    Hey @miemie

    Thanks for this! Unfortunately, this doesn’t quite work!

    I am able to hide the products on the shop archive and unlink them using the WPClever Product Bundle plugin. I would like to still be able to click on the first two products on the list (as they can be purchased individually): http://prntscr.com/12f8jry

    After checkout, in the downloads list, users are able to click through to the product pages of all the products (even if they are unlinked and hidden): http://prntscr.com/12f8ksb

    Although they are hidden, the links are still able to be shared:
    http://prntscr.com/12f8lgi

    Is there any way around this?
    Best, /JJ

    Plugin Author WPClever

    (@wpclever)

    Hi @jamesjohnsonw

    In this case, you still need to add the price for exclusive products to make them purchasable.

    Then, add the below snippet to prevent buying them individually (How to add custom code?):

    add_filter( 'woocommerce_add_to_cart_validation', 'woosb_prevent_exclusive_products', 10, 2 );
    function woosb_prevent_exclusive_products( $passed, $product_id ) {
    	$exclusive_products = array( 999, 1248 ); // fill your exclusive products ID here
    
    	if ( in_array( $product_id, $exclusive_products, false ) ) {
    		wc_add_notice( esc_html__( 'This is exclusive product for bundles, you can\'t add this product individually.', 'woo-product-bundle' ), 'error' );
    
    		return false;
    	}
    
    	return $passed;
    }

    Now when buying it individually, the buyer will see the notice https://www.screencast.com/t/O8lSv2i1ME2W

    Thread Starter jamesjohnsonw

    (@jamesjohnsonw)

    Hi @wpclever

    Thanks- I’ve added the code as shown: http://prntscr.com/12j3os8

    and added a price (£10) to the exclusive products. Unfortunately, they are still able to be purchased: http://prntscr.com/12j3pu2

    I will leave the site for a few minutes and clear my cache to see if anything changes.

    Thanks again,
    /JJ

    Thread Starter jamesjohnsonw

    (@jamesjohnsonw)

    Hey @wpclever

    This code hasn’t seemed to work? I’ve added this to my functions.php and tried the Code Snippet plugin.

    Any ideas?

    Best, /JJ

    Plugin Author WPClever

    (@wpclever)

    @jamesjohnsonw the add-to-cart button still is there but you will see the error when trying to buy it individually.

    Thread Starter jamesjohnsonw

    (@jamesjohnsonw)

    Thanks @wpclever

    I have built upon the code and issue I was having. I have disabled the purchase (with your code), then removed certain features (add to cart button, price, social share, category list, reviews) for products within the ‘Bundle Exclusives’ category. Finally, I have hidden the ‘Bundle Exclusives’ category. Bit of a weird fix. Would love to see exclusive products implemented in WooCommerce or the Product Bundles plugin!

    Code

    // DISABLE PURCHASE
    
    add_filter( 'woocommerce_add_to_cart_validation', 'woosb_prevent_exclusive_products', 10, 2 );
    function woosb_prevent_exclusive_products( $passed, $product_id ) {
    	$exclusive_products = array( 6292, 6291, 6290, 6286, 6285, 6284, 6279, 6278, 6277 ); // fill your exclusive products ID here
    
    	if ( in_array( $product_id, $exclusive_products, false ) ) {
    		wc_add_notice( esc_html__( 'This is an exclusive product only available in bundles!', 'woo-product-bundle' ), 'error' );
    
    		return false;
    	}
    
    	return $passed;
    }
    
    // DISABLE ADD TO CART BUTTON, PRICE, SOCIAL SHARE AND CATEGORY LIST ON BUNDLE EXCLUSIVE CATEGORY
    
    add_action('woocommerce_single_product_summary', 'remove_product_description_add_cart_button', 1 );
    function remove_product_description_add_cart_button() { // function for deleting ...
        // Set category ID
        $categories = array('bundle-exclusives');
    
        //Feature removal
        if ( has_term( $categories, 'product_cat', get_the_id() ) ) {
            remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
    		remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
    		remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
    		remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
        }
    }
    
    // HIDE BUNDLE EXCLUSIVE CATEGORY
    
    add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 );
    function ts_get_subcategory_terms( $terms, $taxonomies, $args ) {
    	$new_terms = array();
    
    		if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() &&is_shop() ) {
    		foreach( $terms as $key => $term ) {
    		if ( !in_array( $term->slug, array( 'bundle-exclusives', 'uncategorized' ) ) ) { //pass the slug name here
    	
    	$new_terms[] = $term;
    	}}
    	$terms = $new_terms;
    	}
    
    return $terms;
    }

    Screenshots:

    Normal product: http://prntscr.com/12l3zr6

    Bundle exclusive product: http://prntscr.com/12l40fs

    Thanks for your help,
    Best, /JJ

    Plugin Author WPClever

    (@wpclever)

    Thanks for the detailed information and snippets!

    I’ll guide other customers to do that if they have the same requirements.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Exclusive products’ is closed to new replies.