get_customer_order_notes() 공개 메소드

List order notes (public) for the customer.
public get_customer_order_notes ( ) : array
리턴 array
예제 #1
1
 /**
  * Redirect to allPay
  */
 public function receipt_page($order_id)
 {
     # Clean the cart
     global $woocommerce;
     $woocommerce->cart->empty_cart();
     $order = new WC_Order($order_id);
     try {
         $this->invoke_allpay_module();
         $aio = new AllInOne();
         $aio->Send['MerchantTradeNo'] = '';
         $service_url = '';
         if ($this->allpay_test_mode == 'yes') {
             $service_url = 'http://payment-stage.allpay.com.tw/Cashier/AioCheckOut';
             $aio->Send['MerchantTradeNo'] = date('YmdHis');
         } else {
             $service_url = 'https://payment.allpay.com.tw/Cashier/AioCheckOut';
         }
         $aio->MerchantID = $this->allpay_merchant_id;
         $aio->HashKey = $this->allpay_hash_key;
         $aio->HashIV = $this->allpay_hash_iv;
         $aio->ServiceURL = $service_url;
         $aio->Send['ReturnURL'] = add_query_arg('wc-api', 'WC_Gateway_Allpay', home_url('/'));
         $aio->Send['ClientBackURL'] = home_url('?page_id=' . get_option('woocommerce_myaccount_page_id') . '&view-order=' . $order->id);
         $aio->Send['MerchantTradeNo'] .= $order->id;
         $aio->Send['MerchantTradeDate'] = date('Y/m/d H:i:s');
         # Set the product info
         $aio->Send['TotalAmount'] = $order->get_total();
         array_push($aio->Send['Items'], array('Name' => '網路商品一批', 'Price' => $aio->Send['TotalAmount'], 'Currency' => $order->get_order_currency(), 'Quantity' => 1));
         $aio->Send['TradeDesc'] = 'allPay_module_woocommerce_1_0_3';
         # Get the chosen payment and installment
         $notes = $order->get_customer_order_notes();
         $choose_payment = '';
         $choose_installment = '';
         if (isset($notes[0])) {
             list($choose_payment, $choose_installment) = explode('_', $notes[0]->comment_content);
         }
         $aio->Send['ChoosePayment'] = $choose_payment;
         # Set the extend information
         switch ($aio->Send['ChoosePayment']) {
             case 'Credit':
                 # Do not support UnionPay
                 $aio->SendExtend['UnionPay'] = false;
                 # Credit installment parameters
                 if (!empty($choose_installment)) {
                     $aio->SendExtend['CreditInstallment'] = $choose_installment;
                     $aio->SendExtend['InstallmentAmount'] = $aio->Send['TotalAmount'];
                     $aio->SendExtend['Redeem'] = false;
                 }
                 break;
             case 'WebATM':
                 break;
             case 'ATM':
                 $aio->SendExtend['ExpireDate'] = 3;
                 $aio->SendExtend['PaymentInfoURL'] = $aio->Send['ReturnURL'];
                 break;
             case 'CVS':
             case 'BARCODE':
                 $aio->SendExtend['Desc_1'] = '';
                 $aio->SendExtend['Desc_2'] = '';
                 $aio->SendExtend['Desc_3'] = '';
                 $aio->SendExtend['Desc_4'] = '';
                 $aio->SendExtend['PaymentInfoURL'] = $aio->Send['ReturnURL'];
                 break;
             case 'Alipay':
                 $aio->SendExtend['Email'] = $order->billing_email;
                 $aio->SendExtend['PhoneNo'] = $order->billing_phone;
                 $aio->SendExtend['UserName'] = $order->billing_first_name . ' ' . $order->billing_last_name;
                 break;
             case 'Tenpay':
                 $aio->SendExtend['ExpireTime'] = date('Y/m/d H:i:s', strtotime('+3 days'));
                 break;
             case 'TopUpUsed':
                 break;
             default:
                 throw new Exception($this->tran('Invalid payment method.'));
                 break;
         }
         $aio->CheckOut();
         exit;
     } catch (Exception $e) {
         $this->add_error($e->getMessage());
     }
 }
    /**
     * Output the shortcode.
     *
     * @access public
     * @param array $atts
     * @return void
     */
    public static function output($atts)
    {
        global $woocommerce;
        $woocommerce->nocache();
        if (!is_user_logged_in()) {
            return;
        }
        extract(shortcode_atts(array('order_count' => 10), $atts));
        $user_id = get_current_user_id();
        $order_id = isset($_GET['order']) ? $_GET['order'] : 0;
        $order = new WC_Order($order_id);
        if ($order_id == 0) {
            woocommerce_get_template('myaccount/my-orders.php', array('order_count' => 'all' == $order_count ? -1 : $order_count));
            return;
        }
        if ($order->user_id != $user_id) {
            echo '<div class="woocommerce-error">' . __('Invalid order.', 'woocommerce') . ' <a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">' . __('My Account &rarr;', 'woocommerce') . '</a>' . '</div>';
            return;
        }
        $status = get_term_by('slug', $order->status, 'shop_order_status');
        echo '<p class="order-info">' . sprintf(__('Order <mark class="order-number">%s</mark> made on <mark class="order-date">%s</mark>', 'woocommerce'), $order->get_order_number(), date_i18n(get_option('date_format'), strtotime($order->order_date))) . '. ' . sprintf(__('Order status: <mark class="order-status">%s</mark>', 'woocommerce'), __($status->name, 'woocommerce')) . '.</p>';
        $notes = $order->get_customer_order_notes();
        if ($notes) {
            ?>
			<h2><?php 
            _e('Order Updates', 'woocommerce');
            ?>
</h2>
			<ol class="commentlist notes">
				<?php 
            foreach ($notes as $note) {
                ?>
				<li class="comment note">
					<div class="comment_container">
						<div class="comment-text">
							<p class="meta"><?php 
                echo date_i18n(__('l jS \\of F Y, h:ia', 'woocommerce'), strtotime($note->comment_date));
                ?>
</p>
							<div class="description">
								<?php 
                echo wpautop(wptexturize($note->comment_content));
                ?>
							</div>
			  				<div class="clear"></div>
			  			</div>
						<div class="clear"></div>
					</div>
				</li>
				<?php 
            }
            ?>
			</ol>
			<?php 
        }
        do_action('woocommerce_view_order', $order_id);
    }
    /**
     * View order page
     *
     * @param  int $order_id
     */
    private static function view_order($order_id)
    {
        $user_id = get_current_user_id();
        $order = new WC_Order($order_id);
        if (!current_user_can('view_order', $order_id)) {
            echo '<div class="woocommerce-error">' . __('Invalid order.', 'woocommerce') . ' <a href="' . get_permalink(wc_get_page_id('myaccount')) . '" class="wc-forward">' . __('My Account', 'woocommerce') . '</a>' . '</div>';
            return;
        }
        $status = get_term_by('slug', $order->status, 'shop_order_status');
        echo '<p class="order-info">' . sprintf(__('Order <mark class="order-number">%s</mark> was placed on <mark class="order-date">%s</mark> and is currently <mark class="order-status">%s</mark>.', 'woocommerce'), $order->get_order_number(), date_i18n(get_option('date_format'), strtotime($order->order_date)), __($status->name, 'woocommerce')) . '</p>';
        if ($notes = $order->get_customer_order_notes()) {
            ?>
			<h2><?php 
            _e('Order Updates', 'woocommerce');
            ?>
</h2>
			<ol class="commentlist notes">
				<?php 
            foreach ($notes as $note) {
                ?>
				<li class="comment note">
					<div class="comment_container">
						<div class="comment-text">
							<p class="meta"><?php 
                echo date_i18n(__('l jS \\o\\f F Y, h:ia', 'woocommerce'), strtotime($note->comment_date));
                ?>
</p>
							<div class="description">
								<?php 
                echo wpautop(wptexturize($note->comment_content));
                ?>
							</div>
			  				<div class="clear"></div>
			  			</div>
						<div class="clear"></div>
					</div>
				</li>
				<?php 
            }
            ?>
			</ol>
			<?php 
        }
        do_action('woocommerce_view_order', $order_id);
    }
