Can Membership provide automatic discounts on ecommerce products?

I want to offer a membership package that includes a flat 10% off all products / services on my site. Can Membership support this?

  • Ash

    Hello @msk5400

    I hope you are well today and thanks for asking the question.

    I am afraid, there is no built in integration between Membership and MarketPress. How's about offering coupon to a certain membership level members?

    You can create coupon from Products > Store Settings > Coupons. And then you can send that coupon to the user of a certain level using the communication system in Membership > Communication. You can (auto)send the communication message just after registration.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash

  • Ash

    Hello @msk5400

    Okay, I have got a solution for you. Let me draw the scenario.

    For example, you have 2 levels: Level 1 (id = 1) and Level 2 ( id = 2)
    For those two levels, you have two products coupons: Level 1 = XXX and Level2 = YYY.

    Now, try to use the following code:

    add_filter( 'mp_coupon_value', 'mp_coupon_value_cb', 10, 3 );
    function mp_coupon_value_cb( $return, $code, $total ) {
    
    	$arr = array(
    		     'XXX' => 1,
    		     'YYY' => 2
    		     );
    
    	if( current_user_on_level( $arr[$code] ) ){
    		return $return;
    	}else{
    		global $mp;
    		$currency = $mp->get_setting('currency', 'USD');
    		$symbol = $mp->currencies[$currency][1];
    		$symbols = explode(', ', $symbol);
    		if (is_array($symbols)) {
    		       $symbol = "";
    		       foreach ($symbols as $temp) {
    			       $symbol .= '&#x'.$temp.';';
    		       }
    		} else {
    		       $symbol = '&#x'.$symbol.';';
    		}
    
    		$del = explode( $symbol, $return['discount'] );
    
    		$return['new_total'] = $return['new_total'] + $del[1];
    		$return['discount'] = 0;
    
    		return $return;
    	}
    }

    You have to change this part:

    $arr = array(
    		     'XXX' => 1,
    		     'YYY' => 2
    		     );

    Where XXX is coupon code and 1 is ID, Same for second one. You need to keep the syntax and add coupons and level IDs into that array.

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.