Code to get product image, availability and description in woocommerce

I am working on a woo commerce project in which I want to show product image, availability, description and add to card.

I used the short code [product id="1234"], but it shows the whole product details – I just want to show the product image, availability and description.

Read More

Is there any short code or other code to get them?

Related posts

1 comment

  1. Try This:

    <?php 
        $product_DI = 1234; //Product ID
        $pro = new WC_Product($product_DI);
    
        echo "<b>price: </b>".$pro->get_price();      /// Get price
        echo "<b>availability Stock: </b>".$pro->get_total_stock();   //Get number of  availability
        echo "<b>availability Status: </b>".$pro->is_in_stock( );  //Get availability Status
        echo "<b>Image: </b>".$pro->get_image($size = 'shop_thumbnail');  //Get Image
        echo "<b>Title: </b>".$pro->get_title();  //Get Title
        echo "<b>description: </b>".$pro->get_post_data()->post_excerpt;  //Get description 
    
    ?>
    

Comments are closed.