Giter Site home page Giter Site logo

woocommerce-json-api's Introduction

WooCommerce JSON API

Don't forget to Follow us on Twitter @RedETools

Before you download/use this API

This API is not for end users, sorry. You will need to be tech-savvy to use/install/run it.

Future versions will hopefully be user friendly enough for anyone to make use of it, but this plugin is for developers.

This API is currently under heavy development! While I run the test suite before committing each change, only the get_* methods are guaranteed to work, as they are more or less complete. The set_* methods are currently being retooled based on user requests and feedback. If you want to use this API, expect to pull updates often. And be ready to post issues.

When you post issues, please include extra details like how you are posting to the API, and complete JSON objects and error output that you posted (minus any sensitive details of course.)

You cannot test this code while logged into Wordpress. You will need to log out of wordpress, or open a new incognito window to test the code.

Requires PHP 5.3+

A simple, Abstract JSON API for Wordpress' Awesome Plugin: WooCommerce

Here is an example, using jQuery

    var url = 'http://woo.localhost/c6db13944977ac5f7a8305bbfb06fd6a/?callback=?';
    params = { action: 'woocommerce_json_api', proc:"get_products"};
    params.arguments = {token: 1234, per_page: 10, page: 1}
    jQuery.getJSON(url,params).done(function (data) { console.log(data);});

And here would be the response, trimmed down a bit:

    jQuery171020958687388338149_1373358917457({
        "callback": "jQuery171020958687388338149_1373358917457",
        "action": "woocommerce_json_api",
        "proc": "get_products",
        "arguments": {
            "token": "1234",
            "per_page": "10",
            "page": "1"
        },
        "_": "1373358924670",
        "status": true,
        "errors": [

        ],
        "warnings": [

        ],
        "notifications": [

        ],
        "payload": [
            {
                "id": "1461",
                "name": "Api created product 14",
                "slug": "",
                "type": "product",
                "description": "",
                "status": "",
                "sku": "A349",
                "downloadable": "",
                "virtual": "",
                "manage_stock": "",
                "sold_individually": "",
                "featured": "",
                "allow_backorders": "",
                "quantity": 0,
                "height": "",
                "weight": "",
                "length": "",
                "price": "15.95",
                "regular_price": "15.95",
                "sale_price": "",
                "sale_from": "",
                "sale_to": "",
                "attributes": "",
                "tax_class": "",
                "tax_status": "",
                "categories": [

                ],
                "tags": [

                ],
                "featured_image": false
            },
            ...
            {
                "id": "1279",
                "name": "Bodum Brazil Coffee Press 8 Cup",
                "slug": "bodum-brazil-coffee-press-8-cup",
                "type": "product",
                "description": "<p>Pellentesque habitant morbi ...<\/p>",
                "status": "instock",
                "sku": "W027",
                "downloadable": "no",
                "virtual": "no",
                "manage_stock": "no",
                "sold_individually": "",
                "featured": "no",
                "allow_backorders": "no",
                "quantity": 0,
                "height": "",
                "weight": "",
                "length": "",
                "price": "43",
                "regular_price": "43",
                "sale_price": "",
                "sale_from": "",
                "sale_to": "",
                "attributes": "",
                "tax_class": "",
                "tax_status": "taxable",
                "categories": [
                    {
                        "id": "26",
                        "name": "Coffee &amp; Tea",
                        "slug": "coffee-tea",
                        "description": "",
                        "parent_id": "0",
                        "count": "4",
                        "group_id": "0",
                        "taxonomy_id": "28"
                    },
                    {
                        "id": "41",
                        "name": "Coffee Plungers",
                        "slug": "coffee-plungers",
                        "description": "",
                        "parent_id": "26",
                        "count": "1",
                        "group_id": "0",
                        "taxonomy_id": "43"
                    }
                ],
                "tags": [

                ],
                "featured_image": "http:\/\/woo.localhost\/wp-content\/uploads\/2012\/12\/Bodum-Coffee-Press-1.jpg"
            },
            ...
        ],
        "payload_length": 10
    });

How to install

cd into your wp-content/plugins directory and clone the repo

git clone git://github.com/jasonknight/woocommerce-json-api.git

How to update

cd into your wp-content/plugins/woocommerce-json-api directory and run:

git pull

Visit the Wiki for more Documentation

TODO

woocommerce-json-api's People

Contributors

jasonknight avatar jasonniebauer avatar marksel avatar teambob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

woocommerce-json-api's Issues

Issue With Get Products

