pmpro_insSaveOrder

Save a new order from IPN info.

Description

pmpro_insSaveOrder( $txn_id, $last_order ); 

$last_order passed in is the previous order for this subscription.

Parameters (2)

0. $txn_id
The txn id.
1. $last_order
The last order.

Usage

  1. if ( !function_exists( 'pmpro_insSaveOrder' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/services/twocheckout-ins.php'; 
  3.  
  4. // The txn id. 
  5. $txn_id = null; 
  6.  
  7. // The last order. 
  8. $last_order = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = pmpro_insSaveOrder($txn_id, $last_order); 
  12.  

Defined (1)

The function is defined in the following location(s).

/services/twocheckout-ins.php  
  1. function pmpro_insSaveOrder( $txn_id, $last_order ) { 
  2. global $wpdb; 
  3.  
  4. //check that txn_id has not been previously processed 
  5. $old_txn = $wpdb->get_var("SELECT payment_transaction_id FROM $wpdb->pmpro_membership_orders WHERE payment_transaction_id = '" . $txn_id . "' LIMIT 1"); 
  6.  
  7. if( empty( $old_txn ) ) { 
  8.  
  9. //save order 
  10. $morder = new MemberOrder(); 
  11. $morder->user_id = $last_order->user_id; 
  12. $morder->membership_id = $last_order->membership_id; 
  13. $morder->payment_transaction_id = $txn_id; 
  14. $morder->subscription_transaction_id = $last_order->subscription_transaction_id; 
  15. $morder->InitialPayment = $_POST['item_list_amount_1']; //not the initial payment, but the class is expecting that 
  16. $morder->PaymentAmount = $_POST['item_list_amount_1']; 
  17.  
  18. $morder->FirstName = $_POST['customer_first_name']; 
  19. $morder->LastName = $_POST['customer_last_name']; 
  20. $morder->Email = $_POST['customer_email']; 
  21.  
  22. $morder->gateway = $last_order->gateway; 
  23. $morder->gateway_environment = $last_order->gateway_environment; 
  24.  
  25. //save 
  26. $morder->saveOrder(); 
  27. $morder->getMemberOrderByID( $morder->id ); 
  28.  
  29. //email the user their invoice 
  30. $pmproemail = new PMProEmail(); 
  31. $pmproemail->sendInvoiceEmail( get_userdata( $last_order->user_id ), $morder ); 
  32.  
  33. inslog( "Neworder(" . $morder->code . ") created." ); 
  34.  
  35. return true; 
  36. else { 
  37. inslog( "Duplicate Transaction ID: " . $txn_id ); 
  38. return false;