How do I offer separating pricing for premium members using marketpress?

Note- this is integration issue between membership and marketpress.

I have both running on my live site.
I need to have discounted pricing when a premium member sees my course offerings.
When a visitor (not logged in) or free trial member is on my site they see regular pricing.

Thanks

Mike

  • Mike

    @Jack and @Eugene- thanks for your replies. I know that Eugene has been working on the beta fixes to the product and I am appreciate his efforts; however my concern is that the issue I am raising has been out on the forum over 1 year now and I find that this request really should be a standard offering for a WPMU integrated product. The events+ product has the tie in to discounted pricing module to marketpress, it is disappointing that marketpress doesn't recognize membership or vice versa.

    Finally- Since I am now under pressure to find a workable solution in the next 4 days...
    Has anyone had success with this approach ?
    https://premium.wpmudev.org/forums/topic/marketpress-and-membership

    Or
    this approach.. yes I know the thread is dated but the concept
    https://premium.wpmudev.org/forums/topic/membership-11-beta

    I realize I could use the coupon option; however this is not my preferred because it simply is not very professional looking option when offering a discount on a $1,700 adult education course.

    Mike

  • Jack Kitterhing

    Hi there Mike,

    Hope you're well today, we are looking into this for a future version, in this case I've checked the other two links you've provided and honestly I don't believe that would be a workable solution in either.

    Both plugins have changed a lot since then, it may be worth trying but I couldn't say if that would still work, I believe my colleague @DavidM might have some ideas here, I'll include him for valuable input here.

    Thanks!

    Kind Regards
    Jack.

  • DavidM

    Hi @Mike,

    Hope all's going great for ya today! :slight_smile:

    I've been testing this slowly over time but now's a better time than any to really dig into it. The following would let you adjust pricing at the point where products get placed into the cart:

    function mp_membership_price_discount( $price ){
    	// check for existence of Membership plugin
    	if ( class_exists( 'M_Membership' ) ) {
    		// check if user is logged in
    		if ( is_user_logged_in() ){
    			$user_id = get_current_user_id();
    			$subscription = new M_Subscription( end( get_sub_by_user( $user_id ) )->sub_id );
    			// get subscription name for current user
    			$sub_name = $subscription->sub_name();
    			if ( $sub_name == 'Paid' ) {
    				return $price/2;
    			}
    		}
    	}
    	return $price;
    }
    
    add_filter( 'mp_product_price', 'mp_membership_price_discount' );

    If you'll let me know the following:
    1. The names of your subscriptions that will receive special pricing.
    2. The amount of discount you'd like for them to receive.

    I'll see about getting a that suited to work with those.

    How does that sound?

    Oh, and of course, it's easiest to add that with a plugin like this:
    http://wordpress.org/plugins/code-snippets/

    But you could add that to your theme's functions.php file or by creating a simply plugin like so:
    http://codex.wordpress.org/Writing_a_Plugin

    @Jack, thanks for the ping, I've been meaning to at least post this somewhere, hoping it'll help someone looking for custom pricing options.

    Cheers,
    David

  • Mike

    David- Thanks for the response.

    I will be setting up a 'Premium' Access Level membership. We want to offer a 10% discount on our courses (rounded to clean $--- this might be tricky )
    For example
    $1695 for non-members; $1525 for premium members (10% is actually $1525.50).
    If this becomes problematic.. flexibility may have to be key.

    Here is where it gets tricky-- As part of our annual (premium) membership, I have Web'n Learns and those will be free zero$ to them. Otherwise full retail pricing.

    I just happened to stumble here, did not see email notificat'n.

    Thanks for any help David-

    If need be, I can create admin. account.

    Mike

  • DavidM

    Hi @Mike,

    Thanks for confirming that. The following should work more specifically for that:

    function mp_membership_price_discount( $price ){
    	// check for existence of Membership plugin
    	if ( class_exists( 'M_Membership' ) ) {
    		// check if user is logged in
    		if ( is_user_logged_in() ){
    			$user_id = get_current_user_id();
    			$subscription = new M_Subscription( end( get_sub_by_user( $user_id ) )->sub_id );
    			// get subscription name for current user
    			$sub_name = $subscription->sub_name();
    			if ( $sub_name == 'Premium' ) {
    				return $price * 0.1;
    			}
    		}
    	}
    	return $price;
    }
    
    add_filter( 'mp_product_price', 'mp_membership_price_discount' );

    I'm not sure of the levels/subscriptions you've setup myself. That I understand from your description, "Premium" is the paid level we're considering here, correct?

    Thanks,
    David

  • Mike

    David- thanks for the code-

    I added an item to my cart and rec'd

    Fatal error: Call to undefined function get_sub_by_user() in /home/user/public_html/something/wp-content/themes/executive/functions.php on line 56

    Also, I only want to have a premium level membership but have two pricing models

    10% discount for courses

    and for product category web N Learn fyi slug project-mgmt-webinar
    100% discount aka free

    thanks

    Mike

  • DavidM

    Hi @Mike,

    Thanks for mentioning that. Really weird though, I had this working on a test site but I must have had that get_sub_by_user() function added somewhere else.

    To make this quicker for you, could I possibly set this up with you through an admin login and by way of email?

    I can then post the final snippet back here with some comments on it.

    If that's okay, you can simply send a message through here:
    https://premium.wpmudev.org/contact

    And you can select "I have another question".
    For the subject, "ATTN David"
    For the message you can include a link to this thread with any extra details.

    How would that work for you?

    Really, I'd just like to make this quicker and easier for you. :slight_smile:

    Cheers,
    David

  • DavidM

    Hi Mike,

    Thanks for providing access for this, it really helped as I needed to get some specifics set in there for your category and member level.

    As I've mentioned in email, here's that updated code:

    function mp_membership_discount( $price ){
    	$discount_level_id = 3;
    	$discount_percent = 0.1;
    	// check if user is logged in and is member with specified level
    	if ( is_user_logged_in() && current_user_on_level( $discount_level_id ) ){
    		return $price - ( $price * $discount_percent );
    	}
    	return $price;
    }
    
    function mp_membership_category_discount( $price, $product_id ){
    	$discount_level_id = 3;
    	$discount_category_name = 'Web N Learn';
    	$discount_percent = 1;
    	// check if user is logged in and is member with specified level
    	if ( is_user_logged_in() && current_user_on_level( $discount_level_id ) ){
    		//get product categories
    		$product_cats = get_the_terms( $product_id, 'product_category' );
    		if( is_array( $product_cats ) ) {
    			// iterate over product categories and return 0 price if discount_category exists
    			foreach( $product_cats as $cat ) {
    				if ( $cat->name == $discount_category_name ){
    					return $price - ( $price * $discount_percent );
    				}
    			}
    		} else {
    			//single category, check for match and return free pricing
    			if ( $product_cats->ID = $discount_category_name ){
    				return $price - ( $price * $discount_percent );
    			}
    		}
    	}
    	return $price;
    }
    
    if ( class_exists( 'M_Membership' ) ) {
    	add_filter( 'mp_product_price', 'mp_membership_discount' );
    	add_filter( 'mp_product_price', 'mp_membership_category_discount', 100, 2 );
    }

    While that works perfectly for the items added to the cart, yielding percentage based discounts on both overall pricing and the category based pricing, it doesn't actually display the adjusted pricing in the product listing itself.

    Unfortunately, that's not so easy! I'm looking into it though to see what we can do to get that adjusted. :slight_smile:

    Thanks for your patience with this!

    Thanks!
    David

  • Ollie

    +1

    Good to see this topic is getting closer - Ive been waiting for years but been too busy creating other custom addons for WPMU plugins to touch this one.....

    Please please, add it to the core functionality once it's working... Shouldn't be a custom fix.. Not that we can't do it ourselves but more budgets of clients, they are already paying heaps to maintain all the custom code that you need in order to run a seamless marketpress / membership install side by side.

    Cheers

  • Mike

    Hi,
    I tried using the code from this post: https://premium.wpmudev.org/forums/topic/how-do-i-offer-separating-pricing-for-premium-members-using-marketpress#post-604465

    But I can't get it to work for me. I did change the specific details to suit my needs but I never end up seeing a discount being applied. Unlike that scenario I just need a discount based on a users membership level or subscription, whichever is easier. (No specific product stuff). Is it conflicting with the fact that a user can have more than one subscription or membership thing now? I don't know what to try.

    Why isn't this working for me? I tried cycling though all member level id's (I have 4 levels) But never saw any discounts.

    Can you help me David?

  • DavidM

    Hi @Mike,

    Glad you got that working, though sorry for the delay.

    @Billzy and @Mike (original post), I'm trying to sort out an "elegant" solution for adjusting the price tag apart from the pricing affecting just the pricing once added to cart.

    The best I can think of currently is to provide a "strikeout" styling to the price tag of products wherever displayed in front-end.

    I'll post back if I can come up with a feasible solution but the code above will still work for adjusting pricing when products are added to the cart.

    @Billzy, I'd love for this to be added to Membership/MarketPress core as well, it just takes some work to provide the options in the back-end. Just takes a bit of time, I'm sure we'll have something integrates soon though. :slight_smile:

    Cheers,
    David

  • Fabio Fava

    Hey hazen how are you doing!

    As far as I can see, Membership2 doesn't (yet) offer discounts based on Membership Levels. The solution I've found is called Paid Memberships Pro, that on the Free Version offers this feature for WooCommerce-based stores.

    I think the free license will allow you to do the trick, as far as you can move you store to WooCommerce instead of MarketPress. Unfotunately the people from PMPro can't offer development to MarketPress.

    I still hope that Memberships2 can offer discounts based on Membership Levels. Also, that our beloved WPMUDEV plugins could better integrated with other platforms, like WooCommerce.

    Wish you and everybody a very nice day!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.