Remove cart functionality from WooCommerce so it doesn’t remember the products [closed]

Not sure if this is the right way to do it but I finally found an answer here: https://stackoverflow.com/a/49382476/2308992 and did the following: add_action( ‘woocommerce_add_to_cart_validation’, function( $passed, $product_id, $quantity ) { if( ! WC()->cart->is_empty() ) { wc_empty_cart(); } return $passed; }, 20, 3); What this does basically before WooCommerce tries to add anything in the … Read more

WordPress | Woocommerce | use “category display type” in if statement

Depending on where whoocommerce posts are stored, you could do this via basic WordPress post queries, via: $args = array( ‘post_type’ => ‘your_post_type’, ‘category_name’ => ‘your_category’, ‘tag’ => ‘your_tag’ ); $arr_posts = new WP_Query($args); if ($arr_posts->have_posts()) { while ($arr_posts->have_posts()) { echo $arr_posts->the_post(); // Echo out content of each post, but here you may do whatever … Read more

Conditional for product attribute page

This is the answer: function active_woocommerce_filters() { // for older WC versions // global $_chosen_attributes; $_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes(); return count( $_chosen_attributes ); } https://stackoverflow.com/questions/33229238/woocommerce-check-if-filtering-products