When using get_product all variations of the product is being returned as a product.
Would be grateful if this can be looked into.
A sample response of the product variation that is returned is shown below.

         [18] => Array
                (
                    [id] => 110
                    [name] => Variation #110 of TWLC Reach 4 Me
                    [slug] => product-46-variation
                    [type] => product_variation
                    [description] => 
                    [short_description] => 
                    [parent_id] => 46
                    [publishing] => publish
                    [sku] => RED123
                    [downloadable] => no
                    [visibility] => visible
                    [virtual] => no
                    [manage_stock] => no
                    [sold_individually] => no
                    [featured] => no
                    [allow_backorders] => no
                    [quantity] => 15
                    [height] => 
                    [weight] => 
                    [length] => 
                    [price] => 6250
                    [regular_price] => 6500
                    [sale_price] => 6250
                    [sale_from] => 
                    [sale_to] => 
                    [status] => instock
                    [attributes] => Array
                        (
                        )

                    [tax_class] => 
                    [tax_status] => none
                    [product_type] => product
                    [categories] => Array
                        (
                        )

                    [tags] => Array
                        (
                        )

                    [reviews] => Array
                        (
                        )

                    [variations] => Array
                        (
                        )

                    [images] => Array
                        (
                        )

                    [featured_image] => Array
                        (
                        )

                )

Questions and More Requests

Questions

  1. How do i pass the categories and tags when creating a new product.
  2. In what date format should the sale_from and sale_to field be, a date that I set as "2013-09-15" is displayed as "1379203200" how can this be formated to the date I set.
  3. When creating a new product, the price is not displayed when viewing all products in the WP-Admin area, but once the product is viewed the price is shown. But once I edit the product and save it in WP-Admin the price reflects.
  4. How to create a variable product using the API. I would like to create a product that has some variations like Color: Red, Blue and Green and Size: small, Medium and Large. Is this possible with the API.
  5. When viewing products I am seeing some product: "Auto Draft" but they are not visible in WP-Admin, pls what might be the cause. The 'publishing' value is 'auto-draft', they don't have any value set apart from the name. Is this normal.

Requests

  1. Can you add getting and setting a product short description
  2. Support for adding and getting product images
  3. Support for getting product reviews, editing and deleting them.
  4. An option to view orders in the trash, change their status and delete them

Issue with set_products api!

When I tried to add new product by calling proc API "set_products", it created a new post (post_type = post) instead of new product (post_type = product).

I think the reason must be in dynamic_get function (Base class).
I know you set attributes for Product model that way:

'type'                  => array('name' => 'post_type',
                                       'type' => 'string',
                                       'values' => array(
                                                          'product',
                                                          'product_variation'
                                                    ),
                                       'default' => 'product',
                                       'sizehint' => 5
                                  ),

But in dynamic_get function, I don't see you used that default value.
Please let me know your thought if I misunderstand.
Thank you!

I get an error making the getJSON call

Hello and thank you some much for developing this plugin!
I'm really interested in using it since I'm developing a webapp that really needs this plugin. I've tried your example to start working and I don't know why it's not. working.
I've activated the plugin and used your example but it's not working. Sorry to bother you but here is my question on Stackoverflow and my code: http://stackoverflow.com/questions/18500372/getjson-method-returns-an-error-using-woocommerce-json-api-plugin
I would really appreciated if you could help me! Or if not is there any way I can contact you via e-mail or something? Thank you so much!

Cannot work while logged into Wordpress. Why?

Hi,
Could you please explain more why this plugin cannot work while user logged into WP? I really don't understand why. Because I'm in a project that requires adding new product (also adding that one to cart) while user logged or hasn't logged yet. But for now, while user logged, we just get fail. As author of this plugin could you explain more and any chances we can make this plugin work in this case?
Thank you very much! You are doing great job!

Don

Image Issues

The images returned when using get_products have the wrong url and base_url.

In the array shown below the url is that of a multisite install, it shouldn't have the multisite name in this case 'merchant', the url is meant to be returned as http://localhost/cartmultisite/wp-content/uploads/sites/2/2013/10/Mens-Athletic-Fit-150x150.jpg instead of http://localhost/cartmultisite/merchant/wp-content/uploads/sites/2/2013/10/Mens-Athletic-Fit-150x150.jpg.

One other thing is that the month arguments is meant to be 6, but it keeps fetching 10. I tried this in a normal WP install and a multisite install and the same value of 10 is being returned.
The url is meant to be http://localhost/cartmultisite/wp-content/uploads/sites/2/2013/06/Mens-Athletic-Fit-150x150.jpg and not http://localhost/cartmultisite/wp-content/uploads/sites/2/2013/10/Mens-Athletic-Fit-150x150.jpg

