How to set all of notice below “Add to cart”?
-
Hello,
By default, it seems that all of notices is showing up above attributes, is there an code snippet to enable show up below the “Add to cart” button?
Thanks
-
Hi @alexliii,
Thank you for contacting us. We would be happy to assist you.
This issue seems more of a theme issue to me. The way plugin works is that the notice is hooked to a location on the WooCommerce product page which is set to show after the product price by default. WordPress hook priority controls the display order. I am assuming that the theme used on your WordPress WooCommerce setup has modified the single product template in one way or another. This should be causing the notices to be displayed elsewhere on the page.For now you can add the custom code to achieve this. See below(tested on staging environment):
- To display global notice after the Add to Cart button, add this:
remove_action( 'woocommerce_single_product_summary', 'crwcpn_global_product_notice_top', 12 ); add_action( 'woocommerce_after_add_to_cart_button', 'crwcpn_global_product_notice_top' );
- To display product notice after the Add to Cart button, add this:
remove_action( 'woocommerce_single_product_summary', 'crwcpn_product_notice_top', 12 ); add_action( 'woocommerce_after_add_to_cart_button', 'crwcpn_product_notice_top' );
- To display more than one global and product notice after the Add to Cart button, add this:
remove_action( 'woocommerce_single_product_summary', 'crwcpn_product_notice_display', 12 ); add_action( 'woocommerce_after_add_to_cart_button', 'crwcpn_product_notice_display' );
You can practically hook the functions crwcpn_global_product_notice_top , crwcpn_product_notice_top and crwcpn_product_notice_display to any of the available hook locations on the WooCommerce product page. See this page for visual hook guide reference: https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/.
You would need to add the code to your theme’s functions.php (preferably a child theme) or use a plugin like WP Designer or Code Snippets to add the custom code to your website.
If the above solution doesn’t work for you or does not give the desired results, please provide us with more information about your website’s setup so that we can better assist you. This information should include (and is not limited to) your website’s PHP version, WordPress version, current theme name with version, and any active WooCommerce extensions. This will help us troubleshoot the issue in a quick and efficient manner.
Looking forward to making your WooCommerce store experience better. Thanks.
It works well.
Great thanks.
I set to display more than one global and product notice after the Add to Cart button:
remove_action( 'woocommerce_single_product_summary', 'crwcpn_product_notice_display', 12 ); add_action( 'woocommerce_after_add_to_cart_button', 'crwcpn_product_notice_display' );
The way plugin works is that the notice is hooked to a location on the WooCommerce product page which is set to show after the product price by default
The reason why I set it below “Add to button”, is that the button will out of screen area if there are several product attributes, for example, Color, Material, Size, etc.
The button of Add to cart will be out of viewpoint of screen because of height of attributes.
Here is a screenshot for you to understand what I mean: https://prnt.sc/rX1dhuUSkAxh
So, What I suggest is put it always after “Add to cart” by default, but not after price if you like.
Thanks so much.
Hello,
I just noted that it works on Pc mode, but, does not work on mobile mode, could you optimize the code snippet and make it works on mobile mode too?
We are using this theme and product layout setting as this page at https://savoy.nordicmade.com/product/eco-body-lotion/?pgallery=scroll
Thanks
- This reply was modified 1 year, 9 months ago by alexliii.
Hello @alexliii,
I would like to inform you the notices are rendering correctly after the Add to Cart button and functioning seamlessly on both mobile and PC mode.
In order to troubleshoot the issue you’re experiencing, I recommend trying to access the website in incognito mode. If the notice still fails to render properly, it is possible that the issue may be related to your website’s cache. I suggest clearing the cache and attempting to access the website once more.
Please keep us informed on whether or not this solution resolves the issue. If the issue persists, kindly provide us with your website URL so that we may further investigate.
Thank you
Thanks, it works, th issue on mobile is because of cache.
- The topic ‘How to set all of notice below “Add to cart”?’ is closed to new replies.