Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. if ( isset( $this->options['wc_notify_customer_payment_successful_enable'] ) ) {
  2.     add_action( 'woocommerce_order_status_processing', array( &$this, 'successful_payment_notification_client' ) );
  3. }
  4.  
  5.  
  6. /*
  7.  * WooCommerce Successful payment notification client
  8.  *
  9.  * @param $checkout
  10.  */
  11. public function successful_payment_notification_client ( $order_id ) {
  12.     // Check the mobile field is empty
  13.     if ( empty( $_REQUEST['mobile'] ) ) {
  14.         return;
  15.     }
  16.  
  17.     $args = array(
  18.         'post_id' => $order_id,
  19.         'orderby' => 'comment_ID',
  20.         'order'   => 'DESC',
  21.         'approve' => 'approve',
  22.         'type'    => 'order_note',
  23.         'number'  => 1
  24.     );
  25.  
  26.     remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
  27.  
  28.     $notes = get_comments( $args );
  29.  
  30.     add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
  31.  
  32.     $order          = new WC_Order( $order_id );
  33.     $this->sms->to  = array( $_REQUEST['mobile'] );
  34.     $template_vars  = array(
  35.         '%order_id%'           => $order_id,
  36.         '%order_number%'       => $order->get_order_number(),
  37.         '%status%'             => $order->get_status(),
  38.         '%billing_first_name%' => $_REQUEST['billing_first_name'],
  39.         '%billing_last_name%'  => $_REQUEST['billing_last_name'],
  40.         '%comment%'            => $notes[0]->comment_content,
  41.     );
  42.     $message        = str_replace( array_keys( $template_vars ), array_values( $template_vars ), $this->options['wc_notify_customer_payment_successful_message'] );
  43.     $this->sms->msg = $message;
  44.     $this->sms->SendSMS();
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement