/**
  * trigger function.
  */
 function trigger($booking_id)
 {
     if ($booking_id) {
         $this->object = get_wc_booking($booking_id);
         if ($this->object->has_status('in-cart')) {
             return;
         }
         $this->find[] = '{product_title}';
         $this->replace[] = $this->object->get_product()->get_title();
         if ($this->object->get_order()) {
             $this->find[] = '{order_date}';
             $this->replace[] = date_i18n(wc_date_format(), strtotime($this->object->get_order()->order_date));
             $this->find[] = '{order_number}';
             $this->replace[] = $this->object->get_order()->get_order_number();
         } else {
             $this->find[] = '{order_date}';
             $this->replace[] = date_i18n(wc_date_format(), strtotime($this->object->booking_date));
             $this->find[] = '{order_number}';
             $this->replace[] = __('N/A', 'woocommerce-bookings');
         }
         if (!$this->is_enabled() || !$this->get_recipient()) {
             return;
         }
         $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
     }
 }
/**
 * Check if a product has a member discount
 * Example: Display a member discount notice
 */
function sv_wc_memberships_member_discount_product_notice()
{
    // bail if Memberships isn't active
    if (!function_exists('wc_memberships')) {
        return;
    }
    // Set a discount end date
    $discount_ends = date_i18n(wc_date_format(), strtotime('2015-12-31'));
    // Add our top notice if the member has a discount
    if (wc_memberships_user_has_member_discount()) {
        wc_print_notice(sprintf('Act fast! Your member discount ends on %s.', $discount_ends), 'notice');
    }
}
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($booking_id)
 {
     if ($booking_id) {
         $this->object = get_wc_booking($booking_id);
         if ($this->object->get_product()) {
             $this->find[] = '{product_title}';
             $this->replace[] = $this->object->get_product()->get_title();
         }
         if ($this->object->get_order()) {
             $this->find[] = '{order_date}';
             $this->replace[] = date_i18n(wc_date_format(), strtotime($this->object->get_order()->order_date));
             $this->find[] = '{order_number}';
             $this->replace[] = $this->object->get_order()->get_order_number();
             $this->recipient = $this->object->get_order()->billing_email;
         } else {
             $this->find[] = '{order_date}';
             $this->replace[] = date_i18n(wc_date_format(), strtotime($this->object->booking_date));
             $this->find[] = '{order_number}';
             $this->replace[] = __('N/A', 'woocommerce-bookings');
             if ($this->object->customer_id && ($customer = get_user_by('id', $this->object->customer_id))) {
                 $this->recipient = $customer->user_email;
             }
         }
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * Trigger.
  *
  * @version 2.4.0
  */
 function trigger($order_id)
 {
     if ($order_id) {
         $this->object = wc_get_order($order_id);
         if ($this->customer_email) {
             $this->recipient = $this->object->billing_email;
         }
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     if ($order_id) {
         global $post;
         $order = wc_get_order($order_id);
         $post = $order->post;
         setup_postdata($post);
     }
     $this->send($this->get_recipient(), $this->get_subject(), do_shortcode($this->get_content()), $this->get_headers(), $this->get_attachments());
     if ($order_id) {
         wp_reset_postdata();
     }
 }
 /**
  * trigger function.
  *
  * We need to override WC_Email_Customer_Invoice's trigger method because it expects to be run only once
  * per request (but multiple subscription renewal orders can be generated per request).
  *
  * @access public
  * @return void
  */
 function trigger($order)
 {
     if (!is_object($order)) {
         $order = new WC_Order(absint($order));
     }
     if ($order) {
         $this->object = $order;
         $this->recipient = $this->object->billing_email;
         $order_date_index = array_search('{order_date}', $this->find);
         if (false === $order_date_index) {
             $this->find[] = '{order_date}';
             $this->replace[] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         } else {
             $this->replace[$order_date_index] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         }
         $order_number_index = array_search('{order_number}', $this->find);
         if (false === $order_number_index) {
             $this->find[] = '{order_number}';
             $this->replace[] = $this->object->get_order_number();
         } else {
             $this->replace[$order_number_index] = $this->object->get_order_number();
         }
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * trigger function.
  *
  * We need to override WC_Email_New_Order's trigger method because it expects to be run only once
  * per request.
  *
  * @access public
  * @return void
  */
 function trigger($order_id)
 {
     if ($order_id) {
         $this->object = new WC_Order($order_id);
         $order_date_index = array_search('{order_date}', $this->find);
         if (false === $order_date_index) {
             $this->find[] = '{order_date}';
             $this->replace[] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         } else {
             $this->replace[$order_date_index] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         }
         $order_number_index = array_search('{order_number}', $this->find);
         if (false === $order_number_index) {
             $this->find[] = '{order_number}';
             $this->replace[] = $this->object->get_order_number();
         } else {
             $this->replace[$order_number_index] = $this->object->get_order_number();
         }
         $this->subscriptions = wcs_get_subscriptions_for_switch_order($this->object);
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($order_id)
 {
     $vendors = get_vendor_from_an_order($order_id);
     if ($vendors) {
         foreach ($vendors as $vendor) {
             $vendor_obj = get_wcmp_vendor_by_term($vendor);
             $vendor_email = $vendor_obj->user_data->user_email;
             $vendor_id = $vendor_obj->term_id;
             if ($order_id && $vendor_email) {
                 $this->object = new WC_Order($order_id);
                 $this->find[] = '{order_date}';
                 $this->replace[] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
                 $this->find[] = '{order_number}';
                 $this->replace[] = $this->object->get_order_number();
                 $this->vendor_email = $vendor_email;
                 $this->vendor_id = $vendor_id;
                 $this->recipient = $vendor_email;
             }
             if (!$this->is_enabled() || !$this->get_recipient()) {
                 return;
             }
             $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
         }
     }
 }
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($order)
 {
     if (!is_object($order)) {
         $order = wc_get_order(absint($order));
     }
     if ($order) {
         $this->object = $order;
         $this->recipient = $this->object->billing_email;
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
     }
     if (!$this->get_recipient()) {
         return;
     }
     if (version_compare(WOOCOMMERCE_VERSION, '2.2', '<')) {
         return;
     }
     $refunds = $order->get_refunds();
     if (empty($refunds)) {
         return;
     }
     $result = $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
     do_action('wpo_wcpdf_pro_email_sent', $result, $this->id, $order);
 }
 public function add_checkout_time_to_booking_end_time($date, $booking)
 {
     $product = wc_get_product($booking->product_id);
     if (empty($product) || 'accommodation-booking' !== $product->product_type) {
         return $date;
     }
     $check_out = get_option('woocommerce_accommodation_bookings_check_out', '');
     $date_format = apply_filters('woocommerce_bookings_date_format', wc_date_format());
     $time_format = apply_filters('woocommerce_bookings_time_format', ', ' . wc_time_format());
     return date_i18n($date_format, $booking->end) . date_i18n($time_format, strtotime("Today " . $check_out));
 }
 /**
  * Trigger.
  *
  * @param int $order_id
  */
 function trigger($order_id)
 {
     if ($order_id) {
         $this->object = wc_get_order($order_id);
         $this->recipient = $this->object->billing_email;
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
         $customer_id = $this->object->post->post_author;
         $customer_code = get_the_author_meta('customercode', $customer_id);
         /** Send order details to notification server. **/
         $order_list = array();
         foreach ($this->object->get_items() as $val) {
             $vendor_name = $val['roaster'];
             $vendor_email = $val['roaster_email'];
             if (!array_key_exists($vendor_name, $order_list)) {
                 $order_list[$vendor_name] = array('roaster' => $vendor_name, 'roaster_email' => $vendor_email, 'orders' => array());
             }
             $product_id = $val['product_id'];
             $order_meta = get_post_custom($order_id);
             $product_meta = get_post_custom($product_id);
             $orders = array('product_name' => $val['name'], 'product_code' => $product_meta['product_code'][0], 'unit_size' => $product_meta['unit_size'][0], 'unit_quantity' => $product_meta['unit_quantity'][0], 'currency' => $order_meta['_order_currency'][0], 'quantity' => $val['qty'], 'cost' => '&yen;' . $val['line_subtotal']);
             array_push($order_list[$vendor_name]['orders'], $orders);
         }
         $order_data = array('customer_code' => $customer_code, 'order_id' => $order_id, 'order_date' => date_i18n(wc_date_format(), strtotime($this->object->order_date)), 'notes' => $this->object->customer_note, 'customer_email' => $this->object->billing_email, 'customer_telephone' => $this->object->billing_phone, 'shipping_address' => $this->object->get_address(), 'orders' => $order_list, 'totals' => $this->object->get_order_item_totals());
         if (array_key_exists($order_data['shipping_address']['state'], $this->states)) {
             $order_data['shipping_address']['state'] = $this->states[$order_data['shipping_address']['state']];
         }
         $curl_url = "http://services.coffeeconnection.jp/newOrder";
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $curl_url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_HEADER, false);
         curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
         curl_setopt($ch, CURLOPT_TIMEOUT, 20);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($order_data));
         $response = curl_exec($ch);
         $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         if ($status != 204) {
         } else {
             error_log("Successfully sent order_data: " . json_encode($order_data) . " \nresponse: {$response} , status: {$status}");
         }
         curl_close($ch);
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * Determine if the email should actually be sent and setup email merge variables
  *
  * @since 1.0.1
  */
 public function trigger($offer_args)
 {
     $this->recipient = $offer_args['recipient'];
     $this->offer_args = $offer_args;
     if (!$this->is_enabled() || !$this->recipient) {
         return;
     }
     $this->find['offer_date'] = '{offer_date}';
     $this->find['offer_number'] = '{offer_number}';
     $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime(date('Y-m-d H:i:s')));
     $this->replace['offer_number'] = $this->offer_args['offer_id'];
     // woohoo, send the email!
     $this->send($this->recipient, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * Trigger.
  */
 function trigger($order_id)
 {
     if ($order_id) {
         $this->object = wc_get_order($order_id);
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * Trigger email.
  *
  * @param  WC_Order $order         Order data.
  * @param  string   $tracking_code Tracking code.
  */
 public function trigger($order, $tracking_code)
 {
     if (is_object($order)) {
         $this->object = $order;
         $this->recipient = $this->object->billing_email;
         $this->find[] = '{order_number}';
         $this->replace[] = $this->object->get_order_number();
         $this->find[] = '{date}';
         $this->replace[] = date_i18n(wc_date_format(), time());
         $this->find[] = '{tracking_code}';
         $this->replace[] = $this->get_tracking_code_url($tracking_code);
     }
     if (!$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($order_id, $customer_email, $vendor_id)
 {
     if ($order_id && $customer_email && $vendor_id) {
         $this->object = new WC_Order($order_id);
         $this->find[] = '{order_date}';
         $this->replace[] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->find[] = '{order_number}';
         $this->replace[] = $this->object->get_order_number();
         $this->vendor_id = $vendor_id;
         //$user = get_user_by( 'id', $user_id );
         $this->recipient = $customer_email;
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($object)
 {
     if (!is_object($object)) {
         $object = get_post($object);
         if ($object->post_type == 'shop_order') {
             $object = wc_get_order($object->ID);
         } else {
             if ($object->post_type == 'invoice') {
                 $object = wc_gzdp_get_invoice($object->ID);
             }
         }
     }
     if (is_object($object)) {
         $this->object = $object;
         // Look for the actual invoice
         if ($object instanceof WC_Order) {
             if ($object->invoices) {
                 foreach ($object->invoices as $invoice) {
                     $invoice = wc_gzdp_get_invoice($invoice);
                     if ($invoice->is_type('simple')) {
                         $this->object = $invoice;
                         break;
                     }
                 }
             }
         }
         if (!$this->object instanceof WC_GZDP_Invoice) {
             return;
         }
         $recipient = $this->object->recipient;
         $this->recipient = $recipient['mail'];
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->find['invoice-number'] = '{invoice_number}';
         $order_data = $this->object->order_data;
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($order_data['date']));
         $this->replace['order-number'] = $this->object->order;
         $this->replace['invoice-number'] = $this->object->get_number(true);
         $this->object->mark_as_sent();
     }
     if (!$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($order)
 {
     if (!is_object($order)) {
         $order = wc_get_order(absint($order));
     }
     if ($order) {
         $this->object = $order;
         $this->recipient = $this->object->billing_email;
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
     }
     if (!$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($order)
 {
     if (!is_object($order)) {
         $order = wc_get_order(absint($order));
     }
     if ($order) {
         $this->object = $order;
         $this->recipient = $this->get_option('recipient');
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
     }
     if (!$this->get_recipient()) {
         return;
     }
     $result = $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
     do_action('wpo_wcpdf_pro_email_sent', $result, $this->id, $order);
 }
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($args)
 {
     if ($args) {
         $defaults = array('order_id' => '', 'customer_note' => '');
         $args = wp_parse_args($args, $defaults);
         extract($args);
         $this->object = wc_get_order($order_id);
         $this->recipient = $this->object->billing_email;
         $this->customer_note = $customer_note;
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($booking_id, $notification_subject, $notification_message, $attachments = array())
 {
     if ($booking_id) {
         $this->object = get_wc_booking($booking_id);
         $this->find[] = '{product_title}';
         $this->replace[] = $this->object->get_product()->get_title();
         if ($this->object->get_order()) {
             $this->find[] = '{order_date}';
             $this->replace[] = date_i18n(wc_date_format(), strtotime($this->object->get_order()->order_date));
             $this->find[] = '{order_number}';
             $this->replace[] = $this->object->get_order()->get_order_number();
             $this->find[] = '{customer_name}';
             $this->replace[] = $this->object->get_order()->billing_first_name . ' ' . $this->object->get_order()->billing_last_name;
             $this->find[] = '{customer_first_name}';
             $this->replace[] = $this->object->get_order()->billing_first_name;
             $this->find[] = '{customer_last_name}';
             $this->replace[] = $this->object->get_order()->billing_last_name;
             $this->recipient = $this->object->get_order()->billing_email;
         } else {
             $this->find[] = '{order_date}';
             $this->replace[] = date_i18n(wc_date_format(), strtotime($this->object->booking_date));
             $this->find[] = '{order_number}';
             $this->replace[] = __('N/A', 'woocommerce-bookings');
             $this->find[] = '{customer_name}';
             $this->replace[] = __('N/A', 'woocommerce-bookings');
             $this->find[] = '{customer_first_name}';
             $this->replace[] = __('N/A', 'woocommerce-bookings');
             $this->find[] = '{customer_last_name}';
             $this->replace[] = __('N/A', 'woocommerce-bookings');
             if ($this->object->customer_id && ($customer = get_user_by('id', $this->object->customer_id))) {
                 $this->recipient = $customer->user_email;
             }
         }
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     $this->heading = str_replace($this->find, $this->replace, $notification_subject);
     $this->subject = str_replace($this->find, $this->replace, $notification_subject);
     $this->notification_message = str_replace($this->find, $this->replace, $notification_message);
     $attachments = apply_filters('woocommerce_email_attachments', $attachments, $this->id, $this->object);
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $attachments);
 }
 /**
  * Trigger.
  */
 function trigger($order_id)
 {
     if ($order_id) {
         $this->object = wc_get_order($order_id);
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->find['donation-project-name'] = '{project_name}';
         $order_id = $this->object->get_order_number();
         $project_id = WC_QD()->db()->get_project_id($order_id);
         $project_name = get_the_title($project_id);
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
         $this->replace['donation-project-name'] = $project_name;
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($order_id, $partial_refund = false, $refund_id = null)
 {
     $this->partial_refund = $partial_refund;
     $this->set_email_strings($partial_refund);
     if ($order_id) {
         $this->object = wc_get_order($order_id);
         $this->recipient = $this->object->billing_email;
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
     }
     if ($refund_id) {
         $this->refund = wc_get_order($refund_id);
     }
     if (!$this->is_enabled() || !$this->get_recipient()) {
         return;
     }
     $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
    /**
     * Trigger a notification
     * 
     * @access public
     * @param object $order
     * @param array $args
     * @param bool $send_to_admin
     * @return void
     */
    public function trigger($order, $args = array(), $send_to_admin = false)
    {
        if (!$order) {
            return;
        }

        $this->object = $order;

        if ($send_to_admin) {
            $this->recipient = get_option('admin_email');
        }
        else {
            $this->recipient = $this->object->billing_email;
        }

        // Replace macros
        $this->find[] = '{order_date}';
        $this->replace[] = date_i18n(wc_date_format(), strtotime($this->object->order_date));

        // Check if this email type is enabled, recipient is set and we are not on a development website
        if (!$this->is_enabled() || !$this->get_recipient() || !Subscriptio::is_main_site()) {
            return;
        }

        // Get subscription
        $subscription = Subscriptio_Order_Handler::get_subscriptions_from_order_id($order->id);
        $subscription = reset($subscription);

        if (!$subscription) {
            return;
        }

        $this->template_variables = array(
            'subscription'  => $subscription,
            'order'         => $this->object,
            'email_heading' => $this->get_heading(),
            'sent_to_admin' => false,
        );

        $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
    }
 /**
  * trigger function.
  *
  * @access public
  * @return void
  */
 function trigger($order_id)
 {
     if (!$this->is_enabled() || empty($vendors) || empty($order_id)) {
         return false;
     }
     $this->object = wc_get_order($order_id);
     $this->vendor = yith_get_vendor($this->object->post->post_author, 'user');
     if (!$this->vendor->is_valid()) {
         return false;
     }
     $this->find['order-date'] = '{order_date}';
     $this->find['order-number'] = '{order_number}';
     $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
     $this->replace['order-number'] = $this->object->get_order_number();
     $vendor_email = $this->vendor->store_email;
     if (empty($vendor_email)) {
         $vendor_owner = get_user_by('id', absint($this->vendor->get_owner()));
         $vendor_email = $vendor_owner instanceof WP_User ? $vendor_owner->user_email : false;
     }
     $this->send($vendor_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
 }
 /**
  * Trigger.
  *
  * @version 2.5.6
  */
 function trigger($order_id)
 {
     if (!$this->is_enabled()) {
         return;
     }
     if ($order_id) {
         $this->object = wc_get_order($order_id);
         if ($this->customer_email) {
             $this->recipient = $this->object->billing_email;
         }
         $this->find['order-date'] = '{order_date}';
         $this->find['order-number'] = '{order_number}';
         $this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
         $this->replace['order-number'] = $this->object->get_order_number();
         global $post;
         $order = wc_get_order($order_id);
         if ('woocommerce_checkout_order_processed_notification' === current_filter()) {
             // Check status
             $is_status_found = false;
             $trigger_hooks = $this->get_option('trigger');
             foreach ($trigger_hooks as $trigger_hook) {
                 if (false !== ($pos = strpos($trigger_hook, 'woocommerce_new_order_notification'))) {
                     $the_status = 'wc-' . substr($trigger_hook, 35);
                     if ('wc-wcj_any_status' === $the_status || $order->post_status === $the_status) {
                         $is_status_found = true;
                         break;
                     }
                 }
             }
             if (false === $is_status_found) {
                 return;
             }
         }
         $post = $order->post;
         setup_postdata($post);
     }
     $this->recipient = do_shortcode($this->recipient);
     if (!$this->get_recipient()) {
         if ($order_id) {
             wp_reset_postdata();
         }
         return;
     }
     $this->send($this->get_recipient(), do_shortcode($this->get_subject()), do_shortcode($this->get_content()), $this->get_headers(), $this->get_attachments());
     if ($order_id) {
         wp_reset_postdata();
     }
 }
Esempio n. 25
0
 * @author 		WooThemes
 * @package 	WooCommerce/Templates/Emails/Plain
 * @version     2.0.0
 */
if (!defined('ABSPATH')) {
    exit;
    // Exit if accessed directly
}
echo $email_heading . "\n\n";
echo __("Hello, a note has just been added to your order:", 'woocommerce') . "\n\n";
echo "----------\n\n";
echo wptexturize($customer_note) . "\n\n";
echo "----------\n\n";
echo __("For your reference, your order details are shown below.", 'woocommerce') . "\n\n";
echo "****************************************************\n\n";
do_action('woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text);
echo sprintf(__('Order number: %s', 'woocommerce'), $order->get_order_number()) . "\n";
echo sprintf(__('Order date: %s', 'woocommerce'), date_i18n(wc_date_format(), strtotime($order->order_date))) . "\n";
do_action('woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text);
echo "\n" . $order->email_order_items_table($order->is_download_permitted(), true, '', '', '', true);
echo "----------\n\n";
if ($totals = $order->get_order_item_totals()) {
    foreach ($totals as $total) {
        echo $total['label'] . "\t " . $total['value'] . "\n";
    }
}
echo "\n****************************************************\n\n";
do_action('woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text);
do_action('woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text);
echo "\n****************************************************\n\n";
echo apply_filters('woocommerce_email_footer_text', get_option('woocommerce_email_footer_text'));
Esempio n. 26
0
						</span> 
						<?php 
echo $order->get_order_number();
?>

					</td>
					<td class="order-table-heading" style="text-align:right; padding: 12px 0 6px;">
						<span class="highlight">
							<?php 
_e('Order Date:', 'email-control');
?>

						</span> 
						<?php 
printf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($order->order_date)), date_i18n(wc_date_format(), strtotime($order->order_date)));
?>

					</td>
				</tr>
			</table>
			
			<table cellspacing="0" cellpadding="0" class="order_items_table" border="0" >
				<thead>
					<tr>
						<th scope="col" class="order_items_table_th_style order_items_table_td order_items_table_td_left order_items_table_th_bg_color order_items_table_td_top"><?php 
_e('Product', 'email-control');
?>
</th>
						<th scope="col" class="order_items_table_th_style order_items_table_td order_items_table_th_bg_color order_items_table_td_top"><?php 
_e('Quantity', 'email-control');
             * @param string $profile_identifier See https://github.com/opauth/opauth/wiki/Opauth-configuration - Strategy
             */
            echo apply_filters('wc_social_login_profile_identifier', $profile->has_email() ? $profile->get_email() : $profile->get_nickname());
            ?>
					</span>
				</td>
				<td data-title="<?php 
            _e('Last login', WC_Social_Login::TEXT_DOMAIN);
            ?>
">
					<span>
					<?php 
            if ($login_timestamp) {
                ?>
						<?php 
                printf(__('%s @ %s', WC_Social_Login::TEXT_DOMAIN), date_i18n(wc_date_format(), $login_timestamp), date_i18n(wc_time_format(), $login_timestamp));
                ?>
					<?php 
            } else {
                ?>
						<?php 
                echo __('Never', WC_Social_Login::TEXT_DOMAIN);
                ?>
					<?php 
            }
            ?>
					</span>
				</td>
				<td class="profile-actions">
					<a href="<?php 
            echo $provider->get_auth_url($return_url, 'unlink');
Esempio n. 28
0
				<p class="meta">
					<div class="author"><strong itemprop="author"><?php 
    comment_author();
    ?>
</strong></div> <?php 
    if (get_option('woocommerce_review_rating_verification_label') === 'yes') {
        if (wc_customer_bought_product($comment->comment_author_email, $comment->user_id, $comment->comment_post_ID)) {
            echo '<em class="verified">(' . __('verified owner', 'woocommerce') . ')</em> ';
        }
    }
    ?>
					<div class="date"><time itemprop="datePublished" datetime="<?php 
    echo get_comment_date('c');
    ?>
"><?php 
    echo get_comment_date(wc_date_format());
    ?>
</time></div>
				</p>
				

			<?php 
}
?>

			<div itemprop="description" class="description expert"><?php 
comment_text();
?>
</div>
			</div>
		</div>
    /**
     * Output the metabox.
     */
    public static function output($post)
    {
        global $post;
        $args = array('post_id' => $post->ID, 'orderby' => 'comment_ID', 'order' => 'DESC', 'approve' => 'approve', 'type' => 'order_note');
        remove_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments'), 10, 1);
        $notes = get_comments($args);
        add_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments'), 10, 1);
        echo '<ul class="order_notes">';
        if ($notes) {
            foreach ($notes as $note) {
                $note_classes = get_comment_meta($note->comment_ID, 'is_customer_note', true) ? array('customer-note', 'note') : array('note');
                $note_classes = apply_filters('woocommerce_order_note_class', $note_classes, $note);
                ?>
				<li rel="<?php 
                echo absint($note->comment_ID);
                ?>
" class="<?php 
                echo esc_attr(implode(' ', $note_classes));
                ?>
">
					<div class="note_content">
						<?php 
                echo wpautop(wptexturize(wp_kses_post($note->comment_content)));
                ?>
					</div>
					<p class="meta">
						<abbr class="exact-date" title="<?php 
                echo $note->comment_date;
                ?>
"><?php 
                printf(__('added on %1$s at %2$s', 'woocommerce'), date_i18n(wc_date_format(), strtotime($note->comment_date)), date_i18n(wc_time_format(), strtotime($note->comment_date)));
                ?>
</abbr>
						<?php 
                if ($note->comment_author !== __('WooCommerce', 'woocommerce')) {
                    printf(' ' . __('by %s', 'woocommerce'), $note->comment_author);
                }
                ?>
						<a href="#" class="delete_note"><?php 
                _e('Delete note', 'woocommerce');
                ?>
</a>
					</p>
				</li>
				<?php 
            }
        } else {
            echo '<li>' . __('There are no notes yet.', 'woocommerce') . '</li>';
        }
        echo '</ul>';
        ?>
		<div class="add_note">
			<h4><?php 
        _e('Add note', 'woocommerce');
        ?>
 <?php 
        echo wc_help_tip(__('Add a note for your reference, or add a customer note (the user will be notified).', 'woocommerce'));
        ?>
</h4>
			<p>
				<textarea type="text" name="order_note" id="add_order_note" class="input-text" cols="20" rows="5"></textarea>
			</p>
			<p>
				<select name="order_note_type" id="order_note_type">
					<option value=""><?php 
        _e('Private note', 'woocommerce');
        ?>
</option>
					<option value="customer"><?php 
        _e('Note to customer', 'woocommerce');
        ?>
</option>
				</select>
				<a href="#" class="add_note button"><?php 
        _e('Add', 'woocommerce');
        ?>
</a>
			</p>
		</div>
		<?php 
    }
/**
 * @deprecated
 */
function woocommerce_date_format()
{
    return wc_date_format();
}