0

I am development a plugin for custom payment method for WOoCommerce, where in "public function result()" function I want to access/get product id which is bought. Below is my code so far but it is not working;

 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 );
    }}

Any help would be very helpful.

4

1 回答 1

0

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

更正变量 itemm->get_product_id();

于 2020-02-26T13:21:35.663 回答