Home > Enterprise >  woocommerce booking and Woocommerce get_customer_note();
woocommerce booking and Woocommerce get_customer_note();

Time:11-30

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.

CodePudding user response:

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;

}

CodePudding user response:

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

CodePudding user response:

Still Nothing https://prnt.sc/213gfpn I did this

<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() );
                                //echo "<pre>order: "; print_r($order); echo "</pre>";
                                $customer_note = $order->get_customer_note();
                                print_r($customer_note);
                                ?></textarea>
                            </p>

Any solution?

  • Related