The Manufacturer’s Suggested Retail Price (MSRP) is the price that a manufacturer recommends retailers sell a product for. You’ve probably seen this tactic in ads or flyers: “MSRP: $140. Our price: $99 only!”
Displaying the MSRP alongside your actual selling price shows customers the savings they are getting, and this can boost conversion rates in your store.
In this post, we’ll add a custom MSRP field to the WooCommerce product editor, save it securely, and display it on the product page for your customers to see.
I’ve already written in detail about adding custom fields to WooCommerce products, so we won’t go into the basics here. Instead, we’ll focus specifically on adding an MSRP field to the pricing section.
Adding an MSRP Field to the WooCommerce Product Page
The code consists of three parts: adding the input field to the product editor, saving the value to the database, and displaying it on the product page. Add the following code to the functions.php file in your theme (preferably, use a child theme).
// -----------------------------------------
// 1. Add MSRP field input at product edit page
function savvy_add_msrp_to_products() {
global $product_object;
woocommerce_wp_text_input( array(
'id' => '_msrp',
'value' => $product_object->get_meta( '_msrp', true, 'edit' ),
'class' => 'short wc_input_price',
'label' => __( 'MSRP', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')',
'data_type' => 'price',
)
);
}
add_action( 'woocommerce_product_options_pricing', 'savvy_add_msrp_to_products' );
// -----------------------------------------
// 2. Save MSRP field via product object (WooCommerce CRUD)
function savvy_save_msrp( $product ) {
if ( isset( $_POST['_msrp'] ) ) {
$product->update_meta_data( '_msrp', wc_clean( wp_unslash( $_POST['_msrp'] ) ) );
}
}
add_action( 'woocommerce_admin_process_product_object', 'savvy_save_msrp' );
// -----------------------------------------
// 3. Display MSRP field at single product page
function savvy_display_msrp() {
global $product;
if ( $product->get_type() !== 'variable' && $msrp = $product->get_meta( '_msrp', true ) ) {
echo '<div class="woocommerce_msrp">';
_e( 'MSRP: ', 'woocommerce' );
echo '<span>' . wc_price( $msrp ) . '</span>';
echo '</div>';
}
}
add_action( 'woocommerce_single_product_summary', 'savvy_display_msrp', 9 );Let’s break down what each part does.
The first function hooks into woocommerce_product_options_pricing to add a text input field in the “General” product data tab, right next to the regular and sale price fields. It uses the $product_object global to read the current value when editing an existing product.
The second function saves the MSRP value when the product is saved. It hooks into woocommerce_admin_process_product_object and uses the WooCommerce CRUD method update_meta_data() to store the value.
The code uses the woocommerce_admin_process_product_object hook instead of the generic save_post hook. This is important because save_post fires in many contexts (auto-drafts, revisions, XML-RPC requests) and can cause unintended side effects. The input is also sanitized with wc_clean() and wp_unslash() for security.
The third function displays the MSRP on the single product page. Notice the condition that excludes variable products since their variations may have different prices. You can remove this condition if you prefer, but keep in mind it might be misleading for products with varying prices across variations.
Styling the MSRP Display
To make the MSRP stand out to customers, add the following CSS to your theme’s stylesheet:
.woocommerce_msrp {
font-size: 14px;
color: #777;
margin-bottom: 10px;
}
.woocommerce_msrp span {
text-decoration: line-through;
}The text-decoration: line-through adds a strikethrough on the suggested price, making it clear to customers that your price is lower than the manufacturer’s recommendation. Adjust the styles to match your store’s design.
Adding MSRP to Variable Products
If you want to display the MSRP for variable products as well, you’ll need to add the MSRP field at the variation level. Here is the code:
// Add MSRP field to each variation
function savvy_add_msrp_to_variations( $loop, $variation_data, $variation ) {
woocommerce_wp_text_input( array(
'id' => '_msrp_variation[' . $loop . ']',
'value' => get_post_meta( $variation->ID, '_msrp', true ),
'class' => 'short wc_input_price',
'label' => __( 'MSRP', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')',
'data_type' => 'price',
'wrapper_class' => 'form-row form-row-first',
));
}
add_action( 'woocommerce_variation_options_pricing', 'savvy_add_msrp_to_variations', 10, 3 );
// Save MSRP field for each variation
function savvy_save_msrp_variation( $variation_id, $i ) {
if ( isset( $_POST['_msrp_variation'][ $i ] ) ) {
update_post_meta( $variation_id, '_msrp', wc_clean( wp_unslash( $_POST['_msrp_variation'][ $i ] ) ) );
}
}
add_action( 'woocommerce_save_product_variation', 'savvy_save_msrp_variation', 10, 2 );Each variation gets its own MSRP field, so you can set a different manufacturer’s price for each variation.
FAQs
Common questions about displaying the MSRP in WooCommerce:
save_post hook fires every time WordPress saves a post, including auto-drafts, revisions, and XML-RPC requests. This can lead to unwanted saves and security issues. The woocommerce_admin_process_product_object hook fires only when a product is saved through the WooCommerce admin interface, making it more secure and predictable.woocommerce_single_product_summary hook, use woocommerce_after_shop_loop_item_title with an appropriate priority. The display function itself stays the same - just change the add_action line.register_rest_field or use the woocommerce_rest_prepare_product_object filter.Summary
Adding an MSRP field to your WooCommerce store is a simple and effective way to show customers they are getting a better deal. The code in this guide uses the modern WooCommerce CRUD methods and proper input sanitization. To learn more about customizing WooCommerce with hooks, check out our guide to WooCommerce hooks.
If you need help or have any questions, feel free to ask in the comments. Good luck!

