Woocommerce exclude specific categories products from related products

add_action( ‘wp’, ‘vn_remove_related_products’ ); function vn_remove_related_products() { if ( is_product() && has_term( array(‘workshops’, ‘events’), ‘product_cat’ ) ) { remove_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_output_related_products’, 20 ); } } Function has_term() can pass first parameter as array with terms.

if statement for search results

Within the loop the best way to check if the result is a product would be to check the value of get_post_type(): if ( get_post_type() === ‘product’ ) { } As you say, is_woocommerce(), is_product() and is_search() are for checking which type of page is being viewed regardless of the current item in the loop.

Fatal Error in WordPress WooCommerce theme “Call to undefined function wc_get_theme_slug_for_templates()”

Ok, the error is telling you this: The error comes from this theme file: \themes\vw-ecommerce-shop\woocommerce\global\wrapper-end.php Line: 23. In that file on line 23 the following function is called wc_get_theme_slug_for_templates() but at that point it’s not (yet) available. The function should be available though, because it’s a valid Woocommerce function, see here. Can you update your … Read more

Hiding products with a specific tag from WooCommerce main shop page

You can paste the following snippet in your child theme’s functions.php function exclude_specific_tag( $q ) { if (is_shop()){ $tax_query = (array) $q->get( ‘tax_query’ ); $tax_query[] = array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => array( ‘pré-commande’ ), // write the tag name to remove in between the ” ‘operator’ => ‘NOT IN’ ); $q->set( … Read more

Send a value to woocommerce with a button type submit

At the select tag you have 2 name attribute <select type=”number” step=”any” name=”actions” id=”actions-select” name=”wpneo_donate_amount_field” class=”input-text amount wpneo_donate_amount_field text”> Then, when you submit, it only collect the first defined name. (name=”actions”). You have to delete this attribute. and using name=”wpneo_donate_amount_field” only. It should like <select type=”number” step=”any” id=”actions-select” name=”wpneo_donate_amount_field” class=”input-text amount wpneo_donate_amount_field text”>

function to add note on single Woo Commerce product page for downloadable variations

For variable product, it’s not the product that you need to test but the variations : add_action( ‘woocommerce_before_add_to_cart_button’ , function () { global $product; $downloadable = FALSE; if (“simple” === $product->get_type()) { $downloadable = $product->is_downloadable(); } elseif (“variable” === $product->get_type()) { $variations = $product->get_available_variations(); foreach ($variations as $variation) { if ($variation[“is_downloadable”]) { $downloadable = TRUE; … Read more

How can I add an additional action button into the woocommerce admin order page?

Add this below code your current active theme functions.php file add_filter( ‘woocommerce_admin_order_actions’, ‘add_custom_order_status_actions_button’, 100, 2 ); function add_custom_order_status_actions_button( $actions, $order ) { if ( $order->has_status( array( ‘processing’ ) ) ) { // The key slug defined for your action button $action_slug = ‘invoice’; $status = $_GET[‘status’]; $order_id = method_exists($the_order, ‘get_id’) ? $the_order->get_id() : $the_order->id; // … Read more