WooCommerce Remove <del> <ins> Tag and Show Regular Price Only

Friday, January 17, 2014 10:32 AM By Admin , In

Use following code to remove all inside <del> and <ins> tag and show regular price only.

Method:

  1. Copy code to your functions.php.

/* Remove tags   */
add_filter('woocommerce_get_price_html', 'bas_sale_price', 10, 2);
function bas_sale_price($price,$product){
 $price = '';
  if($product->price > 0){
   if($product->is_on_sale() && isset($product->regular_price)){
    $price .= woocommerce_price($product->get_price());
   }else{
    $price .= woocommerce_price($product->get_price());
   }
  }elseif($product->price === ''){
   $price = apply_filters('woocommerce_empty_price_html','',$product);
  }elseif($product->price == 0){
   if ($product->is_on_sale() && isset($product->regular_price)){
    $price .= $product->get_price_html_from_to($product->regular_price, __('Free!','woocommerce'));
   }else{
    $price  = __('Free!','woocommerce');
   }
  }
 return $price;
}

2 comments:

P. said...

Man, you saved me!

Thank you very much!

June 23, 2014 at 10:21 PM
Rudeboy said...

Thanks so much for sharing!

November 5, 2016 at 1:16 AM

Post a Comment