Separate Categories from WC Product loop when display type is set to both on the category

I have found the solution I was looking for. Using the following code will stop displaying categories in the product loop. remove_filter( ‘woocommerce_product_loop_start’, ‘woocommerce_maybe_show_product_subcategories’ ); Then use the following function in a separate section of the page will render the categories in a separate section. woocommerce_maybe_show_product_subcategories()

global $post; in WooCommerce

You should avoid using global variables where possible. For metaboxes you should use the $post variable that is passed to the callback function instead: add_meta_box( ‘supplier_package_box’, __( ‘Supplier’, ‘supplier’ ), ‘populate_meta_box’ ); function populate_meta_box( $post ){ print_r($post); }

Accessing parameters when adding filter

When you call add_filter(), set the fourth parameter to 3 (which is the number of parameters accepted by the callback function which in your case is change_rating_output()), and then change your change_rating_output() function so that it accepts the $rating and $count parameters: add_filter(‘woocommerce_product_get_rating_html’, ‘change_rating_output’, 10, 3); function change_rating_output($html, $rating, $count){ // Now do what you … Read more

Move WooCommerce product tabs out of the tabs [closed]

It turned out that woocommerce_get_template() was deprecated and replaced by wc_get_template(). I solved this by adding this to my functions.php. add_action( ‘woocommerce_after_single_product_summary’, ‘removing_product_tabs’, 2 ); function removing_product_tabs(){ remove_action(‘woocommerce_after_single_product_summary’,’woocommerce_output_product_data_tabs’, 10 ); add_action(‘woocommerce_after_single_product_summary’,’get_product_tab_templates_displayed’, 10 ); } function get_product_tab_templates_displayed() { wc_get_template( ‘single-product/tabs/description.php’ ); wc_get_template( ‘single-product/tabs/additional-information.php’ ); comments_template(); }

Woocommerce add_to_cart non-register visitor not working

I did two tests on my dev site add_action( “wp_loaded”, function() { var_dump(WC()->cart->add_to_cart(1353)); }); and add_action( “wp_footer”, function() { var_dump(WC()->cart->add_to_cart(1353)); }); Both var_dump a hash, but only the first one actually adds a product to the cart, the second prints the hash but does not add anything. What is happening is that in the second … Read more

Move add to cart in Woocommerce

You can change the priority/order by removing and re-adding the parts you want the position changed – like this: remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 10 ); add_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_add_to_cart’, 10 ); Drop this piece of code into your functions.php to take effect.