Need help with custom shortcode
-
I am trying to make a shortcode to use on a pricing table that automatically updates the price. I have this so far…
//DISPLAY PRODUCT PRICE SHORTCODE function display_price( $atts ) { $atts = shortcode_atts( array('id' => null,), $atts, 'bartag' ); $_product = wc_get_product( $atts['id'] ); if( $is_on_sale == true){ $html = "<span style=\"color:grey; font-size:.6em;\"><s>" . "$" . $_product->get_variation_regular_price() . "</s></span> " . $_product->get_variation_sale_price() . "<span style=\"font-size:0.6em;\">/mo</span>"; return $html; } else { $html = $_product->get_variation_regular_price() . "<span style=\"font-size:0.6em;\">/mo</span>"; return $html; } } add_shortcode( 'woocommerce_price', 'display_price' );
I cant get it to work. It shows else no matter if its on sale or not.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Need help with custom shortcode’ is closed to new replies.