Can I apply mathematic formula on values from shortcodes?
-
Hi,
I have a shortcode for displaying the price of a product (variant) → [woocommerce_price id=”XXXX”]. I use it in text and in some pricing tables.
I have monthly and yearly subscriptions.
I ould love to compare the monthly prices next to each other, so the discount for yearly is more prominent.
Is it possible to create another shortcode that divides [woocommerce_price id=”XXXX”] by 12?
This is my current shortcoode
function so_30165014_price_shortcode_callback( $atts ) { $atts = shortcode_atts( array( 'id' => null, ), $atts, 'bartag' ); $html = ''; if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){ $_product = wc_get_product( $atts['id'] ); $html = "€ = " . $_product->get_price(); } return $html; } add_shortcode( 'woocommerce_price', 'so_30165014_price_shortcode_callback' );
Thanks in advanced!
– Jan
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Can I apply mathematic formula on values from shortcodes?’ is closed to new replies.