I’m trying to create a bit of shortcode that would allow me to display what my product price would be after multiplying it by .2 but I haven’t much understanding of php
The Shortcode script seems to basically be
function wpc_elementor_shortcode( $atts ) {
}
add_shortcode( 'my_elementor_php_output', 'wpc_elementor_shortcode');
Where the actual content I want to add would be inbetween the brackets
The content seems to be in the wheel house of this code
$product_id = 99;
$product = wc_get_product( $product_id );
echo $product->get_price_html();
Which I’m told would simply display the price of the product. What I would like to know is how I can take whatever number “get_price_htnml(); produces and multiply it by .2 and have that result displayed by my shortcode script.
It’s not proper code, but I would think something to the effect of
$sum = get_price_html() * .2
echo $sum
Is what I would do if php was a lot simpler.
I also am uncertain about having the product id set to 99, the post I got the code from said that I needed to create a product object just to use the get_price_html code, but the shortcode would need to be responsive to the single product it was added to, it can’t keep calling to product id 99’s price one very page it’s on
Sorry that this is a mess, I mostly code css but need to add this one bit of php to make my life a whole lot easier