Ejemplo n.º 1
0
 $params = array();
 parse_str($_POST['vars']['data'], $params);
 /*****************************************
 		[get the order]
 	*****************************************/
 global $wpdb;
 $orderId = false;
 $order = $wpdb->get_row("SELECT id,payment_status FROM " . $wpdb->prefix . $this->pluginOrderTable . " WHERE hash='" . $params['wppizza_hash'] . "' ");
 if ($order) {
     $orderId = $order->id;
     $orderStatus = $order->payment_status;
 }
 /********************************************
 		[new send order email class]
 	********************************************/
 $sendEmail = new WPPIZZA_SEND_ORDER_EMAILS();
 /************************************************************
  *	[provided we have a valid order id AND its set
  *	to INITIALIZE send the emails and update db]
  *	returns array
  *	['status']->true/false
  *	['error']->''/msg
  *	['mailer']->mail function name
  *
  ************************************************************/
 /*default errors**/
 $mailResults['error'] = __('Sorry, we could not find this order.', $this->pluginLocale);
 $mailResults['mailer'] = 'Error';
 /**just so we dont have an abandoned colon**/
 if ($orderId) {
     if ($orderStatus == 'INITIALIZED') {
Ejemplo n.º 2
0
 function wppizza_gateway_complete_order($orderId, $blogid = false, $logging = false, $sendAdminErrors = false)
 {
     global $wpdb;
     $orderId = (int) $orderId;
     /**select the right blog table */
     if ($blogid && is_int($blogid) && $blogid > 1) {
         $wpdb->prefix = $wpdb->base_prefix . $blogid . '_';
     }
     /**********new send order email class**************/
     $sendEmail = new WPPIZZA_SEND_ORDER_EMAILS();
     /************************************************************
      *
      *	[send the emails returns array
      *	['status']->true/false
      *	['error']->''/msg
      *	['mailer']->mail function name
      *
      ************************************************************/
     $mailResults = $sendEmail->wppizza_order_send_email($orderId, $blogid);
     /********************************************************************
      *
      *	[depending on $mailResults['status'],
      *	will insert order into db and output "thankyou"
      *	or justs displays error]
      *
      ********************************************************************/
     /*update db*/
     $dbupd['customer_details'] = '' . $sendEmail->customerDetails . '';
     $dbupd['order_details'] = '' . $sendEmail->orderDetails . '';
     $dbupd['payment_status'] = 'COMPLETED';
     //$dbupd['transaction_details']	=	esc_sql(serialize($gatewayReply));
     $dbupd['transaction_errors'] = '';
     $dbupd['mail_sent'] = !empty($mailResults['status']) ? 'Y' : 'N';
     $dbupd['mail_error'] = !empty($mailResults['error']) ? esc_sql(maybe_serialize($mailResults['error'])) : '';
     $fields = '';
     $i = 0;
     foreach ($dbupd as $k => $v) {
         if ($i > 0) {
             $fields .= ", ";
         }
         $fields .= "" . $k . "='" . $v . "'";
         $i++;
     }
     $sql = "UPDATE " . $wpdb->prefix . $this->pluginOrderTable . " SET " . $fields . " WHERE id='" . $orderId . "' ";
     $wpdb->query($sql);
     /**do additional stuff when order has been executed*/
     do_action('wppizza_on_order_executed', $orderId, $this->pluginOrderTable);
     if (!$mailResults['status'] && $sendAdminErrors) {
         $this->wppizza_gateway_send_errors_to_admin(true, $blogid, $orderId, false, $mailResults);
     }
     /**logging**/
     if (!$mailResults['status']) {
         $this->wppizza_gateway_logging($logging, $blogid, $orderId, $mailResults, 'mail-error');
     } else {
         $this->wppizza_gateway_logging($logging, $blogid, $orderId, 'Order ID:' . $orderId . PHP_EOL . 'Customer Details:' . PHP_EOL . print_r($sendEmail->customerDetails, true) . PHP_EOL . 'Order Details:' . PHP_EOL . print_r($sendEmail->orderDetails, true) . PHP_EOL . PHP_EOL, 'success');
     }
 }