Public Ticket #3029544

Add to cart button issue

Closed
Comments
6 Tickets 1
Codeplayaz started the conversation 4 years ago on April 22, 2022 at 9:02am

I am trying to design the product template in Elementor.

Wherever I put the add to cart button with quantity select, it later adds the price tier table between the add to cart button itself and the like product heart without any margins. Just smashes it there , like its all ok. While I would like to have the table there as an element, I could not find any documentation how to affect its appearance. I am sure I missed something. I am using Woodmart theme as recommended. 

2,762
KingsPlugins replied 4 years ago on April 23, 2022 at 3:11pm

Hi there,

Thank you for purchasing our plugin,

We have not seen this issue with Woodmart usually, perhaps it has to do with the product template used with Elementor. Either way, it's a common issue that we can usually resolve by changing the insertion point where the table is added.

To do this, please try to add the following PHP code snippet to your site:

global $b2bking_public;
remove_action('woocommerce_after_add_to_cart_button', array($b2bking_public,'b2bking_show_tiered_pricing_table'));
add_action('woocommerce_after_add_to_cart_form', array($b2bking_public,'b2bking_show_tiered_pricing_table'));

A PHP snippet can be added to functions.php, or by following our guide here: https://b2bkingplugin.com/docs/how-to-add-a-snippet-php-or-js/

If that doesn't do it, I suggest you try to replace 'woocommerce_after_add_to_cart_form' with 'woocommerce_product_meta_start' in the above snippet.

We can also look into it directly for you if you'd like - for that, we'd need a backend login to your site or staging site.

Kind regards,

Stefan

6 Tickets 1
Codeplayaz replied 4 years ago on April 25, 2022 at 9:18pm

After adding that, second table appears below the first one (see attached picture). When I replace  'woocommerce_after_add_to_cart_form' with 'woocommerce_product_meta_start' in the code, the second table disappears but the first one is what I am trying to get rid of.

Wouldn't this kind of table make more sense as a shortcode, so I could put it where I need in my design and use Woocommerce quantity select button separately?

I would even be happy with a shortcode quantity select and add to cart button if that means shortcode table. Or at least clear and easily modifyable CSS hooks, so I could at modify it.

Anyways, it seems that with the snippet, removing the table is what is broken (the second line)


2,762
KingsPlugins replied 4 years ago on April 27, 2022 at 12:53am

Hi again,

I tested that code I sent you, but it seems to be able to remove it in my tests with WoodMart. I think the issue may have to do with how that snippet is added - in my tests I added it to functions.php

If you're using the snippets plugin, please try to replace the snippet with this:

add_action('wp_loaded', function(){    
    global $b2bking_public;    
    remove_action('woocommerce_after_add_to_cart_button', array($b2bking_public,'b2bking_show_tiered_pricing_table'));    
    add_action('woocommerce_after_add_to_cart_form', array($b2bking_public,'b2bking_show_tiered_pricing_table'));
});

Please try to clear caches if there are any.


We can certainly look at adding a shortcode for this - thanks for the feedback. In most cases we need to place it there by default because users are not usually designing their own product pages.

Actually it seems to work for me by default with woodmart, so I think it has to do with how Elementor places hooks.

6685195496.png

Let me know if the above can help,

2,762
KingsPlugins replied 4 years ago on May 17, 2022 at 4:56pm

I can immediately send you an update with shortcodes for the product information table, and for the tiered pricing table for simple products. 


However for variable products, it's more complicated - we usually insert it in the hook 'woocommerce_available_variation'. The table needs to be different for each variation, and it needs to change when the currently selected variation changes. So it wouldn't work to insert it statically through a shortcode. I'm not sure if the Elementor product page builder has any option that could help here. Hope that makes sense.

Sign In