【问题标题】:How to access custom fields from order in thank you page woocommerce如何在感谢页面 woocommerce 中从订单中访问自定义字段
【发布时间】:2016-06-15 10:39:35
【问题描述】:

我在订单中创建了很多自定义字段,现在我正在尝试在感谢页面上完成订单后访问它们。

我看到了this 的回复,但它对我不起作用。我做了一个 var dump 来查看 $order->order_custom_fields 里面的内容,但我只得到了 string(0) ""

我正在编辑文件 order-details-customer.php 如何访问我的自定义字段?

这是我创建的自定义字段的示例

        woocommerce_form_field( 'destination_state', array(
        'type'          => 'text',
        'class'         => array('destination_state form-row-first'),
        'label'         => __('State'),
        'required'      => true,
        ), $checkout->get_value( 'destination_state' ));

【问题讨论】:

    标签: php wordpress woocommerce


    【解决方案1】:

    经过一番搜索和逻辑思考后,我发现这很容易。

    echo '<p>' . get_post_meta(  $order->id, 'Date Collection', true ) . '</p>';
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-25
      • 1970-01-01
      • 1970-01-01
      • 2015-01-17
      • 1970-01-01
      • 2021-04-04
      相关资源
      最近更新 更多