• Hello, I apologize for my English. I have a problem, products are not added to the cart when using your plugin. There has already been a similar question. I also have a theme from the developer Xtemos. Here is a snippet of code that is responsible for adding products to the cart. I will be grateful if you can help solve the problem.

    
    if( ! function_exists( 'woo_ajax_add_to_cart' ) ) {
    	function woo_ajax_add_to_cart() {
    		// Get messages
    		ob_start();
    
    		wc_print_notices();
    
    		$notices = ob_get_clean();
    
    		// Get mini cart
    		ob_start();
    
    		woocommerce_mini_cart();
    
    		$mini_cart = ob_get_clean();
    
    		// Fragments and mini cart are returned
    		$data = array(
    			'notices' => $notices,
    			'fragments' => apply_filters( 'woocommerce_add_to_cart_fragments', array(
    					'div.widget_shopping_cart_content' => '<div class="widget_shopping_cart_content">' . $mini_cart . '</div>'
    				)
    			),
    			'cart_hash' => apply_filters( 'woocommerce_add_to_cart_hash', WC()->cart->get_cart_for_session() ? md5( json_encode( WC()->cart->get_cart_for_session() ) ) : '', WC()->cart->get_cart_for_session() )
    		);
    
    		wp_send_json( $data );
    
    		die();
    	}
    }
    
    add_action( 'wp_ajax_woo_ajax_add_to_cart', 'woo_ajax_add_to_cart' );
    add_action( 'wp_ajax_nopriv_woo_ajax_add_to_cart', 'woo_ajax_add_to_cart' );
    
Viewing 1 replies (of 1 total)
  • Thread Starter hellion35

    (@hellion35)

    I understand that this is due to ajax adding an item to the cart, if this option is disabled in the template settings, then everything starts working(((

Viewing 1 replies (of 1 total)
  • The topic ‘Add to cart does not work’ is closed to new replies.