Manual Payment: echo amount, coupon amount etc

Hey :slight_smile:

Iam trying to show the level selected amount within my manual payment e-mail which is sending to the user, after he successfully placed his order.

for better clarification, you can find my code below:

// Form Variables
		$per = $_POST['period'];
	$lev = $_POST['level'];

			// User Meta
			 global $current_user;
			get_currentuserinfo();
 			$curr_user_email = $current_user->user_email;
			$uname = $current_user->display_name;
 			$currlvl = $current_user->user_level;

			//php mailer variables
 			$to = get_option('admin_email');

			 //php clientmailer variables
		$subject_client = "Your order....";
			$headers_client = 'From: '. $to . "\r\n" . 'Reply-To: ' . $to . "\r\n";
			$headers_client .= "MIME-Version: 1.0\r\n";
			$headers_client .= "Content-Type: text/html;\r\n";		

		if ($lev = $_POST["level"] == 2) {
			$mailtext_client = 'Hello '.$uname.', <br> Mymessage if user bought level 2
        Right here i would like to place the level amount, discount amount etc. 		} 

        elseif ($lev = $_POST["level"] == 3) {
		$mailtext_client = 'Hallo '.$uname.', <br> Mymessage if user bought level 3
        Right here i would like to place the level amount, discount amount etc.	}

        //Emails are sending after order is placed, but not after coupon is entered
			//Error/Success Message
			if(empty($per) || empty($lev)) {
	 			if ($_POST['submit']) {
	 	 		$content .= '<div class="errormsg">My Errormessage!</div>';
	 			}
			}
			elseif ($_POST['coupon-submit']) {
	 			// nothing happens
			} else {
	 			$sent = wp_mail($curr_user_email, $subject_client, $mailtext_client, $headers_client);
	 			if ($sent) $content .= $makepayment; // shows payment details
			}

What i want to do, is add the amounts to my messages. are there variables to use for? If yes, how do i call them? I added all this to my "gateway-manual.php" right now.

If you guys need some more explanation, please let me know.

Best,
David

  • Vaughan
    • Support/SLS MockingJay

    Hi David,

    Hope you're well?

    I'm not sure if this code will get you what you want;

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

    then just echo $discount in your message, something like Discount: $discount

    Hope this helps

  • MapSteps
    • Site Builder, Child of Zeus

    Hi Vaughan,

    i guess this right way, but unfortunatley this error came up:

    Fatal error: Call to undefined method ProSites_Gateway_Manual::coupon_value() in /mypath/wp-content/plugins/pro-sites/pro-sites-files/gateways/gateway-manual.php on line 292

    right after entering/submitting the coupon code.
    Thanks!

  • Vaughan
    • Support/SLS MockingJay

    Hi,

    sorry, with regards to above, it's because I used $this->

    Can you try using global $psts instead.

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

    Not sure of what else, I think it might be best if I ask one of our developers for some help with this if the above still doesn't work. Hopefully he should be able to give you some code to do exactly what you ask.

    Hope this helps

  • MapSteps
    • Site Builder, Child of Zeus

    YES!

    Thank you so much! Now i can check if a coupon with a specific value has been chosen :slight_smile:

    if ($lev = $_POST["level"] == 2 && $discount == "-20%") {
    //where the magic happens
    } elseif ($lev = $_POST["level"] == 2) {
    //where everything else on level 2 happens
    }

    You made my day! :slight_smile:
    Best wishes,
    Dave

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.