Product Price Shortcode
-
Good afternoon,
Do you have a shortcode to display the price of a product using it’s ID please?
I was using this code:
add_shortcode( 'cl_product_price', 'cl_woo_product_price_shortcode' ); /** * Shortcode WooCommerce Product Price. * */ function cl_woo_product_price_shortcode( $atts ) { $atts = shortcode_atts( array( 'id' => null ), $atts, 'cl_product_price' ); if ( empty( $atts[ 'id' ] ) ) { return ''; } $product = wc_get_product( $atts['id'] ); if ( ! $product ) { return ''; } return $product->get_price_html(); }
However it has recently stopped working and I figured you guys would know how best to create a new shortcode. Thank you so much!
The page I need help with: [log in to see the link]
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Product Price Shortcode’ is closed to new replies.