Pre filter woocommerce products to remove a certain category of products

You can use the pre_get_posts hook for Woocommerce product query, but here the example is for the main query. function wpse_306252_query( $query ) { if($query->is_main_query()) { $query->set( ‘category__not_in’, YOUR_CAT_ID); } } add_action( ‘pre_get_posts’, ‘wpse_306252_query’ ); If you want the opposite of it, I think the best is to add a SquareExport parameter to check when … Read more

In WooCommerce can you make a list of ‘steps’ for quantity increase? [closed]

unfortunately, the quantity input doesn’t support this. The quantity input is rendered in the following template: global/quantity-input.php. You can see in the template that it’s using an html input element, of type ‘number’, which doesn’t support custom steps. Using a filter in this case just can’t work. If you are sure that you will always … Read more

Change max number of products on shop pages

You can add this code to your functions.php: /** * Change number of products that are displayed per page (shop page) */ add_filter( ‘loop_shop_per_page’, ‘new_loop_shop_per_page’, 20 ); function new_loop_shop_per_page( $products ) { // Return the number of products you wanna show per page. $products = 100; return $products; } Change the 100 for more if … Read more

How to re-arrange this hooked content?

To override action that use in plugin, use can wrap the remove_action code in template_redirect action to make sure your action will be excute later. For example add_action(‘template_redirect’, function() { // Remove the title. remove_action(‘sensei_course_content_inside_before’, array( ‘Sensei_Templates’, ‘the_title’ ) ,5, 1 ); // Add it again add_action(‘sensei_course_content_inside_before’, array( ‘Sensei_Templates’, ‘the_title’ ) ,15, 1 ); }, … Read more

How do I update every title of a certain category with a phrase

I would use a filter. Sometimes things change and strings have to be translated and so on: function my_custom_built_title( $title, $post_id ) { $post = get_post( $post_id ); if ( ‘product’ == $post->post_type ) { $terms = wp_get_post_terms( $post->ID, ‘product_cat’, [ ‘fields’ => ‘ids’ ] ); if ( in_array( ‘3439’, $terms ) ) { $title=”Custom … Read more

woocommerce_new_product action doesn’t fire

Try like function add_this_to_new_products( $new_status, $old_status, $post ) { global $post; if ( $post->post_type !== ‘product’ ) return; if ( ‘publish’ !== $new_status or ‘publish’ === $old_status ) return; add_post_meta( $post->ID, ‘total_amount’, ‘0’, true ); // This is the action to take } add_action( ‘transition_post_status’, ‘add_this_to_new_products’, 10, 3 );