/** * Create a shortcode to add a specific product price */ // Creates a shortcode so that a product price can be inserted into any page or post. // The shortcode takes the id as the parameter // https://wpbeaches.com/add-woocommerce-product-price-as-a-shortcode/ add_shortcode('cl_product_price', 'cc_product_price_shortcode'); function cc_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(); }