(
    [file] => Mens-Athletic-Fit-150x150.jpg
    [width] => 150
    [height] => 150
    [mime-type] => image/jpeg
    [url] => http://localhost/cartmultisite/merchant/wp-content/uploads/sites/2/2013/10/Mens-Athletic-Fit-150x150.jpg
)
[featured_image] => Array
(
    [0] => Array
        (
            [id] => 90
            [filename] => T_1_front
            [slug] => t_1_front
            [mime_type] => image/jpeg
            [type] => attachment
            [description] => 
            [caption] => 
            [parent_id] => 0
            [publishing] => inherit
            [path] => 2013/06/T_1_front.jpg
            [metadata] => Array


[url] => http://localhost/cartdemo/2013/06/T_1_front.jpg


[base_url] => http://localhost/cartdemo/wp-content/uploads/2013/10

I can't make get_products work on Javascript

After changing the URL in the config, I'm able to get products through tests/get_products.php, but completely unable using the Interface or the example in the Wiki. I always get this error:

error: -3: An unexpected error has occured That attribute count does not exist to be set to ''. for WCAPI\Product
Base.php:583:WCAPI\Base
Base.php:205:WCAPI\Base
Base.php:680:WCAPI\Base
Base.php:650:WCAPI\Base
version1.php:529:WCAPI\Base
class-wc-json-api.php:214:WC_JSON_API_Provider_v1
woocommerce-json-api-core.php:185:WooCommerce_JSON_API
Unknown:GlobalScope:GlobalScope
plugin.php:406:GlobalScope
wp-settings.php:329:GlobalScope
wp-config.php:101:GlobalScope
wp-load.php:29:GlobalScope
wp-blog-header.php:12:GlobalScope
index.php:17:GlobalScope

image

Thanks!

Add Image Url to Image Array

Can the image url be added to the images array when getting products.
Initially the image url was part of the array.

[images] => Array
                        (
                            [0] => Array
                                (
                                    [id] => 5
                                    [filename] => dc-shoes-stock-skate-shoes-leather-for-men-in-white-black~p~4625x_01~1500.3
                                    [slug] => dc-shoes-stock-skate-shoes-leather-for-men-in-white-blackp4625x_011500-3
                                    [mime_type] => image/jpeg
                                    [type] => attachment
                                    [description] => 
                                    [caption] => 
                                    [parent_id] => 4
                                    [publishing] => inherit
                                    [path] => 2013/08/dc-shoes-stock-skate-shoes-leather-for-men-in-white-blackp4625x_011500.3.jpg
                                    [metadata] => Array
                                        (
                                            [width] => 1500
                                            [height] => 1500
                                            [file] => 2013/08/dc-shoes-stock-skate-shoes-leather-for-men-in-white-blackp4625x_011500.3.jpg
                                            [sizes] => Array
                                                (
                                                    [thumbnail] => Array
                                                        (
                                                            [file] => dc-shoes-stock-skate-shoes-leather-for-men-in-white-blackp4625x_011500.3-150x150.jpg
                                                            [width] => 150
                                                            [height] => 150
                                                            [mime-type] => image/jpeg
                                                        )

                                                    [medium] => Array
                                                        (
                                                            [file] => dc-shoes-stock-skate-shoes-leather-for-men-in-white-blackp4625x_011500.3-300x300.jpg
                                                            [width] => 300
                                                            [height] => 300
                                                            [mime-type] => image/jpeg
                                                        )

                                                    [large] => Array
                                                        (
                                                            [file] => dc-shoes-stock-skate-shoes-leather-for-men-in-white-blackp4625x_011500.3-1024x1024.jpg
                                                            [width] => 1024
                                                            [height] => 1024
                                                            [mime-type] => image/jpeg
                                                        )

                                                    [post-thumbnail] => Array
                                                        (
                                                            [file] => dc-shoes-stock-skate-shoes-leather-for-men-in-white-blackp4625x_011500.3-604x270.jpg
                                                            [width] => 604
                                                            [height] => 270
                                                            [mime-type] => image/jpeg
                                                        )

                                                    [shop_thumbnail] => Array
                                                        (
                                                            [file] => dc-shoes-stock-skate-shoes-leather-for-men-in-white-blackp4625x_011500.3-90x90.jpg
                                                            [width] => 90
                                                            [height] => 90
                                                            [mime-type] => image/jpeg
                                                        )

                                                    [shop_catalog] => Array
                                                        (
                                                            [file] => dc-shoes-stock-skate-shoes-leather-for-men-in-white-blackp4625x_011500.3-150x150.jpg
                                                            [width] => 150
                                                            [height] => 150
                                                            [mime-type] => image/jpeg
                                                        )

                                                    [shop_single] => Array
                                                        (
                                                            [file] => dc-shoes-stock-skate-shoes-leather-for-men-in-white-blackp4625x_011500.3-300x300.jpg
                                                            [width] => 300
                                                            [height] => 300
                                                            [mime-type] => image/jpeg
                                                        )

                                                )

More String Responses instead of Array

get_coupons -> payload -> product_ids
get_coupons -> payload -> exclude_product_ids

are returned as strings

"payload": [
    {
      "id": "21",
      "code": "cc1",
      "slug": "cc1",
      "type": "shop_coupon",
      "publishing": "publish",
      "discount_type": "fixed_cart",
      "value": "10",
      "is_exclusive": "yes",
      "limit": "100",
      "product_ids": "15,16",
      "exclude_product_ids": "19",
      "expiry_date": "2013-09-25",
      "is_before_tax": "yes",
      "is_shipping_free": "",
      "will_exclude_sale_products": "yes",
      "product_category_ids": [
        13,
        14
      ],
      "exclude_product_category_ids": [
        13,
        14
      ],
      "minimum_total": "3",
      "customer_email": [
        "[email protected]",
        "[email protected]"
      ]
    }
  ],

String Response instead of Array

get_coupons -> payload -> exclude_product_ids

It is a weird string but get_supported_attributes defines it as an Array. Here the raw response:

{
  "action": "woocommerce_json_api",
  "proc": "get_coupons",
  "arguments": {
    "token": "1234"
  },
  "status": true,
  "errors": [],
  "warnings": [],
  "notifications": [],
  "payload": [
    {
      "id": "21",
      "code": "cc1",
      "slug": "cc1",
      "type": "shop_coupon",
      "publishing": "publish",
      "discount_type": "fixed_cart",
      "value": "10",
      "is_exclusive": "yes",
      "limit": "100",
      "product_ids": "s:100:\"s:92:\"s:84:\"s:76:\"s:68:\"s:60:\"s:52:\"s:44:\"s:36:\"s:28:\"s:20:\"s:12:\"s:5:\"16,15\";\";\";\";\";\";\";\";\";\";\";\";\";",
      "exclude_product_ids": "19",
      "expiry_date": "2013-09-25",
      "is_before_tax": "yes",
      "is_shipping_free": "",
      "will_exclude_sale_products": "yes",
      "product_category_ids": [
        13,
        14
      ],
      "exclude_product_category_ids": [
        13,
        14
      ],
      "minimum_total": "3",
      "customer_email": [
        "[email protected]",
        "[email protected]"
      ]
    }
  ],
  "payload_length": 1
}

Access to WP Features

We need read/write in core WP capabilities like

Read/write/delete pages
Read/write/delete posts
Read/write/delete menus
Read/write reading setting (under Settings for WP)
Read/write/delete users
Read/write/delete comments

How can i use this plugin?

Hi guys, I'm a new comer. I try install this plugin but dun know how to use it, i have read though the doc and wiki but no luck. I saw the way you call it in jQuery but i still misunderstand. I want to know which url will be used to call, for example, call to get products maybe uses the url like this www.example.com/api/get_products, please give the short description or references.

Thank a lot.

Error Using The API on a live environment

I was using the API on my local environment and it was working fine.
But when I switch to a live environment for testing all I am getting back is 1.
What might be the cause of this.

Weird customer_email attribute when using set_coupons

The Woocommerce user interface in Wordpress, on the Coupons page, shows a weird customer email address:

a:1:{i:0;s:0:"";}

The request I made:

{
  "action": "woocommerce_json_api",
  "proc": "set_coupons",
  "arguments": {
    "token": "1234"
  },
  "payload": [
    {
      "code": "cc4",
      "slug": "",
      "type": "shop_coupon",
      "publishing": "publish",
      "discount_type": "",
      "value": "",
      "is_exclusive": "yes",
      "limit": "",
      "product_ids": [
        ""
      ],
      "exclude_product_ids": "",
      "expiry_date": "",
      "is_before_tax": "yes",
      "is_shipping_free": "yes",
      "will_exclude_sale_products": "yes",
      "product_category_ids": [
        ""
      ],
      "exclude_product_category_ids": [
        ""
      ],
      "minimum_total": "",
      "customer_email": [
        ""
      ]
    }
  ]
}

Similarly, when I send an email address with it:

      "customer_email": [
        "[email protected]"
      ]

The backend shows:

a:1:{i:0;s:7:"[email protected]";}

Fields in order are pre-filled with data from previous customer

All users coming to site are for some reason automatically signed in as the API user set for this plugin. I restricted all the rights so they cannot change anything.

However, the data in order form are saved to this user account and showed next time someone else comes to the order page. Any idea how to prevent this?

Thanks

Show tags in JSON for get_products

Results should be similar to catagories. Show all tags for each product (not sure about all the fields, what I really need is the name and the slug of a tag).

    ...
      "tax_status": "",
      "categories": [
        {
          "id": "6",
          "name": "Listening",
          "slug": "listening",
          "description": "Description",
          "parent_id": "0",
          "count": "4",
          "group_id": "0",
          "taxonomy_id": "23"
        }
      ],
      "tags": [
        {
          "id": "6",
          "name": "Level 1",
          "slug": "level-1",
          "description": "Description",
          "parent_id": "0",
          "count": "4",
          "group_id": "0",
          "taxonomy_id": "23"
        }
      ]
...

Issue With Variations

[attributes] => Array
(
    [size] => Array
        (
            [name] => Size
            [value] => Array
                (
                    [0] => Small
                    [1] => Medium
                    [2] => Large
                )

            [position] => 1
            [is_visible] => no
            [is_variation] => yes
            [is_taxonomy] => no
        )

)

A variation is usually attached to a attributes.
How can I link a variation to its attribute.

Would really appreciate if you can add a field to link a variation to a attribute.

In the code above I have an attribute called Size, in the code below this are variation that are attached to the Size attribute, but there is no way to link the variation to its attributes.

[variations] => Array
(
    [0] => Array
        (
            [id] => 123
            [name] => Variation #123 of Shoeee
            [slug] => product-26-variation
            [type] => product_variation
            [description] => 
            [short_description] => 
            [parent_id] => 26
            [publishing] => publish
            [sku] => SZ345
            [downloadable] => no
            [visibility] => visible
            [virtual] => no
            [manage_stock] => no
            [sold_individually] => no
            [featured] => no
            [allow_backorders] => no
            [quantity] => 45
            [height] => 
            [weight] => 5
            [length] => 
            [price] => 4800
            [regular_price] => 5000
            [sale_price] => 4800
            [sale_from] => 
            [sale_to] => 
            [status] => instock
            [attributes] => Array
                (
                )

            [tax_class] => 
            [tax_status] => none
            [product_type] => product
            [categories] => Array
                (
                )

            [tags] => Array
                (
                )

            [reviews] => Array
                (
                )

            [variations] => Array
                (
                )

            [images] => Array
                (
                )

            [featured_image] => Array
                (
                )

        )
)

In the app we are building that is leveraging the Woocommerce JSON API, when creating a variation for a product we want to send the following things title of the variation, name of the variation, sku of the variation, price of the product variation and the stock quantity. Because following the example in set_product_variation the attribute isn't passed, but in our case we want to pass an attribute like Size and pass some values along like Small, Medium and Large. The variation that we create we want to link each of them to an attribute value. Like linking a variation to a attribute called Size with a value of Small.

Is there need for us to send an attribute for example size along with the payload data.

You know better, would appreciate if you can explain this clearly.

Issue With get_products

When using get_products it fetches and displays all products along with their variations.
Can an option be added like 'fetch_variations' => 'false' so that only the products are fetched without their variations.

Server-side exception during set_categories

Request:

{
  "action": "woocommerce_json_api",
  "proc": "set_categories",
  "arguments": {
    "token": "1234"
  },
  "payload": [
    {
      "id": {},
      "name": "catnme",
      "slug": "catslug",
      "group_id": "",
      "description": "desc",
      "parent_id": "",
      "count": "",
      "taxonomy": "",
      "taxonomy_id": ""
    }
  ]
}

Apache's error log shows:

 PHP Fatal error:  Call to a member function fromApiArray() on a non-object in /home/michael/Public/projects/woo/woocommerce-json-api/classes/API_VERSIONS/version1.php on line 847, referer: http://localhost/wp-content/plugins/woocommerce-json-api/tests/interface/

Image array returning wrong images on some occasions

Hi Jason,

I hope you can help me out on this one :-)

I just downloaded a new version of your API. I can't find the reason and can't find a bug in your code... but on one product, and only that one, the image array is returning the wrong (and only 3 out of 6) images. The featured image array is returning the right image.

I removed the real website url, but could PM it to you if you wish to have it.

The urls it should return are 3 the following:
http://website.nl/wp-content/uploads/2013/07/SK055-schuin-vooraanzicht.jpg
http://website.nl/wp-content/uploads/2013/07/SK055-vooraanzicht.jpg
http://website.nl/wp-content/uploads/2013/07/SK055-achteraanzicht.jpg

The product id is 211 and the returned object is the following (xCode..):

2013-10-13 22:26:33.802 Test[8704:a0b] Images array is: (
{
alt = "";
caption = "";
description = "";
filename = "SK082 vooraanzicht met licht";
id = 265;
metadata = {
file = "2013/07/SK082-vooraanzicht-met-licht.jpg";
height = 667;
"image_meta" = {
aperture = 0;
camera = "";
caption = "";
copyright = "";
"created_timestamp" = 0;
credit = "";
"focal_length" = 0;
iso = 0;
"shutter_speed" = 0;
title = "";
};
sizes = {
medium = {
file = "SK082-vooraanzicht-met-licht-300x300.jpg";
height = 300;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK082-vooraanzicht-met-licht-300x300.jpg";
width = 300;
};
"shop_catalog" = {
file = "SK082-vooraanzicht-met-licht-150x150.jpg";
height = 150;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK082-vooraanzicht-met-licht-150x150.jpg";
width = 150;
};
"shop_single" = {
file = "SK082-vooraanzicht-met-licht-300x300.jpg";
height = 300;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK082-vooraanzicht-met-licht-300x300.jpg";
width = 300;
};
"shop_thumbnail" = {
file = "SK082-vooraanzicht-met-licht-90x90.jpg";
height = 90;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK082-vooraanzicht-met-licht-90x90.jpg";
width = 90;
};
thumbnail = {
file = "SK082-vooraanzicht-met-licht-150x150.jpg";
height = 150;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK082-vooraanzicht-met-licht-150x150.jpg";
width = 150;
};
};
url = "http://website.nl/wp-content/uploads/2013/07/SK082-vooraanzicht-met-licht.jpg";
width = 667;
};
"mime_type" = "image/jpeg";
"parent_id" = 211;
path = "2013/07/SK082-vooraanzicht-met-licht.jpg";
publishing = inherit;
slug = "sk082-vooraanzicht-met-licht";
type = attachment;
},
{
alt = "";
caption = "";
description = "";
filename = "SK055 vooraanzicht met licht";
id = 266;
metadata = {
file = "2013/07/SK055-vooraanzicht-met-licht.jpg";
height = 667;
"image_meta" = {
aperture = 0;
camera = "";
caption = "";
copyright = "";
"created_timestamp" = 0;
credit = "";
"focal_length" = 0;
iso = 0;
"shutter_speed" = 0;
title = "";
};
sizes = {
medium = {
file = "SK055-vooraanzicht-met-licht-300x300.jpg";
height = 300;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK055-vooraanzicht-met-licht-300x300.jpg";
width = 300;
};
"shop_catalog" = {
file = "SK055-vooraanzicht-met-licht-150x150.jpg";
height = 150;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK055-vooraanzicht-met-licht-150x150.jpg";
width = 150;
};
"shop_single" = {
file = "SK055-vooraanzicht-met-licht-300x300.jpg";
height = 300;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK055-vooraanzicht-met-licht-300x300.jpg";
width = 300;
};
"shop_thumbnail" = {
file = "SK055-vooraanzicht-met-licht-90x90.jpg";
height = 90;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK055-vooraanzicht-met-licht-90x90.jpg";
width = 90;
};
thumbnail = {
file = "SK055-vooraanzicht-met-licht-150x150.jpg";
height = 150;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK055-vooraanzicht-met-licht-150x150.jpg";
width = 150;
};
};
url = "http://website.nl/wp-content/uploads/2013/07/SK055-vooraanzicht-met-licht.jpg";
width = 667;
};
"mime_type" = "image/jpeg";
"parent_id" = 211;
path = "2013/07/SK055-vooraanzicht-met-licht.jpg";
publishing = inherit;
slug = "sk055-vooraanzicht-met-licht";
type = attachment;
},
{
alt = "";
caption = "";
description = "";
filename = "SK052 vooraanzicht met licht";
id = 267;
metadata = {
file = "2013/07/SK052-vooraanzicht-met-licht.jpg";
height = 667;
"image_meta" = {
aperture = 0;
camera = "";
caption = "";
copyright = "";
"created_timestamp" = 0;
credit = "";
"focal_length" = 0;
iso = 0;
"shutter_speed" = 0;
title = "";
};
sizes = {
medium = {
file = "SK052-vooraanzicht-met-licht-300x300.jpg";
height = 300;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK052-vooraanzicht-met-licht-300x300.jpg";
width = 300;
};
"shop_catalog" = {
file = "SK052-vooraanzicht-met-licht-150x150.jpg";
height = 150;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK052-vooraanzicht-met-licht-150x150.jpg";
width = 150;
};
"shop_single" = {
file = "SK052-vooraanzicht-met-licht-300x300.jpg";
height = 300;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK052-vooraanzicht-met-licht-300x300.jpg";
width = 300;
};
"shop_thumbnail" = {
file = "SK052-vooraanzicht-met-licht-90x90.jpg";
height = 90;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK052-vooraanzicht-met-licht-90x90.jpg";
width = 90;
};
thumbnail = {
file = "SK052-vooraanzicht-met-licht-150x150.jpg";
height = 150;
"mime-type" = "image/jpeg";
url = "http://website.nl/wp-content/uploads/2013/07/SK052-vooraanzicht-met-licht-150x150.jpg";
width = 150;
};
};
url = "http://website.nl/wp-content/uploads/2013/07/SK052-vooraanzicht-met-licht.jpg";
width = 667;
};
"mime_type" = "image/jpeg";
"parent_id" = 211;
path = "2013/07/SK052-vooraanzicht-met-licht.jpg";
publishing = inherit;
slug = "sk052-vooraanzicht-met-licht";
type = attachment;
}
)

Issues and Requests

Issues

  1. When using get_orders() all orders that are returned have the same order_status of pending, the right order status of either processing,on-hold, pending, cancelled are not being returned.
  2. Using get_orders(), fetch all orders that have been deleted and are in the trash. An option should be added to enable/disable fetching deleted orders.
  3. Order notes are not being returned when using get_orders().

Requests

  1. Would also appreciate if write access can be added to orders, so that an order status can be updated and order_note added.
  2. Would also appreciate if write access can be added to products, so that a product can be edited.
  3. Can read and write access be added for coupons

Product_Type

When using the set_product method product_type is always set to product, no matter if I specify simple or variable as the value.
The product is created successfuly but the wrong product_type is set.

Output of the get_product_by_id of a product created with set_product

    [id] => 176
    [name] => An API Created Product 6187439
    [slug] => an-api-created-product-6187439
    [type] => product
    [description] => 
    [short_description] => 
    [parent_id] => 0
    [publishing] => publish
    [sku] => API6187439
    [downloadable] => no
    [visibility] => visible
    [virtual] => no
    [manage_stock] => no
    [sold_individually] => no
    [featured] => no
    [allow_backorders] => no
    [quantity] => 
    [height] => 
    [weight] => 
    [length] => 
    [price] => 6.25
    [regular_price] => 6.25
    [sale_price] => 
    [sale_from] => 
    [sale_to] => 
    [status] => instock
    [attributes] => Array
        (
        )

    [tax_class] => 
    [tax_status] => none
    [product_type] => product
    [categories] => Array

Would be grateful if this can be looked into.

Server-side exception logs user in

This is a security risk and also prevents users from making further JSON requests. When a JSON AJAX request is made, the server returns the regular Wordpress HTML

Object Responses instead of Array

Not sure if intentional, but I'll list them anyway:

The following are objects instead of Arrays:

get_shipping_methods -> payload -> settings
get_payment_gateways -> paylaod -> settings
get_store_settings -> payload
get_site_settings -> payload

Featured image/images empty on some occasions

Hi,

Today I found an issue with the images/featured images. I have a release from the 24th of september where the featured image was a string. Now the featured image is an array with metadata and the new image-array is added. On some products, the new featured-image array is empty, while a featured image is actually set. If I change the API to the old (24th) the featured image is set again.

I don't know what could be the cause of the bug but I could give you the URL/api key of the webshop so you can test it yourself. It only occurs on 2 of the 45 products and I made sure the images are set..

Let me know if you want access to test it.

method set_orders not doing anything

No matter which fields I set, set_orders does not return a payload.

I send:

{
  "action": "woocommerce_json_api",
  "proc": "set_orders",
  "arguments": {
    "token": "1234"
  },
  "payload": [
    {
      "name": "name",
      "guid": "guid",
      "order_key": "key",
      "billing_first_name": "firstname",
      "billing_last_name": "lastname",
      "billing_company": "company",
      "billing_address_1": "address1",
      "billing_address_2": "address2",
      "billing_city": "bcity",
      "billing_postcode": "bpc",
      "billing_country": "bc",
      "billing_state": "bs",
      "billing_email": "be",
      "billing_phone": "bp",
      "shipping_first_name": "sfn",
      "shipping_last_name": "sln",
      "shipping_company": "sc",
      "shipping_address_1": "sa1",
      "shipping_address_2": "sa2",
      "shipping_city": "sc",
      "shipping_postcode": "sp",
      "shipping_country": "sc",
      "shipping_state": "ss",
      "shipping_method": "sm",
      "shipping_method_title": "sm",
      "payment_method": "pm",
      "payment_method_title": "pmt",
      "order_discount": "1",
      "cart_discount": "1",
      "order_tax": "1",
      "order_shipping": "1",
      "order_shipping_tax": "1",
      "order_total": "1",
      "customer_user": "1",
      "completed_date": {},
      "status": "completed"
    }
  ]
}

I always get:

{
  "action": "woocommerce_json_api",
  "proc": "set_orders",
  "arguments": {
    "token": "1234"
  },
  "payload": [],
  "status": true,
  "errors": [],
  "warnings": [],
  "notifications": [],
  "payload_length": 0
}

Errors -4 and -7 for proc get_images

I'm getting this, though other models work:

Raw JSON Request

{
  "action": "woocommerce_json_api",
  "proc": "get_images",
  "arguments": {
    "token": "1234",
    "order_by": "name",
    "order": "ASC"
  }
}

Raw JSON Response

{
  "action": "woocommerce_json_api",
  "proc": "get_images",
  "arguments": {
    "token": "",
    "order_by": "name",
    "order": "ASC"
  },
  "status": false,
  "errors": [
    {
      "text": "Permissions for this user have not been set",
      "code": -7
    },
    {
      "text": "Not a valid API User",
      "code": -4
    }
  ],
  "warnings": [],
  "notifications": [],
  "payload": [],
  "payload_length": 0
}

JSONP requests

Great work. Everything works fine. One more detail - I am trying to build a widget for other websites to show products from my eshop. Due the cross-domain restrictions I have to use JSONP. Can you add a JSONP toggle?

The only difference is in the format of the output:

JSON:

{"red" : "#f00"}

JSONP:

jQuery16406345664265099913_1319854793396({"red" : "#f00"})

where jQuery16406345664265099913_1319854793396 is a value from the querystring "callback".

http://stackoverflow.com/a/7941973

PHP error instead of JSON result

I am probably doing something wrong. After following the instructions, this is what I get as a result from the call:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /wp-content/plugins/woocommerce-json-api-master/classes/class-wc-json-api-product.php on line 144

Here is the code I use:

(function() {
  var url = "http://www.mydomain.com/apislug/?callback=?";
    $.getJSON( url, {     
    "action": "woocommerce_json_api",
    "proc": "get_products",
    "arguments": {
        "token": "1234",
        "per_page": 20,
        "page": 1
    }
    })
  .done(function( data ) {
     //more code here
  });
})();

Am I doing something wrong or is it a bug in the code?

Issue with product attributes values returned empty

First of all, thanks for creating this JSON API. It looks awesome.

I have a woocommerce shop with product attributes. Attributes of type "Text". I have tested the get products API Call get_products. Products are returned but attributes values are empty.

I attach you a screenshot that illustrates the issue. Thanks in advanced.

www weco-pirotehnika hr_callback_action_woocommerce_json_api_proc_get_products_arguments_per_page__100_arguments_page__1_arguments_token__6f2ldxomqeerr_and_25_carat___weco_pirotehnika

Registering an user and logging in

Hi,

First of all, thanks for the API, I really like it.

I'm developing a multi-platform app for Woocommerce using your API. I've got an user with the API-key set up by hand. But is it possible to automatically set an API key on registration (e.g. User registers on the website, the API key now is empty, I would like to set it to some value).

Is it also possible to set the default permissions for a newly registered user?

Then the last question... Is there any way to "log the user in" and retrieve the API key?

Thanks in advance!

Issues With set_product

I am trying to assign an already created category to a product by passing the category id, but the category isn't being assigned to the product.
Can this be looked into.

This is how my category argument looks like

'categories'        => array(
       'id                  => 24,
)

Product Vendor in product list

First of all: many thanks for this great plugin. I'm using it for a seperate web-application and works just great.

I'm using the 'Product Vendor' by Matt Gates : http://shop.mgates.me/shop/wc-marketing/wc-product-vendor/ The webshop I made is a single-shop/multi-vendor concept.
What I'would like to have is the product vendor information included in each product definition by get_products(). And maybe in the future: get_product_by_vendor().
If you're not familiar with Product Vendor, I might be able to help.

Thanks in advance.
Best, Gerrit

Error when sending order_by for images

get_api_methods gives the following order_by values:

get_images": {
      "order_by": {
        "type": "string",
        "values": [
          "id",
          "count",
          "name",
          "slug"
        ],
        "default": "name",
        "required": false,
        "sizehint": 1,
        "description": "What column to order results by"
      },

However, when sending

{
  "action": "woocommerce_json_api",
  "proc": "get_images",
  "arguments": {
    "token": "1234",
    "order_by": "name",
    "order": "ASC"
  }
}

i am getting error -5 order_by must be one of these:ID,post_title,post_date,post_author,post_modified

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.