开发自定义的WooCommerce付款方式插件

时间:2020-01-10 12:26:23

标签: wordpress woocommerce payment-method wordpress-plugin-creation

我正在为WOoCommerce开发自定义付款方式的插件,其中要在“ public function result()”函数中访问/获取购买的产品ID。 下面是我到目前为止的代码,但是它不起作用;

 public function result() {
        global $woocommerce,$wp;
   $order_id = apply_filters( 'woocommerce_thankyou_order_id', absint( $wp->query_vars['order- 
       received'] ) );
    $orderr = wc_get_order( $order_id );
   $itemss = $orderr->get_items();
   foreach($itemss as $itemm){
    $product_id = $item->get_product_id();
     $authenticationcode =  get_post_meta($product_id, 'authenticationcode', true );
     $merchantcode = get_post_meta($product_id, 'merchantcode', true );
    }}

任何帮助都会非常有帮助。

1 个答案:

答案 0 :(得分:0)

我认为在您的foreach循环中使用了错误的变量。 错误的变量:$ item-> get_product_id();

纠正变量itemm-> get_product_id();