I am using woocommerce to develop a ecommerce site
In single-product.php I am facing a problem.
I can’t display the add to cart button under the product in this page.
So far I am using this code:
<?php
//global $post;
echo do_shortcode('[add_to_cart id="$post->ID"]');
?>
But no luck for me yet!
Maybe you made a simple writing mistake? Try this:
I would suggest using the WooCommerce default
content-single-product.php
template.By default, the single product’s add to cart template is added via the
woocommerce_template_single_add_to_cart()
function and is added to thewoocommerce_single_product_summary
hook (priority 30).If you must change the single product content very radically, you can either call
woocommerce_template_single_add_to_cart()
directly or add it to a different hook. There’s no reason to use a shortcode here.If I understood you right, you want to move the Add-to-Cart button from the top of the page to the bottom of the page, so that it would go below the main product description.
Here is how I’ve done this on my website: