Bricks Version: 1.6
After installing V1.6 the quantity field for the “add to cart” widget disappears. Also if it is out of stock it now has a Read More link
Bricks Version: 1.6
After installing V1.6 the quantity field for the “add to cart” widget disappears. Also if it is out of stock it now has a Read More link
Hi Philip,
Thanks so much for your report!
Unfortunately, I cannot reproduce the issue. Would you be so kind as to provide a screencast showing and explaining what’s going on?
Best regards,
timmse
Hello
I have attached a link to the screencast.
It how’s it working under 1.5.7 but when upgrading to 1.6 it is different. I downgraded in the screencast and you can see it working again.
Apologises for the slow cast, the site backs up before updates
Kind regards
Philip
The quantity field in the pop-up window doesn’t work either. Only the Add to cart button is displayed.
Hey guys,
Quick update after consulting our devs: We are trying to follow the default WooCommerce way. If the Add to cart element is placed inside a query loop, we’re using the woo loop template. By default, the add-to-cart quantity will not be placed inside a woo loop.
If we don’t follow this, some weird bug like this might happen: SOLVED: WooCommerce Single Product Template wrong product image when query loop is present
If you place the Add to cart element outside of a loop, in a single product template, for example, then the quantity field will be output together with the add-to-cart form.
However, if you want to show the quantity in a woo loop (e.g. the shop/category archive), you can use this official WooCommerce filter: Override loop template and show quantities next to add to cart buttons. - WooCommerce
Best regards,
timmse
Thanks for the tip, but unfortunately this WC snippet does not work as it should The quantity field doesn’t show up in the product archives. As I understand it, this is due to the fact that it depends on the cart button, while this button is already displayed in Bricks as an independent element.
Maybe there’s a way to add a quantity field for the button through Bricks filters? It’s very missing next to the button in the products archive. In practice customers actively use this field without going to the product card.
Also, if I manually assemble the product card to display in the list, the {woo_add_to_cart} tag doesn’t display the quantity field.
Woocommerce has a lot of weird flaws that have been working in other e-commerce solutions for a long time. The quantity field in archives is one of them.
Hi @parktechno
Yes, the snippet is unable to use on dynamic tag {woo_add_to_cart}, because Bricks sanitized/skipped some HTML tags.
Already recorded this in the bug tracker for review.
Additionally, you should use Add to Cart element or a Basic Text element with {woo_add_to_cart} in it (Can’t use this in current Bricks as mentioned above).
Your current way, which uses a normal button element, and place {woo_add_to_cart} on the link field is not right. It only tells Bricks to use the ?add_to_cart=product_id
as the href value. Imagine if the woocommerce_loop_add_to_cart_link
adds a chunk of HTML and place it into href attribute, the HTML gonna be broken. Hope this explains the problem.
And this is the amended snippet that should work on the Add to Cart element in the loop.
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() ) {
$new_html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
$new_html .= woocommerce_quantity_input( array(), $product, false );
$new_html .= $html;
$new_html .= '</form>';
return $new_html;
}
return $html;
}
Regards,
Jenn
Hi, @itchycode
Thanks for the detailed response. Let’s get to the bottom of how it works and why something works and something doesn’t.
This filter is designed to modify WC layouts that are set by default without modification by third-party plugins. It should work. But if we go this way, we’ll have to manually write all styles for default WC layouts. Also moving elements around in the layout would be problematic. Again, this can be done through filters and hooks on standard layouts. But then the question arises - why do we need a visual builder if we can do without it?
Elementor, as far as I know, has dealt well with all the WC elements so that we can flexibly customize layouts and that’s the right thing to do. But, I gave up on elementor because of their policy of ignoring community opinions. For example, for three(!) years they refused to expand breakpoint functionality and didn’t want to listen to users on this issue - there were thousands of posts on the github about it. Also, the elementor creates a lot of garbage, which has a very negative impact on SEO.
As I see it, a visual builder should provide flexibility not only for creating nice-looking landing pages, but also for more complex layouts, including WC. A strong advantage of Bricks is that it has many of the right and necessary tools to solve complex problems. But working with WC is not yet full-fledged, in my opinion. It’s clear that modified standard WC elements are hard to keep up to date, but some compromise has to be found anyway. Otherwise we’ll have stores that don’t work the way we want them to. And I don’t personally want it to work, but the customers who are not interested in the technical side of the question. They either go the way of buying at our site without any problems or go to another store where everything works simply and clearly.
In the next post I will write my approach to creating the layout of the product card in the list, so that there is an understanding of what I’m trying to do.
Thank you, all makes sense and now I understand the reasoning I have made changes accordingly.
Thank you!!! It works
I replaced the base element of the button, which I customized manually, with the wc add to cart button element and everything worked.