Show MSRP Price in WooCommerce WP-Lister for Amazon

WordPress

If you use the WP Lister for Amazon plugin you are able to set a custom MSRP price for products. But these do not show as stroke trough price if you enter a regular or sale price.

Add the below code into your functions.php and the regular price will always show the MSRP price if set.

/**
Change on sale to true if MSRP is set, otherwise price only shows regular
**/
add_filter( 'woocommerce_product_is_on_sale', 'we_msrp_on_sale', 10, 1);
function we_msrp_on_sale($onsale) {

    global $product;
    if(!$product) {
        return $onsale;
    }

    $rrp = get_post_meta( $product->get_id(), '_msrp_price', true );
    if($rrp) {
        $price = $product->get_regular_price();
        $onsale = true;
    }

    $variable_rrp = get_post_meta( $product->get_id(), 'variable_msrp', true );
    if($variable_rrp) {
        $price = $variable_rrp;
        $onsale = true;
    }

    return $onsale;
}

/**
Sale price will be regular price if msrp is set
**/
add_filter( 'woocommerce_product_get_sale_price', 'we_msrp_sale_price', 10, 1);
function we_msrp_sale_price($price) {
    global $product;
    if(!$product) {
        return $price;
    }

    $rrp = get_post_meta( $product->get_id(), '_msrp_price', true );
    if($rrp) {
        $price = $product->get_regular_price();
    }

    $variable_rrp = get_post_meta( $product->get_id(), 'variable_msrp', true );
    if($variable_rrp) {
        $price = $variable_rrp;
    }

    return $price;
}

/**

**/
add_filter( 'woocommerce_product_get_regular_price', 'we_msrp_price', 10, 1);
function we_msrp_price($price) {

    global $product;
    if(!$product) {
        return $price;
    }

    $rrp = get_post_meta( $product->get_id(), '_msrp_price', true );
    if($rrp) {
        $price = $rrp;
    }

    $variable_rrp = get_post_meta( $product->get_id(), 'variable_msrp', true );
    if($variable_rrp) {
        $price = $variable_rrp;
    }

    return $price;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

We use cookies to give you the best online experience. By agreeing you accept the use of cookies in accordance with our cookie policy.

Close Popup
Privacy Settings saved!
Privacy Settings

When you visit any web site, it may store or retrieve information on your browser, mostly in the form of cookies. Control your personal Cookie Services here.

These cookies are necessary for the website to function and cannot be switched off in our systems.

Technical Cookies
In order to use this website we use the following technically required cookies
  • wordpress_test_cookie
  • wordpress_logged_in_
  • wordpress_sec

Decline all Services
Save
Accept all Services