show wc_add notices on particular page in woo commerce custom plugin development

I solve this problem below is code. add_action( ‘woocommerce_init’, array( $this, ‘afwo_add_notices’ ) ); public function afwo_add_notices() { if ( isset( $_POST[‘whatsapp_cart_nonce_field’] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[‘whatsapp_cart_nonce_field’] ) ), ‘whatsapp_cart_field’ ) ) { echo ”; } if ( empty( WC()->session->get( ‘WhatsApp_cart’ ) ) ) { return; } if ( isset( $_GET[‘index_to_remove’] ) ) { … Read more

How do I make my terms for each product display via foreach loop? (woocommerce)

The problem is here: while ( $query->have_posts() ) { $query->the_post(); function filter_categories($categories) { foreach ($categories as $category) { echo $category->name; } } You shouldn’t declare a function inside a loop. Every time it loops around the filter_categories function gets declared again, but named functions can only be declared once, so it crashes the second time … Read more

How do I add filter with woocommerce categories?

I was missing the condition for the array inside the tax_query array. It is important to have it regardless if you have one or more conditions. $term_search = get_queried_object()->slug; // WP_Query arguments $args = array( ‘p’ => ‘product’, ‘post_type’ => array( ‘product’ ), ‘order’ => ‘ASC’, ‘post_per_page’ => 20, ‘tax_query’ => array(array( ‘taxonomy’ => ‘product_cat’, … Read more

“add to cart” links css class “ajax_add_to_cart” doesn’t show in woocommerce in widget sidebar

At last i solved it myself. Hope someone will get benefit form this answer. I merge $default variables all array (quantity, class, attributes) directly into link. I changed whole block of if ( $product ) {}. if ( $product ) { $output .= sprintf( ‘<a href=”%s” data-quantity=”1″ class=”%s” %s>%s</a>’, esc_url( $product->add_to_cart_url() ), esc_attr( implode( ‘ … Read more