如何获取woocommerce订单说明

时间:2020-03-31 23:56:33

标签: angular wordpress woocommerce

我正在尝试使用woocommerce API'/ wp-json / wc / v3 / orders / id> / notes'检索Woocommerce订单记录,但出现此错误“ woocommerce_rest_shop_order_invalid_id”

这是我的代码

myservice.service.ts

  siteUrl:string ='https://example.com';
  apiUrl:string ='';
  woocommercePath:string ='/wp-json/wc/v3/';
  ordersByCustomer:any ;

    getOrderNote(orderId){ 
        this.apiUrl = `${this.siteUrl}${this.woocommercePath}orders/${orderId}/notes?consumer_key=${this.consumerKey}&consumer_secret=${this.consumerSecret}`;
        console.log('API URL for order: ', this.apiUrl);
        this.ordersByCustomer = this.http.get( this.apiUrl); 
        return this.ordersByCustomer;  
    } 

我不知道我在哪里弄错了

我的ordernote.ts文件

@Component({
  selector: 'app-notifications',
  templateUrl: './notifications.page.html',
  styleUrls: ['./notifications.page.scss'],
})
export class NotificationsPage implements OnInit {

 orderNotes: any;

  constructor(private WC: WoocommerceService) { }

  ngOnInit() {
    let isUserLoggedIn = localStorage.getItem('currentUserId');
    this.WC.getOrderNote(isUserLoggedIn).subscribe((data)=>{
      this.orderNotes = data;
      console.log('All Orders Note by a customer', this.orderNotes);
    });
  }

}

0 个答案:

没有答案
相关问题