Reputation: 1123
Im building a short code to display product info when passed with an ID, Ive got the title and image working but the description is the one Im having trouble with.
function wcproductslider($atts) {
$a = shortcode_atts( array(
'product' => '98',
), $atts );
$product_ID = $a['product'];
$pro = new WC_Product($product_ID);
$ret = "<b>Title: </b>".$pro->get_title() . "<br>";
$ret .= "<b>Image: </b><br> <a href=' " .$pro->get_permalink() . " '>".$pro->get_image($size = 'shop_thumbnail') . "</a><br>";
$ret .= "<b>Long Description: </b>" . $pro->post->post_content;
$ret .= "<b>Short description: </b>" . $pro->post->post_excerpt;
return $ret;
}
I managed to figure some of it out using wc product class but theres nothing about the product excerpt.
Any ideas would be greatly appreciated.
Upvotes: 2
Views: 9803
Reputation: 1123
Figured it out, didn't put anything in my short description of the product.
Long Description
$pro->post->post_content;
Short Description
$pro->post->post_excerpt;
Upvotes: 1