Skip to content

Instantly share code, notes, and snippets.

@ChrisCree
Created April 9, 2014 05:15
Show Gist options
  • Save ChrisCree/10228143 to your computer and use it in GitHub Desktop.
Save ChrisCree/10228143 to your computer and use it in GitHub Desktop.
Function to show original non-sale price in WooCommerce cart.
<?php
// Do not copy opening PHP tag
// Show non sale product price in cart
add_filter( 'woocommerce_cart_item_price', 'wsm_show_nonsale_price', 10, 2 );
function wsm_show_nonsale_price( $newprice, $product ) {
$_product = $product['data'];
$saleprice = $_product->sale_price;
if ( $saleprice > 0 ) {
$newprice = '';
$newprice .= '<del><small style="color:#c9c9c9;">';
$newprice .= woocommerce_price( $_product->regular_price );
$newprice .= '</small></del> <strong>';
$newprice .= woocommerce_price( $_product->sale_price );
$newprice .= '</strong>';
return $newprice;
}
else {
$newprice = woocommerce_price( $_product->price );
return $newprice;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment