skip to Main Content

I am trying to show get_customer_note(); in woocommerce booking plugin
Everything is working but It is not getting customer notes from orders.
My codee

<p class="form-field form-field-wide">
                                <label for="excerpt"><?php _e( 'Customer provided note', 'woocommerce-bookings' ); ?>:</label>
                                <textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt" placeholder="<?php esc_attr_e( 'Customer notes about the order', 'woocommerce' ); ?>">
                                <?php 
                                $customer_note = $order->get_customer_note();
                                echo wp_kses_post( $customer_note->post_excerpt );
                                ?></textarea>
                            </p>

It is not getting customer notes from woocommerce.

3

Answers


  1. Chosen as BEST ANSWER

    I fixed the issue with this code:

    <p class="form-field form-field-wide">
    
        <label for="excerpt"><?php _e('Customer provided note', 'woocommerce-bookings'); ?>:</label>
        <textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt" placeholder="<?php esc_attr_e('Customer notes about the order', 'woocommerce'); ?>">
            <?php
              $order = wc_get_order($booking->get_order_id());
              $customer_note = $order->get_customer_note();
              echo wp_kses_post($customer_note);
            ?>
        </textarea>
    </p>
    

    I just want to make it so that I can save/update customer notes from woocommerce-booking plugin. instead of going to woocommerce order page. Any ideas???


  2. Get all Customer notes by order id

    //Call fun
    $order_id = 703;
    $_customer_note = cc_get_customer_notes($order_id);
    echo "<pre>_customer_note: "; print_r($_customer_note); echo "</pre>";
    
    /*
    * Get Customer notes
    */
    function cc_get_customer_notes($order_id){
    
      global $wpdb;
    
      $_customer_note_data = array();
    
      $q = "
      SELECT * FROM {$wpdb->prefix}comments 
      WHERE comment_post_ID = '{$order_id}' 
      AND comment_ID IN (
        SELECT comment_id FROM 
        {$wpdb->prefix}commentmeta 
        WHERE meta_key='is_customer_note' 
        AND meta_value=1
      ) 
      ";
    
      $_customer_note = $wpdb->get_results($q);
      if (count($_customer_note) > 0) {
       $_customer_note_data = $_customer_note;
      }
    
      return $_customer_note_data;
    
    }
    
    Login or Signup to reply.
  3. Get Shipping Customer notes

    $order_id = 703;
    $order = wc_get_order( $order_id );
    //echo "<pre>order: "; print_r($order); echo "</pre>";
    $customer_note = $order->get_customer_note();
    echo "<pre>customer_note: "; print_r($customer_note); echo "</pre>";
    

    enter image description here

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search