【问题标题】:woocommerce booking and Woocommerce get_customer_note();woocommerce 预订和 Woocommerce get_customer_note();
【发布时间】:2021-11-30 09:15:10
【问题描述】:

我正在尝试显示 get_customer_note();在 woocommerce 预订插件中 一切正常,但没有从订单中获取客户备注。 我的代码

<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>

它没有从 woocommerce 获取客户备注。

【问题讨论】:

  • @gaurav-sharma 你能帮我更新数据吗,它不会更新来自 woocommerce-bookings 插件的客户备注。

标签: php wordpress woocommerce woocommerce-bookings


【解决方案1】:

按订单 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;

}

【讨论】:

  • 还是什么都没有,我想在此处的 woocommerce 预订 prnt.sc/213g270 中显示此 prnt.sc/213g1ys。但它并没有从 woo commerce 插件中获得价值
  • 查看我的下一篇文章
【解决方案2】:

获取运输客户备注

$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>";

【讨论】:

  • 仍然没有显示prnt.sc/213gfpn,它没有获取数据
  • 好的,我知道这是一个预订插件而不是 woocommerce 插件,能否请您分享您用于预订的插件 URL
  • 是的,它的插件,我只想在这个插件订单详情中显示 woocommerce 客户备注woocommerce.com/products/woocommerce-bookings
  • 兄弟你找到解决办法了吗?
  • Woocommerce 预订是付费插件,如果您提供 GitHub 存储库,我无法在我的环境中重现该问题,然后我可以尝试。
【解决方案3】:

我用这段代码解决了这个问题:

<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>

我只是想通过 woocommerce-booking 插件保存/更新客户备注。而不是去 woocommerce 订单页面。有什么想法???

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-24
    • 2019-09-19
    • 2018-08-22
    • 2018-04-21
    • 2021-08-04
    • 2016-03-21
    • 1970-01-01
    相关资源
    最近更新 更多