Marketpress Chained Percentage based on Pro Site Level

Hi,

As per, https://premium.wpmudev.org/forums/topic/paypal-chained-payments-marketpress-and-prosites

I need to be able to charge a different percentage for Free customers as opposed to paying Pro Site customers.

Is this possible? Can I request this feature?

After a lot of work on our pricing model, this has been the agreed solution.

Cheers,

Johnny

  • aristath
    • Recruit

    Hello again Johnny!

    This will have to be custom-coded...

    I wrote this for you but haven't tested it.
    It's half the work so you can extend and work on that to achieve what you want to do.
    This code will do the following:
    1. Get the current user
    2. Find if the current user is an admin of a site
    3. If the user is an admin of a site, this will get the site's pro-sites level.
    4. Compare all sites administered by this user and get the highest pro-sites level amongst his/her sites.
    5. Adds some conditionals at the end that will allow you to run your custom code depending on the current user's maximum pro-sites level.
    This way, you'll be able to add some filters, actions or whatever you want to make this work and complete this task.

    global $wpdb;
    
    // Get the ID of the current user
    $user_id = get_current_user_id();
    
    // Get the blogs of the current user
    $user_blogs = get_blogs_of_user( $user_id );
    
    foreach ( $user_blogs AS $user_blog ) {
    	$blog_id = $user_blog->userblog_id;
    
    	// Is the current user the admin of this site?
    	if ( current_user_can_for_blog( $blog_id, 'manage_options' ) ) {
    
    		$sql = "SELECT level FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '$blog_id'";
    
    		// Get the site's level
    		$level = $wpdb->get_var( $sql );
    
    		// Get the maximum pro-sites level of the user.
    		// This only runs for sites where the user is an admin.
    		if ( ! isset( $max_level ) ) {
    			$max_level = $level;
    		} else {
    			if ( $max_level < $level ) {
    				$max_level = $level;
    			}
    		}
    	}
    }
    
    // Is the current user the owner of a pro-sites site?
    if ( isset( $max_level ) ) {
    
    	if ( $max_level == 1 ) {
    		// DO SOMETHING IF THE USER HAS A PRO SITE
    		// WITH MAXIMUM LEVEL = 1
    	} elseif ( $max_level == 2 ) {
    		// DO SOMETHING IF THE USER HAS A PRO SITE
    		// WITH MAXIMUM LEVEL = 2
    	} elseif ( $max_level == 3 ) {
    		// DO SOMETHING IF THE USER HAS A PRO SITE
    		// WITH MAXIMUM LEVEL = 3
    	}
    }

    I hope that helps!

    Cheers,
    Ari.

  • Aaron
    • CTO

    As said its custom coding, which Ari has so gracefully extended himself to attempt.

    It would be a relatively easy mod, just checking the pro sites level and overriding the percentage based off it. As you are in the context of the blog you can just call is_pro_site(false, $level) for each level.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.