簡體   English   中英

庫存數量的Woocommerce Rest API問題

[英]Woocommerce Rest API issue with stock quantity

我在離子應用程序中創建Woocommerce產品。 我也想在創建產品時增加庫存量。 但是,庫存始終是空的,存儲在我的MYSQL DB中。 這是JSON feed

{
  "product": {
    "title": "test stock",
    "stock_quantity": "35",
    "images": [],
    "post_author": 88,
    "type": "simple",
    "categories": []
  }
}: 

這是應用程序中的代碼

  var productInfo = {
    title: this.productName,
    regular_price: this.productPrice,
    sale_price: this.productDiscount,
    stock_quantity: this.productStock,
    description: this.productDesc,
    images: new Array<any>(),
    post_author: this.userService.id,
    type: this.productType,
    categories: new Array<any>()
  };

我為stock_quantity嘗試了不同的標簽,例如僅使用“ stock”,並嘗試使用“”將變量推入,而沒有變量。 但是我仍然面臨着同樣的問題。

您的JSON語法正確。 另外,您正在為stock傳遞正確的參數stock_quantity並且當我查看JSON請求時,默認情況下您尚未將manage_stock參數傳遞為true,該參數被視為false。 因此,您還需要傳遞該參數。

您可以嘗試以下代碼。

{
 "product": {
 "title": "test stock",
 "stock_quantity": "35",
 "manage_stock": true,
 "images": [],
 "post_author": 88,
 "type": "simple",
 "categories": []
 }
}: 

您可以引用WooCommerce REST API產品屬性來創建產品

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM