Woocommerce Show $ Discount next to Price on Variable Products
-
Hi,
Up until around wc 2.1 we used to be able to show under the price on both the category pages and product page “Save $xx Off RRP” with the following code in our functions.php.
Around the time of WC 2.1 this code no longer works – can someone assist me in getting it working for WC 2.5 ?
add_filter( 'woocommerce_variable_sale_price_html', 'woocommerce_custom_variable_sales_price', 10, 2 ); function woocommerce_custom_variable_sales_price( $price, $variable ) { $reg_price = get_post_meta( $variable->children[0], '_regular_price', true ); $sale_price = get_post_meta( $variable->children[0], '_sale_price', true ); $percentage = round( $reg_price - $sale_price ,2 ); return $price . sprintf( __(' <br /><span class="price_save">SAVE $%s', 'woocommerce' ), $percentage . ' OFF RRP</span>' ); }
Please Help
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Woocommerce Show $ Discount next to Price on Variable Products’ is closed to new replies.