0

このクエリで商品データを取得できます。WooCommerce REST API

https://example.com/wc-api/v2/products/3222?consumer_key=ck_my_key&consumer_secret=cs_my_secret

それはこの

{ 
"product": { 
    "title": "Guess Capraz Canta", 
    "id": 3222, 
    "created_at": "2017-06-13T08:33:18Z", 
    "updated_at": "2017-06-13T08:33:18Z", 
    "type": "simple", 
    "status": "publish", 
    "downloadable": false, 
    "virtual": false, 
    "permalink": "https://www.example.com/urun/guess-capraz-canta/", 
    "sku": "", 
    "price": "150.00", 
    "regular_price": "600.00", 
    "sale_price": "150.00", 
    "price_html": "<del><span class=\"woocommerce-Price-amount amount\">600,00&nbsp;<span class=\"woocommerce-Price-currencySymbol\">&#8378;</span></span></del> <ins><span class=\"woocommerce-Price-amount amount\">150,00&nbsp;<span class=\"woocommerce-Price-currencySymbol\">&#8378;</span></span></ins>", 
    "taxable": true, 
    "tax_status": "taxable", 
    "tax_class": "", 
    "managing_stock": true, 
    "stock_quantity": 1, 
    "in_stock": true, 
    "backorders_allowed": false, 
    "backordered": false, 
    "sold_individually": true, 
    "purchaseable": true, 
    "featured": false, 
    "visible": true, 
    "catalog_visibility": "visible", 
    "on_sale": true, 
    "product_url": "", 
    "button_text": "", 
    "weight": null, 
    "dimensions": { 
     "length": "", 
     "width": "", 
     "height": "", 
     "unit": "cm" 
    }, 
    "shipping_required": true, 
    "shipping_taxable": true, 
    "shipping_class": "", 
    "shipping_class_id": null, 
    "description": "<p>Guess Capraz Canta<br />\nSiyah<br />\nUrunde asinmalar mevcut(kapak ic derisinde ve capraz aski halkalarinda renk degisimi)</p>\n", 
    "short_description": "", 
    "reviews_allowed": true, 
    "average_rating": "0.00", 
    "rating_count": 0, 
    "related_ids": [ 
     2689, 
     3087, 
     3067, 
     2540, 
     2785 
    ], 
    "upsell_ids": [], 
    "cross_sell_ids": [], 
    "parent_id": 0, 
    "categories": [ 
     "Çapraz Askılı Çanta" 
    ], 
    "tags": [], 
    "images": [ 
     { 
      "id": 3250, 
      "created_at": "2017-06-13T08:32:43Z", 
      "updated_at": "2017-06-13T08:32:43Z", 
      "src": "https://www.example.com/wp-content/uploads/2017/06/Başlıksız9.jpg", 
      "title": "basliksiz9", 
      "alt": "", 
      "position": 0 
     }, 
     { 
      "id": 3219, 
      "created_at": "2017-06-07T12:51:44Z", 
      "updated_at": "2017-06-07T12:51:44Z", 
      "src": "https://www.example.com/wp-content/uploads/2017/06/IMG_2880.jpg", 
      "title": "img_2880", 
      "alt": "", 
      "position": 1 
     }, 
     { 
      "id": 3220, 
      "created_at": "2017-06-07T12:51:54Z", 
      "updated_at": "2017-06-07T12:51:54Z", 
      "src": "https://www.example.com/wp-content/uploads/2017/06/IMG_2881.jpg", 
      "title": "img_2881", 
      "alt": "", 
      "position": 2 
     }, 
     { 
      "id": 3218, 
      "created_at": "2017-06-07T12:51:35Z", 
      "updated_at": "2017-06-07T12:51:35Z", 
      "src": "https://www.example.com/wp-content/uploads/2017/06/IMG_2878.jpg", 
      "title": "img_2878", 
      "alt": "", 
      "position": 3 
     }, 
     { 
      "id": 3221, 
      "created_at": "2017-06-07T12:52:03Z", 
      "updated_at": "2017-06-07T12:52:03Z", 
      "src": "https://www.example.com/wp-content/uploads/2017/06/IMG_2882.jpg", 
      "title": "img_2882", 
      "alt": "", 
      "position": 4 
     }, 
     { 
      "id": 3217, 
      "created_at": "2017-06-07T12:51:05Z", 
      "updated_at": "2017-06-07T12:51:05Z", 
      "src": "https://www.example.com/wp-content/uploads/2017/06/IMG_2879.jpg", 
      "title": "img_2879", 
      "alt": "", 
      "position": 5 
     } 
    ], 
    "featured_src": "https://www.example.com/wp-content/uploads/2017/06/Başlıksız9.jpg", 
    "attributes": [ 
     { 
      "name": "Renk", 
      "slug": "renk", 
      "position": 0, 
      "visible": true, 
      "variation": false, 
      "options": [ 
       "Siyah" 
      ] 
     }, 
     { 
      "name": "Kullanım Durumu", 
      "slug": "kullanim-durumu", 
      "position": 0, 
      "visible": false, 
      "variation": false, 
      "options": [ 
       "Ortalama" 
      ] 
     }, 
     { 
      "name": "Kargo Durumu", 
      "slug": "kargo-durumu", 
      "position": 0, 
      "visible": false, 
      "variation": false, 
      "options": [ 
       "Alıcı Öder" 
      ] 
     } 
    ], 
    "downloads": [], 
    "download_limit": 0, 
    "download_expiry": 0, 
    "download_type": "", 
    "purchase_note": "", 
    "total_sales": 0, 
    "variations": [], 
    "parent": [] 
} 

}

のようなしかし、私の店は、C2Cであると私は、ベンダー/作者の名前を表示する必要があるため、データを返します。私はWC Vendorsプラグインを複数のベンダに使用し、ベンダ情報は投稿者のセルにあります。

ありがとうございます。

答えて

1

Yey。私はこのように問題を解決しました。

function filter_woocommerce_api_product_response($product_data, $product, $fields, $this_server) { 
    $product_data['vendor_id'] = get_post_field('post_author', $product->id); 
    $product_data['vendor_name'] = get_the_author_meta('display_name', $product_data['vendor_id']); 
     return $product_data; 


};  
add_filter('woocommerce_api_product_response', 'filter_woocommerce_api_product_response', 10, 4); 
関連する問題