[Membership 2 Pro] Modify Price Display

We're looking to modify the price display on the Member List page, whenever the user select a membership or wants to change their membership.

Right now it says 'USD 1.00' but it neither displays the currency symbol or the subscription term ( yearly/monthly/weekly/etc. ). It does this via the below function:

get_ms_single_box_membership_price()

We've looked at this function but didn't see a place to hook into so we could modify the display. How can we modify the display of price via the membership_box_html.php template to display the currency symbol and the subscription term/length?

    • IQComputing

      Right, I'm looking for it to display the currency symbol. Dollar sign '$' instead of USD.

      Maybe it's because I'm in sandbox but It does not display "each month." Here's a screenshot of what we see when the user is changing subscriptions:

      It does display whenever they're prompted to check the details of their membership subscription but not when they're choosing their membership options.

      We could add in the subscription length to the subscription details but would rather it be generated ( or we can pull it via method in the box_html template ) similar to how it currently is on the details page.

      So in short, whenever displaying subscriptions prices we would like to display the currency symbol ( '$' instead of 'USD' ) and whenever listing subscription options we're looking to display the subscription length.

      • Ash

        Hello IQComputing

        Please try the following code:

        add_filter( 'ms_membership_price', function( $price, $membership ) {
        	return str_replace( 'USD ', '$', $price ) . ' each ' . MS_Helper_Period::get_period_desc( $membership->pay_cycle_period );
        }, 99, 2 );

        You can use this code in your child theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

        Hope it helps! Please feel free to ask more questions if you have any.

        Have a nice day!

        Cheers,
        Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.