Carrito no suma bien
-
Buenos días,
Tengo un problema en mi web y es que el carrito no suma correctamente. Solo me añade de 1 en 1 por más que cambie la cantidad del input. Esto son los 2 codigos que tengo:
add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_loop_ajax_add_to_cart', 10, 2 ); function quantity_inputs_for_loop_ajax_add_to_cart( $html, $product ) { if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) { // Get the necessary classes $class = implode( ' ', array_filter( array( 'button', 'product_type_' . $product->get_type(), $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '', ) ) ); // Adding embeding <form> tag and the quantity field $html = sprintf( '%s%s<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">%s</a>%s', '<form class="cart">', woocommerce_quantity_input( array(), $product, false ), esc_url( $product->add_to_cart_url() ), esc_attr( isset( $quantity ) ? $quantity : 1 ), esc_attr( $product->get_id() ), esc_attr( $product->get_sku() ), esc_attr( isset( $class ) ? $class : 'button' ), esc_html( $product->add_to_cart_text() ), '</form>' ); } return $html; } add_action( 'wp_footer' , 'archives_quantity_fields_script' ); function archives_quantity_fields_script(){ if( is_shop() || is_product_category() || is_product_tag() ): ?> <script type='text/javascript'> jQuery(function($){ // Update quantity on 'a.button' in 'data-quantity' attribute (for ajax) $('form.cart').on('change', 'input.qty', function() { if ($(this).val() === '0') $(this).val('1'); $(this).closest('form.cart').find( 'a.add_to_cart_button').attr('data-quantity', $(this).val()); }); }); </script> <?php endif; }
Y este:
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_archive_custom_cart_button_text', 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" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>'; $html .= '</form>'; } return $html; }
Llevo dias buscando sin encontrar el problema.
Gracias de antemano.
La página con la que necesito ayuda: [accede para ver el enlace]
Viendo 2 respuestas - de la 1 a la 2 (de un total de 2)
Viendo 2 respuestas - de la 1 a la 2 (de un total de 2)
- El debate ‘Carrito no suma bien’ está cerrado a nuevas respuestas.