-
-
Save kloon/e27f982015a9819b04b6 to your computer and use it in GitHub Desktop.
RRP Price Tutorial - Display price on frontend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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