explanation of issue
i using https://github.com/woocommerce/wc-api-php query woo commerce api.
it using php curl , json decode answer below, array not returning data, being lost, , think in php settings or sever settings.
i have had else test https://github.com/woocommerce/wc-api-php , working correctly.
when try on postman working correctly,
something in settings or dependency wrong?
please help!
call print_r($woocommerce->get('products')
expected:
"categories": [ { "id": 9, "name": "clothing", "slug": "clothing" },
received: returning name...
["categories"]=> array(1) { [0]=> string(9) "chainsaws" }
which no because there can 5 categories same name.
how return id shows in documentation.
steps reproduce issue
when call
http://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-products
<?php print_r($woocommerce->get('products')); ?>
i returned:
```
array(2) { ["product"]=> array(58) { ["title"]=> string(14) "tooline prod 1" ["id"]=> int(103) ["created_at"]=> string(20) "2017-04-01t01:50:28z" ["updated_at"]=> string(20) "2017-04-01t01:51:20z" ["type"]=> string(6) "simple" ["status"]=> string(5) "trash" ["downloadable"]=> bool(false) ["virtual"]=> bool(false) ["permalink"]=> string(65) "http://localhost:84/wordpress/product/tooline-prod-1__trashed-32/" ["sku"]=> string(14) "tooline prod 1" ["price"]=> string(4) "0.00" ["regular_price"]=> string(4) "0.00" ["sale_price"]=> null ["price_html"]=> string(0) "" ["taxable"]=> bool(true) ["tax_status"]=> string(7) "taxable" ["tax_class"]=> string(0) "" ["managing_stock"]=> bool(false) ["stock_quantity"]=> int(0) ["in_stock"]=> bool(true) ["backorders_allowed"]=> bool(false) ["backordered"]=> bool(false) ["sold_individually"]=> bool(false) ["purchaseable"]=> bool(false) ["featured"]=> bool(false) ["visible"]=> bool(true) ["catalog_visibility"]=> string(7) "visible" ["on_sale"]=> bool(false) ["product_url"]=> string(0) "" ["button_text"]=> string(0) "" ["weight"]=> null ["dimensions"]=> array(4) { ["length"]=> string(1) "0" ["width"]=> string(1) "0" ["height"]=> string(1) "0" ["unit"]=> string(2) "cm" } ["shipping_required"]=> bool(true) ["shipping_taxable"]=> bool(true) ["shipping_class"]=> string(0) "" ["shipping_class_id"]=> null ["description"]=> string(22) " test tl prod 1 " ["short_description"]=> string(20) " uyyiryiryiyu " ["reviews_allowed"]=> bool(true) ["average_rating"]=> string(4) "0.00" ["rating_count"]=> int(0) ["related_ids"]=> array(1) { [0]=> int(104) } ["upsell_ids"]=> array(0) { } ["cross_sell_ids"]=> array(0) { } ["parent_id"]=> int(0) ["categories"]=> array(1) { [0]=> string(9) "chainsaws" } ["tags"]=> array(0) { } ["images"]=> array(2) { [0]=> array(7) { ["id"]=> int(102) ["created_at"]=> string(20) "2017-04-01t01:45:16z" ["updated_at"]=> string(20) "2017-04-01t01:45:16z" ["src"]=> string(70) "http://localhost:84/wordpress/wp-content/uploads/2017/04/image-17.jpeg" ["title"]=> string(0) "" ["alt"]=> string(0) "" ["position"]=> int(0) } [1]=> array(7) { ["id"]=> int(101) ["created_at"]=> string(20) "2017-04-01t01:45:15z" ["updated_at"]=> string(20) "2017-04-01t01:45:15z" ["src"]=> string(70) "http://localhost:84/wordpress/wp-content/uploads/2017/04/image-16.jpeg" ["title"]=> string(0) "" ["alt"]=> string(0) "" ["position"]=> int(1) } } ["featured_src"]=> string(70) "http://localhost:84/wordpress/wp-content/uploads/2017/04/image-17.jpeg" ["attributes"]=> array(0) { } ["downloads"]=> array(0) { } ["download_limit"]=> int(0) ["download_expiry"]=> int(0) ["download_type"]=> string(0) "" ["purchase_note"]=> string(0) "" ["total_sales"]=> int(0) ["variations"]=> array(0) { } ["parent"]=> array(0) { } }
``` according documentation should displayed in format: http://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-products
``` "categories": [ { "id": 9, "name": "clothing", "slug": "clothing" },
but returning name...
["categories"]=> array(1) { [0]=> string(9) "chainsaws" }
which no because there can 5 categories same name.
how return id shows in documentation.
when use postman works fine?
`
Comments
Post a Comment