我有这个代码来设置WooCommerce变量
// Defining User set variables
$this->title = $this->get_option( 'title' );
$this->description = $this->get_option( 'description' );
$this->instructions = $this->get_option( 'instructions' );
但如何在 thankyou.php
WooCommerce模板中获取 $this->instructions
?
我已经尝试使用 $order->instructions
,但随后出现错误
注意:说明调用不正确 . 不应直接访问订单属性 . Backtrace:require('wp-blog-header.php'),require_once('wp-includes / template-loader.php'),include('/ themes / startup-company / page.php'),the_content,apply_filters( 'the_content'),WP_Hook-> apply_filters,do_shortcode,preg_replace_callback,do_shortcode_tag,WC_Shortcodes :: checkout,WC_Shortcodes :: shortcode_wrapper,WC_Shortcode_Checkout :: output,WC_Shortcode_Checkout :: order_received,wc_get_template,include('/ plugins / woocommerce / templates / checkout / thankyou.php'),WC_Abstract_Legacy_Order - > __ get,wc_doing_it_wrong请参阅WordPress中的调试以获取更多信息 . (此消息是在3.0版中添加的 . )
所以我试着看看 $order
里面是什么,然后我看到一个很长的变量,它没有我在我自己构建的WooCommerce Payment Gateway插件中为 $this->instructions
设置的文本 .
1 回答
您可以使用
WC_Payment_Gateways
类获得所有Woocommerce付款方式 . 然后你可以得到结账 available 付款方式并以这种方式获取相关数据:测试并在Woocommerce 3中工作