- This topic has 55 replies, 5 voices, and was last updated 3 years, 10 months ago by
Leo.
-
AuthorPosts
-
June 21, 2022 at 2:55 pm #2260564
Ying
StaffCustomer SupportAre you using this function?
add_action( 'woocommerce_after_quantity_input_field', 'bbloomer_display_quantity_plus' ); function bbloomer_display_quantity_plus() { echo '<button type="button" class="plus">+</button>'; } add_action( 'woocommerce_before_quantity_input_field', 'bbloomer_display_quantity_minus' ); function bbloomer_display_quantity_minus() { echo '<button type="button" class="minus">-</button>'; }If so, you can try using two hook elements instead, so that you can set the location to
product.1. Go to appearance > elements, and create a new hook element.
2. Add this to the content area:
for hook 1:<button type="button" class="plus">+</button>
for hook 2: <button type=”button” class=”minus”>-</button>3. Choose custom hook, enter:
for hook 1:woocommerce_after_quantity_input_field.
for hook 2:woocommerce_before_quantity_input_field4. Choose
products > all productsas the location.June 21, 2022 at 3:03 pm #2260569GeneratePressUser
Hello Ying,
OK, I have disabled those functions script and added the 2 hooks, now I guess I need to add this script:
add_action( 'wp_footer', 'add_cart_quantity_plus_minus' ); function add_cart_quantity_plus_minus() { if ( ! is_product() && ! is_cart() ) return; wc_enqueue_js( " $(document).on( 'click', 'button.plus, button.minus', function() { var qty = $( this ).parent( '.quantity' ).find( '.qty' ); var val = parseFloat(qty.val()); var max = parseFloat(qty.attr( 'max' )); var min = parseFloat(qty.attr( 'min' )); var step = parseFloat(qty.attr( 'step' )); if ( $( this ).is( '.plus' ) ) { if ( max && ( max <= val ) ) { qty.val( max ).change(); } else { qty.val( val + step ).change(); } } else { if ( min && ( min >= val ) ) { qty.val( min ).change(); } else if ( val > 1 ) { qty.val( val - step ).change(); } } }); " ); }Right?
June 21, 2022 at 3:09 pm #2260574Ying
StaffCustomer SupportYes, correct.
June 21, 2022 at 3:18 pm #2260587GeneratePressUser
Seems the minus button is not working.
Btw I would like to also tell 1 conflict which your theme settings have with elementor, see the private box.June 21, 2022 at 10:01 pm #2260730Fernando Customer Support
Hello there,
Can you try this for minus:
<button type="button" class="minus">-</button>As for the conflict, to clarify, do you have Display Quantity buttons turned off in Appearance > Customize > Layout > WooCommerce > Single Product as such: https://share.getcloudapp.com/llu09oje when you turn on Show Quantity in Elementor?
Kindly let us know.
June 22, 2022 at 8:03 am #2261405GeneratePressUser
Hello Fernando,
That’s the same what Ying gave and I am already using that for minus.
June 22, 2022 at 4:21 pm #2261768Ying
StaffCustomer SupportIf you are going to use Elementor’s custom add-to cart, it’s better not to load GP’s style at the same time.
Otherwise to have style conflicts is inevitable.
June 22, 2022 at 4:40 pm #2261771GeneratePressUser
Hey Ying,
Got it, so if we use that the cart page buttons will also go away coz they don’t come from elementor and they come from generatepress.
So, if we keep using the current normal woocommerce add to cart widget in elementor instead of custom add to cart then the buttons are not there on single product page, but on using custom add to cart widget button comes can u pls tell why is generatepress not showing buttons on using the normal woocommerce widget of elementor? coz we suppose that is loading from default woocommerce maybe we are not sure.
If we don’t use that and want to disable generatepress buttons totally and just add the buttons manually then we are able to add them on single product but can’t see it on cart page, any idea how that can be done?
The code which u told me to put in elements didn’t work for minus button, on clicking it nothing used to happen.
June 22, 2022 at 4:46 pm #2261775Ying
StaffCustomer SupportSo, if we keep using the current normal woocommerce add to cart widget in elementor instead of custom add to cart then the buttons are not there on single product page, but on using custom add to cart widget button comes can u pls tell why is generatepress not showing buttons on using the normal woocommerce widget of elementor? coz we suppose that is loading from default woocommerce maybe we are not sure.
I have to see the live site with error to be able to tell.
And can we focus on one question at a time? I am kind of lost in this topic.
I’ve got confused about what you were originally trying to achieve…
June 22, 2022 at 4:46 pm #2261776GeneratePressUser
Hey Ying,
Ok, so right now we have disabled Generate Press buttons and have used the businessbloomer script:
https://www.businessbloomer.com/woocommerce-add-plus-minus-buttons-to-add-to-cart-quantity-input/
So, it works perfectly on single product page (see the private box)
June 22, 2022 at 4:48 pm #2261777Ying
StaffCustomer SupportAm I missing something?
The messed up doesn’t show on my end:
[screenshots removed]June 22, 2022 at 4:48 pm #2261778GeneratePressUser
Hey Ying,
Ok, so do u want me to keep using the businessbloomer script or just enable the elements method which u told me to add those plus and minus buttons?
June 22, 2022 at 4:52 pm #2261780GeneratePressUser
I just checked it using safari browser and its showing properly there, but on brave browser its not showing proper weird.
which browser are u using?
June 22, 2022 at 4:52 pm #2261781Ying
StaffCustomer SupportI’m using Chrome. It seems when the screen gets narrower, the issue shows.
Try this CSS:
.woocommerce-cart td.product-quantity .quantity { display: flex; } @media (max-width: 768px) { .woocommerce-cart td.product-quantity .quantity { justify-content: flex-end; } }June 22, 2022 at 4:56 pm #2261784GeneratePressUser
Hey Ying,
That’s perfect, so do u recommend keep using the businessbloomer code? or should we achieve this using elements hook which you had shared?
Let me know if you want me to disable this and enable the elements so that you will be able to even see the error which happens on clicking Minus button.
-
AuthorPosts
- The topic ‘Align Quantity and Add to Cart Buttons on Single Product Page’ is closed to new replies.