How to Display MSRP Price on WooCommerce Shop Pages August 23 2012
The WooCommerce MSRP Pricing plugin allows you to set an MSRP price for your products and display it on the product page. But what if you want the MSRP displayed on the category/catalog/shop pages? The following is one solution, which will display the MSRP just before the regular product price in the catalog pages. You may need to do a little CSS style tweaking of the displayed MSRP price, depending on your theme and the look you want to achieve, but hopefully the example here will be enough to get you started. You can add this to your theme’s functions.php in the usual manner (theme-name/functions.php), or perhaps to your custom site plugin:
add_action( 'woocommerce_after_shop_loop_item_title', 'loop_item_msrp_price', 9 );
/**
* Display the MSRP price in the product loop
*/
function loop_item_msrp_price() {
global $product;
// MSRP pricing enabled?
$msrp_enabled = get_option( 'woocommerce_msrp_status', 'never' );
if ( $msrp_enabled == 'never' ) return;
// is the MSRP price set?
$msrp = get_post_meta( $product->id, '_msrp_price', true );
if ( empty( $msrp ) ) return;
// MSRP label
$msrp_label = get_option( 'woocommerce_msrp_description' );
// display the MSRP price
echo '' . ( $msrp_label ? esc_html__( $msrp_label ) . ': ' : '' ) . '' . woocommerce_price( $msrp ) . '';
}
Note: the above solution currently only supports simple products. It will not display an “MSRP From: $X” for variable products, not that it’s impossible to do so, it would just take some more code.
[affiliate_disclaimer]
The post How to Display MSRP Price on WooCommerce Shop Pages appeared first on SkyVerge.