• Resolved delaitec

    (@delaitec)


    Hi,
    Congratulations on the great job.

    I used the code made available by WooCommerce Docs at this link:
    https://docs.woocommerce.com/document/override-loop-template-and-show-quantities-next-to-add-to-cart-buttons/

    To display the quantity buttons next to the Add to Cart button for products.

    This was the code used:

    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;
    }
    add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );

    Although, I found a possible bug in the code.

    On the product page, when UpSell and Related Products are being displayed.

    When changing the quantity in one, the others are also changed.

    Note this error does not occur with CrossSell products on the Cart page.

    Does anyone know what may be causing this?

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter delaitec

    (@delaitec)

    If anyone on the Woocommerce team knows how to explain to me why this strange behavior,

    I would appreciate it immensely.

    Plugin Support abwaita a11n

    (@abwaita)

    Hi @delaitec,

    There hasn’t been much activity on this thread, so I wanted to add a few more options for you to search for insights from.

    You can visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    I hope this helps.

    Thread Starter delaitec

    (@delaitec)

    Hello @abwaita

    Thanks for your reply 🙂

    I will try your suggestion.

    Hope someone can help here to.

    Good night

    Thread Starter delaitec

    (@delaitec)

    Nothing yet.
    I really wanted to understand what’s going on.

    Plugin Support B C. a11n

    (@battouly)

    Hi @delaitec,

    I would also like to double-check if you have tested this out with only the Storefront theme and WooCommerce active.

    If yes, please share the step by step to replicate so I can check that out with the developers.

    Thanks.

    Thread Starter delaitec

    (@delaitec)

    Hi.

    I found out what was going on.

    My “generatepress pro” theme has the + and – buttons, and they were conflicting with the code I posted here.

    After disabling the buttons in the theme settings the issue was resolved.

    But, i decide use the plugin bellow, cause his work with ajax.
    https://wordpress.org/support/topic/perfect-8581/

    Thank you all for your help.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Add quantity button to the item list’ is closed to new replies.