Skip to content

Instantly share code, notes, and snippets.

@kloon
Last active December 23, 2015 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kloon/e27f982015a9819b04b6 to your computer and use it in GitHub Desktop.
Save kloon/e27f982015a9819b04b6 to your computer and use it in GitHub Desktop.
RRP Price Tutorial - Display price on frontend
add_action( 'woocommerce_single_product_summary', 'wc_rrp_show', 5 );
function wc_rrp_show() {
global $product;
// Do not show this on variable products
if ( $product->product_type <> 'variable' ) {
$rrp = get_post_meta( $product->id, 'rrp_price', true );
echo '<div class="woocommerce_msrp">';
_e( 'RRP: ', 'woocommerce' );
echo '<span class="woocommerce-rrp-price">' . woocommerce_price( $rrp ) . '</span>';
echo '</div>';
}
}
// Optional: To show on archive pages
add_action( 'woocommerce_after_shop_loop_item_title', 'wc_rrp_show' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment