is there a way to order products by price only when a user enters to a specific category?
I kind of know that I can achieve this using hooks in functions.php but I'm not sure on how to achieve this
add_filter('function-for-ordering-products','my-custom-function');
function my-custom-function(){
//Step 1. Find the category the user is currently watching
//Step 2. If the category is "Giftcards" go to step 3
//Step 2.1 If the category is not "Giftcards" go to step 4
//Step 3. Set products order by price
//Step 4. Do nothing
}
Can you help me out with that?
In Add_filter do i need to use woocommerce_before_shop_loop?
So the correct filter would be...
add_filter('woocommerce_before_shop_loop ','my-custom-function')?