'WooCommerce single product page by Woolentor : Related product customize

I use WooCommerce, Woolentor, and WooCommerce subscriptions to construct a website. I'm trying to use the 'WL:Related Product' widget for Woolentor's Single Product template, but I couldn't find a way to add the function I wanted.

  1. WooCommerce subscription products have been found and used as invisible code in the store, but I also want to hide the subscription products in Related Products in Single Product.

    add_action('woocommerce_product_query', 'exclude_specific_tag');

    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('hidden') 'operator' => 'NOT IN' ); $q->set('tax_query', $tax_query); } }

The above code was understood as a function of hiding the product in the store if the tag of the subscription product is designated as hidden.

  1. If it is possible to hide a specific tag product in the linked product according to the tag as shown in No. 1, on the contrary, it is possible to display only products that match the category or tag of the currently viewed product on the related product.

For your information, I am considering using UpSell, but I think it is cumbersome to designate UpSell Product every time, so I want to make it as above.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source