Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function you_save_echo_product() {
- global $product;
- // works for Simple and Variable type
- $regular_price = get_post_meta( $product->get_id(), '_regular_price', true ); // 36.32
- $sale_price = get_post_meta( $product->get_id(), '_sale_price', true ); // 24.99
- if( !empty($sale_price) ) {
- $saved_amount = $regular_price - $sale_price;
- $currency_symbol = get_woocommerce_currency_symbol();
- $percentage = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
- ?>
- <p id="saving_total_price">You Save: <span class="symbol"><?php echo $currency_symbol; ?></span> <span class="amount"><?php echo $saved_amount; ?></span>.00</p>
- <?php
- }
- }
- //add_action( 'woocommerce_single_product_summary', 'you_save_echo_product', 11 );
- add_filter('woocommerce_get_price_html', function($price,$product){
- ob_start();
- you_save_echo_product();
- $save = ob_get_clean();
- return $price.$save;
- },10,2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement