php - Why is my custom WooCommerce code breaking the Ajax? -


please advice me what's wrong custom woocommerce-code. i'm using make product quantity field archive pages (so user can add multiple products cart directly archive - , no need go single product -page if wants choose more 1 piece). code of mine works great otherwise when active - ajax add cart -system doesn't work. problem? here's code:

    add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 ); function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {     if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {         $html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';         $html .= woocommerce_quantity_input( array(), $product, false );         $html .= '<button type="submit" data-product-id="' . esc_attr( $product->id ) . '" class="button add_to_cart_button ajax_add_to_cart">' . esc_html( $product->add_to_cart_text() ) . '</button>';         $html .= '</form>';     }     return $html; } 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -