Woocommerce how do I add an “Add to cart” button in content-widget-product.php

I am looking to add the “add to cart” button in the woo commerce content-widget-product that is called from the woocommerce widget..

Here is the code now

Read More
<?php global $product; ?>
<li>
<a href="<?php echo esc_url( get_permalink( $product->id ) ); ?>" title="<?php echo esc_attr( $product->get_title() ); ?>">
    <?php echo $product->get_image(); ?>
    <span class="product-title"><?php echo $product->get_title(); ?></span>
</a>
<?php if ( ! empty( $show_rating ) ) echo $product->get_rating_html(); ?>
<?php echo $product->get_price_html(); ?>


</li>

Any ideas what I would need to add to put the add to cart button in? Im looking EVERYWHERE and dying here

Related posts

2 comments

  1. Here is how you can add “add to cart” button with this code :

     global $product;
     $product_id = $product->id;
     echo do_shortcode('[add_to_cart id="'.$product_id.'"]');
    

Comments are closed.