• I am trying to hide chained products from appearing on the cart page, after reading this doc from woocommerce; I am stuck on how to make this filter… The Option name is sa_show_chained_items_to_customer and I just need the default changed from Yes to No…

    The code I made:

    add_filter( 'sa_show_chained_items_to_customer', 'is_show_chained_items' );
    
    function is_show_chained_items() {
    
    			$is_show = get_option( 'sa_show_chained_items_to_customer', 'no' );
    
    			if ( $is_show == 'yes' ) {
    				return false;
    			} else {
    				return true;
    			}
    
    		}

    Any help would be appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    This is an option – you can set it in the settings area.

    Thread Starter circlehift

    (@circlehift)

    Thank you @mikejolley for the response, are you positive about this – I am not seeing this anywhere on the woocommerce settings page, to quote the document:

    Note: To modify these values you can add or update a row in options table with option_name as sa_show_chained_item_price & option_value as yes / no

    It appears I definitely over thought this, but where abouts would I locate this option in the settings area.

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Odd. I’ve raised an issue and asked the developer to confirm.

    Thread Starter circlehift

    (@circlehift)

    @mikejolley, thanks again for the response! Here is a screen shot of the current settings location: https://screencast.com/t/CRcz9unSCXeI

    I looked into what you suggested about the settings, and found this article for developers. https://docs.woothemes.com/document/adding-a-section-to-a-settings-tab/

    It appears I need to create a filter in my function.php child theme that will allow the setting “yes” or “no” to be allowed/changed using “sa_show_chained_items_to_customer”. I have given that a shot, but this is kind of beyond me: as I am not sure what to replace wcslider with, I was trying chained_products_add_section

    Sample Code from woo docs article:

    add_filter( 'woocommerce_get_sections_products', 'wcslider_add_section' );
    function wcslider_add_section( $sections ) {
    
    	$sections['wcslider'] = __( 'WC Slider', 'text-domain' );
    	return $sections;
    
    }

    Thread Starter circlehift

    (@circlehift)

    @mikejolley, Temporarily – I have had to resort to this solution of hiding it from the cart with a .css trick – but it doesn’t hide them from the mini-cart. So it shows in the cart 1 product, but the minicart has 10 items.

    tr.cart_item.chained_item {
      display: none;
    }

    You see, I am using the chained product for inventory management of retail versus wholesale. As the attributes assigned are “bulk packs” of other variation products. A customer can choose a variation at a bulk rate, Pack A, and get 2 of each variation referenced (Pack A: 2x XS, SM, M; Pack B: 2x L, XL, XXL)product sizes (wholesale) at the variation set price (wholesale price). The customer understands this – so ultimately, This is only important for stock purposes on the individual sale versus bulk. It’s an important need to turn this off from showing up. Or a customer could possibly end up with 100’s of products in the cart for only purchasing 10 different packs. Chained products works best for this, as I have tried Composite products (but ended up with having to create a bundle product page for each pack, then finally ended up with a composite page to choose from each option): but this ended me with having to create up to 5-6 different pages for 1 product (which is way to many pages for just 1 bulk purchase product).

    Use this code (i.e. in functions.php):

    add_filter( 'sa_cp_show_chained_items', 'remove_chained_items' );
    /**
     * Remove chained items from cart, cart widget, checkout & order
     *
     */
    function remove_chained_items() {
        $bool = false;
    
        return $bool;
    }
    John

    (@john-pingtech)

    @mikejolly Any update to this? I can confirm that the option to change chained products does NOT appear in the woocommerce->product settings.

    • This reply was modified 7 years, 11 months ago by John. Reason: added mike jolly
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Help with a filter – removing chained product from cart’ is closed to new replies.