Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide option select item in woocommerce product type

I am planning to deliver a woocommerce shop to someone and I want to hide none essential options in order not to confuse non advance users. Particularly Product type.

In WooCommerce Product Editor, there is an option to select product type. I only want to show Simple and variable product.

Normally this could be done using css display:hide attributes but when I inspect woocommerce product option select, the options does not have id nor class selector.

Here is the code I saw on product options

<select id="product-type" name="product-type">
<optgroup label="Product Type"><option value="simple" selected="selected">Simple product</option>
<option value="grouped">Grouped product</option><option value="external">External/Affiliate product</option>
<option value="variable">Variable product</option></optgroup>
</select>

My question. Is there a way to hide grouped product and affiliate product type on that option select box in a way that it wont be affected during woocommerce or wp update?

Thanks

like image 872
Wayne Avatar asked Dec 23 '13 15:12

Wayne


People also ask

How do I hide specific product category in WooCommerce?

From the admin panel, go to WooCommerce > Product Visibility > Global visibility tab and select the product and category you want to hide.

How do I remove select options in WooCommerce?

woocommerce_loop_add_to_cart_link filter hook can be used to remove the Select options buttons for each variable product. Add the following in child theme's functions. php: // Remove "Select options" button from (variable) products on the main WooCommerce shop page.

How do I hide a specific product from a shop page in WooCommerce?

The standard method to hide WooCommerce productsOpen up the product you'd like to hide in the 'Edit product' screen. The 'Catalog visibility' option (in the 'Publish' widget to the right) lets you decide which shop pages the product will be listed on. Select the 'Hidden' option.

Where are hidden products in WooCommerce?

Go to Products > Categories. Edit the category for the hidden products that you made. Scroll down to the Visibility section. Pick which users and/or roles have access to your hidden WooCommerce items by going to Protected > Users.


1 Answers

You can filter product_type_selector

add_filter( 'product_type_selector', 'remove_product_types' );

function remove_product_types( $types ){
    unset( $types['grouped'] );
    unset( $types['external'] );

    return $types;
}
like image 147
Laxmana Avatar answered Jan 12 '23 13:01

Laxmana