예제 #4
0
				<table class="customer_note"> 
					<tbody>
					  <tr>
					  	<td colspan="100%">
								<p>
									<?php 
        echo $customer_note ? $customer_note : __('No customer note.', $WCMp->text_domain);
        ?>
								</p>
							</td>
						</tr>
					</tbody>
				</table>
			<?php 
        if ($WCMp->vendor_caps->vendor_capabilities_settings('is_vendor_view_comment')) {
            $vendor_comments = $order->get_customer_order_notes();
            if ($vendor_comments) {
                ?>
				<h2><?php 
                _e('Comments', $WCMp->text_domain);
                ?>
</h2>
				<?php 
                foreach ($vendor_comments as $comment) {
                    $last_added = human_time_diff(strtotime($comment->comment_date_gmt), current_time('timestamp', 1));
                    ?>
						<p>
							<?php 
                    printf(__('Added %s ago', $WCMp->text_domain), $last_added);
                    ?>
							</br>
예제 #5
0
 /**
  * Test: get_customer_order_notes
  */
 function test_get_customer_order_notes()
 {
     $object = new WC_Order();
     $id = $object->save();
     $this->assertCount(0, $object->get_customer_order_notes());
     $object->add_order_note("Hello, I am a fish", true);
     $object->add_order_note("Hello, I am a fish", false);
     $object->add_order_note("Hello, I am a fish", true);
     $this->assertCount(2, $object->get_customer_order_notes());
 }
    /**
     *  Get Orders to display in admin 
     *
     * @return $orders
     */
    function get_orders()
    {
        $user_id = get_current_user_id();
        $orders = array();
        $vendor_products = $this->get_vendor_products($user_id);
        $products = array();
        foreach ($vendor_products as $_product) {
            $products[] = $_product->ID;
        }
        $_orders = $this->get_orders_for_vendor_products($products);
        $model_id = 0;
        if (!empty($_orders)) {
            foreach ($_orders as $order) {
                $order = new WC_Order($order->order_id);
                $valid_items = WCV_Queries::get_products_for_order($order->id);
                $valid = array();
                $items = $order->get_items();
                foreach ($items as $key => $value) {
                    if (in_array($value['variation_id'], $valid_items) || in_array($value['product_id'], $valid_items)) {
                        $valid[] = $value;
                    }
                }
                $products = '';
                foreach ($valid as $key => $item) {
                    $item_meta = new WC_Order_Item_Meta($item['item_meta']);
                    // $item_meta = $item_meta->display( false, true );
                    $item_meta = $item_meta->get_formatted();
                    $products .= '<strong>' . $item['qty'] . ' x ' . $item['name'] . '</strong><br />';
                    foreach ($item_meta as $key => $meta) {
                        // Remove the sold by meta key for display
                        if (strtolower($key) != 'sold by') {
                            $products .= $meta['label'] . ' : ' . $meta['value'] . '<br />';
                        }
                    }
                }
                $shippers = (array) get_post_meta($order->id, 'wc_pv_shipped', true);
                $shipped = in_array($user_id, $shippers) ? 'Yes' : 'No';
                $sum = WCV_Queries::sum_for_orders(array($order->id), array('vendor_id' => get_current_user_id()));
                $total = $sum[0]->line_total;
                $comment_output = '';
                //  Need to fix how form is submitted for adding comments if at all possible.
                if ($this->can_view_comments) {
                    $order_notes = $order->get_customer_order_notes();
                    $comment_output .= '<a href="#TB_inline?width=600&height=550&inlineId=order-comment-window-' . $model_id . '" class="thickbox">';
                    $comment_output .= sprintf(__('Comments (%s)', 'wcvendors'), count($order_notes));
                    $comment_output .= '</a>';
                    $comment_output .= '<div id="order-comment-window-' . $model_id . '" style="display:none;">';
                    $comment_output .= '<h3>' . __('Comments to Customer', 'wcvendors') . '</h3>';
                    if (!empty($order_notes)) {
                        foreach ($order_notes as $order_note) {
                            $last_added = human_time_diff(strtotime($order_note->comment_date_gmt), current_time('timestamp', 1));
                            $comment_output .= '<p>';
                            $comment_output .= $order_note->comment_content;
                            $comment_output .= '<br />';
                            $comment_output .= sprintf(__('added %s ago', 'wcvendors'), $last_added);
                            $comment_output .= '<br />';
                            $comment_output .= '</p>';
                        }
                    } else {
                        $comment_output .= '<p>' . __('No comments currently to customer.', 'wcvendors') . '</p>';
                    }
                    if ($this->can_add_comments) {
                        $comment_output .= wp_nonce_field('add-comment');
                        $comment_output .= '
							<textarea name="comment_text" style="width:97%"></textarea>
							<input type="hidden" name="order_id" value="' . $order->id . '">
							<input type="hidden" name="action" value="add_comment">
							<input class="btn btn-large btn-block" type="submit" name="submit_comment" value="' . __('Add comment', 'wcvendors') . '">';
                    }
                    $comment_output .= '</div>';
                }
                $order_items = array();
                $order_items['order_id'] = $order->id;
                $order_items['customer'] = $order->get_formatted_shipping_address();
                $order_items['products'] = $products;
                $order_items['total'] = woocommerce_price($total);
                $order_items['date'] = date_i18n(wc_date_format(), strtotime($order->order_date));
                // $order_items[ 'comments' ]  = $comment_output;
                $order_items['status'] = $shipped;
                $orders[] = (object) $order_items;
                $model_id++;
            }
        }
        return $orders;
    }
/**
 * View Order Shortcode
 *
 * @package WooCommerce
 * @since 1.4
 */
function woocommerce_view_order()
{
    global $woocommerce;
    woocommerce_nocache();
    if (!is_user_logged_in()) {
        return;
    }
    $user_id = get_current_user_id();
    $order_id = isset($_GET['order']) ? $_GET['order'] : 0;
    $order = new WC_Order($order_id);
    if ($order_id == 0 || $order->user_id != $user_id) {
        echo '<div class="woocommerce_error">' . __('Invalid order.', 'woocommerce') . ' <a href="' . get_permalink(woocommerce_get_page_id('myaccount')) . '">' . __('My Account &rarr;', 'woocommerce') . '</a>' . '</div>';
        return;
    }
    $status = get_term_by('slug', $order->status, 'shop_order_status');
    echo '<p>' . sprintf(__('Order <mark>#%s</mark> made on <mark>%s</mark>', 'woocommerce'), $order->id, date_i18n(get_option('date_format'), strtotime($order->order_date))) . sprintf(__('. Order status: <mark>%s</mark>', 'woocommerce'), __($status->name, 'woocommerce')) . '.</p>';
    $notes = $order->get_customer_order_notes();
    if ($notes) {
        ?>
		<h2><?php 
        _e('Order Updates', 'woocommerce');
        ?>
</h2>
		<ol class="commentlist notes">	
			<?php 
        foreach ($notes as $note) {
            ?>
			<li class="comment note">
				<div class="comment_container">			
					<div class="comment-text">
						<p class="meta"><?php 
            echo date_i18n('l jS \\of F Y, h:ia', strtotime($note->comment_date));
            ?>
</p>
						<div class="description">
							<?php 
            echo wpautop(wptexturize($note->comment_content));
            ?>
						</div>
		  				<div class="clear"></div>
		  			</div>
					<div class="clear"></div>			
				</div>
			</li>
			<?php 
        }
        ?>
		</ol>
		<?php 
    }
    do_action('woocommerce_view_order', $order_id);
}