我正在添加WordPress到Woomcommerce电子邮件模板的一个快捷方式。
  
  do_shortcode('[sample_test name="additional_gift_msg"]);
  
   然后我用这个来显示电子邮件中的值。我能显示价值。
  
      function th_email_shortcode_handler( $atts ) {
        if ( ! empty( $atts['name'] ) ) {
            $field = $atts['name'];
            echo 'Found me';
        }
    }
add_shortcode('sample_test','th_email_shortcode_handler');
  
   但我需要
   
    $order
   
   或
   
    $order_id
   
   在这个处理函数中从post meta获取一些值。如何使用这些变量?shortcode handler函数位于functions.php中
  
  
   我也尝试了以下操作,但是$order\u id仍然是空的。
  
  do_shortcode('[sample_test name="additional_gift_msg" order_id=' . $order->get_id() . ']');