WooCommerce custom add to cart buttons does not add products to cart if you’re logged out

To display specific products with their add-to-cart buttons on the homepage of a Wp site you can use a shortcode to display specific products. you can use the [display_specific_products ids=”1,2,3″] shortcode in your home pages, or widgets to display the specified products with their add-to-cart buttons. Replace 1,2,3 with the actual IDs of the products … Read more

Custom add to cart does not work well only on the first time

You can use the shortcodes provided by WooCommerce. To get the whole button with your custom class and AJAX functionalities.. <?php echo do_shortcode(‘[add_to_cart id=”‘ . get_the_ID() . ‘” class=”add_to_cart_button btn btn-outline-primary btn-lg”]’);?> Or, just the URL to use with your custom button. <a href=”<?php echo do_shortcode(‘[add_to_cart_url id=”‘ . get_the_ID() . ‘”]’);?>” class=”add_to_cart_button btn btn-outline-primary btn-lg”>Přidat … Read more