## How to display before and after price on product page

Question

So, i am wanting to have on my product page the before and after price. So basically, it has the before price with a line through it and then the new price.

This is the code i have, but for some reason it doesn’t work.

Any help would be appreciated

add_filter( 'woocommerce_get_price_html', 'ts_custom_price', 10, 2 );


function ts_custom_price($product) {​​​​​​​ if($product != null){​​​​​​​
if($product->is_on_sale()){​​​​​​​ if($product->is_type('simple') || $product->is_type('external') ||$product->is_type('grouped')) {​​​​​​​
$regular_price = get_post_meta($product->get_id(), '_regular_price', true );
$sale_price = get_post_meta($product->get_id(), '_sale_price', true );

if(!empty($sale_price)) {​​​​​​​ echo '<p class="custom_text"> <del> £'.$regular_price.' </del> £'.\$sale_price.'</p>';
}​​​​​​​
}​​​​​​​
}​​​​​​​
}​​​​​​​


}​​​​​​​

0
2 years 2020-10-26T04:10:25-05:00 0 Answers 15 views 0