Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #3600554
Price By User Role - Original Price Strikethrough
Open

Comments

  •  2
    Nicole Fende started the conversation

    *I'm using the paid plugin*

    How do I get the Regular User Role price to show up AND the original Public price to show with a strikethrough?

    For example, let's say the public price is $20 and the regular price for a specific user is $18. How do I get the the $20 to show as a strikethrough and the user price to show up.

    Please note I do NOT want to mark them as on sale.  Otherwise most of my items would show up as "on sale" for logged in members and would completely lose it's value.

    Thanks!

  •  2
    Nicole Fende replied

    Alternately, is there a way to turn off the "Sale" marker? Then I would get what I want in display.

  •  1,224
    Dustin replied

    Hi Nicole,

    Please add the custom code below. (How do you add a custom code?):

    add_filter( 'woocommerce_get_price_html', function ( $price_html, $product ) {
        if ( ! $product->is_on_sale() && class_exists( 'Wpcpu_Helper' ) ) {
            $price_role = Wpcpu_Helper()::get_price_role( $product );
            if ( ! empty( $price_role ) && ( $price_role['regular'] !== '' ) && ( $price_role['regular'] !== '100%' ) ) {
                $regular_price_ori  = $product->get_regular_price( 'edit' );
                $regular_price_role = Wpcpu_Helper()::format_price( $price_role['regular'], $regular_price_ori );
                return wc_format_sale_price( wc_price( $regular_price_ori ), wc_price( $regular_price_role ) );
            }
        }
        return $price_html;
    }, 999, 2 );

    Then, products will have strike-through prices but won't show the sale badge.

    Best regards,
    Dustin

  •  2
    Nicole Fende replied

    Hi Dustin,

    I added to my website using the  recommended plugin Code Snippets. Unfortunately it had no affect.