Pro Sites 3.5 | Manual Payment, Period and Coupons

Hey there! :slight_smile:

I just installed the new version of Pro Sites (which is great!! by the way).
I use PayPal and Manual Payment.

Now some issues appeared:

# Period isn't submitted correctly in the email the admin receives, after someone sent the manual payment request. I only offer 12 months, email shows: 1 month

This is not really a problem, because i only offer a 12 month subscription, but for others (if they have more plans) this could be a problem.

# Coupon codes and amounts should also be submitted via e-mail, so the admin can see what amound he/she could expect.

I already had a solution for this and i will implement it from my customized prosites plugin.
Only wanted to let you know about this :slight_smile:

Would be great if you would put this on your list :slight_smile:

Best,
David

  • MapSteps

    Hey Kasia,

    thank you for your reply!

    I am just about to reimplement my customizations to the 3.5 version of Pro Sites.

    Please take a look at the code blow, its like just adding the amount into the e-mail which is sent to the owner after someone submits a request:

    Added these lines to "gateway-manual.php" at line 264 right before the e-mail.

    if ( isset( $_SESSION['COUPON_CODE'] ) ) {
    				global $psts;
    
    				$coupon_value = $psts->coupon_value( $_SESSION['COUPON_CODE'], 100 );
    				$discount = $coupon_value['discount'];
    			};
    
    			if ($_POST['level']=='1' ) {
    
    				$amount = "XX,XX$";
    
    			} elseif ($_POST['level']=='2' ) {
    
    				$amount = "XX,XX$";
    
    			} elseif ($discount=='-40%' && $_POST['level']=='1' ) {
    
    				$amount = "XX,XX$";
    
    			} elseif ($discount=='-40%' && $_POST['level']=='2' ) {
    
    				$amount = "XX,XX$";
    
    			} elseif ($discount=='-20%' && $_POST['level']=='1' ) {
    
    				$amount = "XX,XX$";
    
    			} elseif ($discount=='-20%' && $_POST['level']=='2' ) {
    
    				$amount = "XX,XX$";
    
    			}
    
    			$subject = __( 'Pro Sites Manual Payment Submission', 'psts' );
    			$message = sprintf( __( 'The user "%s" has submitted a manual payment request via the Pro Sites checkout form.', 'psts' ), $username ) . "\n\n";
    			$message .= __( 'Level: ', 'psts' ) . intval( $_POST['level'] ) . ' - ' . $psts->get_level_setting( intval( $_POST['level'] ), 'name' ) . "\n";
    			$message .= __( 'Period: ', 'psts' ) . sprintf( __( 'Every %d Months', 'psts' ), intval( $_POST['period'] ) ) . "\n";
    
    // so lets add the amount to the e-mail
    			$message .= 'Amount:' . $amount . "\n";	
    
    			$message .= sprintf( __( "User Email: %s", 'psts' ), $email ) . "\n";
    			$message .= sprintf( __( "Activation Key: %s", 'psts' ), $activation_key ) . "\n";
    			$message .= sprintf( __( "Site Address: %s", 'psts' ), get_home_url() ) . "\n";
    			$message .= sprintf( __( "Manage Site: %s", 'psts' ), $blog_admin_url ) . "\n\n";

    Now unfortunately this little code-snippet isn't working any more:

    if ( isset( $_SESSION['COUPON_CODE'] ) ) {
    				global $psts;
    
    				$coupon_value = $psts->coupon_value( $_SESSION['COUPON_CODE'], 100 );
    				$discount = $coupon_value['discount'];
    			};

    Maybe there is any other way to get ANY value (amount or $ or anything else) to get this working again?

    Thanks in advance! :slight_smile:
    There might also be a better way to handle this... A great idea would be to add an e-mail which would also be sent to the client after he submitted. Some kind of confirmation mail.

    Best,
    David

    • Rheinard

      @David,

      Sessions do work differently now thanks to some better code in WP4.0+. So that meant we changed how we handle sessions. To get a working snippet you will need:

      if ( $session_coupon = ProSites_Helper_Session::session( 'COUPON_CODE' ) ) {
      	global $psts;
      	$coupon_value = $psts->coupon_value( $session_coupon, 100 );
      	$discount = $coupon_value['discount'];
      }

      That said, its probably not the best way to customise Pro Sites as an update will break that for you. So I might add some filters in the next update that you can use.

      Cheers,
      Rheinard

    • Rheinard

      Hi @David,

      In the next update there are a few new hooks that can be used to customise the email upon manual payment. You can use them by adding it to your theme functions.php or if you know how, create a small plugin with the hook.

      Here is what you will need...

      function custom_add_amount_20150626( $email_info, $email_fields ) {
      
      	if( ! class_exists( 'ProSites_Helper_Session' ) ) {
      		return $email_info;
      	}
      
      	if ( $session_coupon = ProSites_Helper_Session::session( 'COUPON_CODE' ) ) {
      		global $psts;
      		$coupon_value = $psts->coupon_value( $session_coupon, 100 );
      		$discount = $coupon_value['discount'];
      	}
      
      	if ($_POST['level']=='1' ) {
      
      		$amount = "XX,XX$";
      
      	} elseif ($_POST['level']=='2' ) {
      
      		$amount = "XX,XX$";
      
      	} elseif ($discount=='-40%' && $_POST['level']=='1' ) {
      
      		$amount = "XX,XX$";
      
      	} elseif ($discount=='-40%' && $_POST['level']=='2' ) {
      
      		$amount = "XX,XX$";
      
      	} elseif ($discount=='-20%' && $_POST['level']=='1' ) {
      
      		$amount = "XX,XX$";
      
      	} elseif ($discount=='-20%' && $_POST['level']=='2' ) {
      
      		$amount = "XX,XX$";
      
      	}
      
      	// so lets add the amount to the e-mail
      	// a little bit of code magic to add it after 'Period'
      	$index = array_search( 'period_text', array_keys( $email_info ) );
      	$index += 1;
      	$email_info_end = array_splice( $email_info, $index );
      	$email_info_start = array_splice( $email_info, 0, $index);
      	$my_custom_line = array( 'my_custom_line', 'Amount:' . $amount );
      	$email_info = array_merge( $email_info_start, $my_custom_line, $email_info_end );
      
      	// Or to add it at the end withou all the fussing around...
      	// $email_info['my_custom_line'] = 'Amount:' . $amount;
      
      	return $email_info;
      }
      
      // Add amount to manual email
      add_filter( 'prosites_manual_payment_email_info', 'custom_add_amount_20150626', 10, 2 );

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.