Coder Social home page Coder Social logo

woocommerce / woocommerce-rest-api-docs Goto Github PK

View Code? Open in Web Editor NEW
129.0 102.0 145.0 2.59 MB

WooCommerce REST API Documentation

Home Page: http://woocommerce.github.io/woocommerce-rest-api-docs/

License: Other

JavaScript 88.36% HTML 1.27% Shell 1.53% SCSS 8.84%

woocommerce-rest-api-docs's Introduction

WooCommerce REST API Docs

Repository of documentation REST API WooCommerce.

This project is based on Slate.

Usage

To generate docs run:

./build.sh

To deploy generated docs:

./deploy.sh

woocommerce-rest-api-docs's People

Contributors

aljullu avatar barryhughes avatar belcherj avatar claudiosanches avatar dependabot[bot] avatar gbvaz avatar igorgudelj avatar johnjago avatar julienmelissas avatar kainjow avatar konamiman avatar loranallensmith avatar lsinger avatar luc45 avatar luizreis avatar luminus avatar mac2000 avatar mathiou04 avatar mikejolley avatar mtimbs avatar natesholland avatar peterfabian avatar psavkar avatar rafa-acioly avatar roykho avatar skatox avatar snikch avatar sparkweb avatar vedanshujain avatar xiaofaye 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  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  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  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

woocommerce-rest-api-docs's Issues

Product property dimensions has incorrect type

In the documentation type of the Product property "dimensions" is array but actual (in the result json) type is object. Please notice that Variations property also has "dimensions" property and it also has incorrect type (array instead object).

Property documentation:
dimensions array Product dimensions. See Dimensions properties.

Actual result:
"dimensions": {
"length": "",
"width": "",
"height": ""
},

Create product: unable to set featured image with WooCommerce REST API v3

I'm kind of freaking out with this issue.

We have a huge CSV file and the products should be automatically imported with the rest api.

Everything works fine (Thank you very much, that's pretty awesome):

  • the product has been created
  • all variations, attributes, price etc. are succesfully imported
  • the images were uploaded succesfully and they've also been set to the gallery (with title and alt attributes)

but we still have one issue:

  • Setting image['position'] = 0 to featured image is not working although the image have also been succesfully uploaded.

All other positions are working perfect, it's only about position = 0. Everything is in his place, but the connection between image and featured image of the product is missing/not working.

Notes (if it helps to find the solution):

  • in some cases the position=0 image is uploaded AFTER position = 1 (if it's important)
  • functions the handle this feature (class-wc-api-products.php):
    create_product (250) -> save_product_images (2259) -> upload_image_from_url (2348) -> set_uploaded_image_as_attachment (2437) -> set_post_thumbnail (called in line 2279)

`
<?php

$url = "http://myshop.com/";
$ck = "consumer_key";
$cs = "consumer_secret";

require_once( 'lib/woocommerce-api.php' );

$options = array(
    'debug'           => true,
    'timeout'         => 30,
    'ssl_verify'      => false,
);

try {

    $client = new WC_API_Client( $url, $ck, $cs, $options );
    $data = array(
        //'product' => array(
            'title' => 'Notebook',
            'type' => 'simple',
            'regular_price' => '21.99',
            'description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.',
            'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
            'categories' => array("Notebook"),
            'images' => array(
                array(
                    'src' => 'https://www.it-guenstiger.net/uploads/ipad_1.png',
                    'position' => 0,
                    'title' => 'Notebook',
                    'alt' => 'Notebook'
                ),
                array(
                    'src' => 'https://www.it-guenstiger.net/uploads/home-pc-system.png',
                    'position' => 1,
                    'title' => 'Notebook',
                    'alt' => 'Notebook'
                )
            )
         //)
    );

    print_r($client->products->create($data));

} catch ( WC_API_Client_Exception $e ) {

    echo $e->getMessage() . PHP_EOL;
    echo $e->getCode() . PHP_EOL;

    if ( $e instanceof WC_API_Client_HTTP_Exception ) {

        print_r( $e->get_request() );
        print_r( $e->get_response() );
    }
}

?>

`

I'm testing the code with kloon's rest api client: https://github.com/kloon/WooCommerce-REST-API-Client-Library (changed kloon's version to v3)

WordPress v4.4.2
WooCommerce v2.5.2
nginx v1.8

wp-api/v1: _links

Product properties: '_links' not part of documentation. Should be?

Bad param in NodeJS example wp_api should be wpAPI

The exemple given at this URL : http://woothemes.github.io/woocommerce-rest-api-docs/?javascript#libraries-and-tools mentions a parameter wp_api.
However, when you use it as such, even the Index request fails with error 400:

WooCommerce.get('', function(err, data, res) {
  console.log(data);
});

When we look in data at the path it tries to access we see it tries to talk to /wc-api/wc/v1.
However the documentation for index (http://woothemes.github.io/woocommerce-rest-api-docs/?javascript#index) mentions /wp-json/wc/v1

When we look in the code https://github.com/woothemes/wc-api-node/blob/master/index.js#L99
we see that this wp-json vs. wc-api switch is conditioned by this.wpAPI and we follow it to the init https://github.com/woothemes/wc-api-node/blob/master/index.js#L44
we see that is looks at the wpAPI parameters in the options and NOT wp_api.

Indeed, when we change to the proper wpAPI, then the index call above now works.

http://woothemes.github.io/woocommerce-rest-api-docs/?javascript#libraries-and-tools should instead give the following proper exemple:

// Install:
// npm install --save woocommerce-api

// Setup:
var WooCommerceAPI = require('woocommerce-api');

var WooCommerce = new WooCommerceAPI({
  url: 'http://example.com', // Your store URL
  consumerKey: 'consumer_key', // Your consumer key
  consumerSecret: 'consumer_secret', // Your consumer secret
  wpAPI: true, // Enable the WP REST API integration
  version: 'wc/v1' // WooCommerce WP REST API version
});

Woocommerce REST API v2 Brake changes

we are doing a migration of an ionic app using Woocommerce REST API v1 (WC v2.6) to Woocommerce REST API v2 (WC v3), so we are are looking for a list of breaking changes and we didn't find anything list those BC !! so please can someone share with us.

Index - Meta properties - 'thousand_separator' description is incorrect

On the API Index page there is the Meta Properties section which contains the table with attributes' descriptions.

Description for the thousand_separator attribute says:

The unit set for product weights. Valid units are kg, g, lbs, oz

Instead, it should say something like:

Thousands separator, e.g .

Variable Product - Attributes Properties: options will not accept Cyrillic letters

If you add Cyrillic attributes options from Wordpress - there is no problem:

GET :

"attributes": [
{
"name": "Размер",
"slug": "size",
"position": 0,
"visible": true,
"variation": true,
"options": [
"36",
"37",
"38",
"39",
"40"
]
},
{
"name": "Цвят",
"slug": "colors",
"position": 1,
"visible": true,
"variation": false,
"options": [
"Бежов", <--------------------------------- Great
"Жълт" <--------------------------------- Great
]
},
{
"name": "Тип",
"slug": "product-type",
"position": 3,
"visible": true,
"variation": false,
"options": [
"Боти", <--------------------------------- Great
"Ботуши", <--------------------------------- Great
"Ниски" <--------------------------------- Great
]
}
],

Screenshot:
http://s23.postimg.org/51705tgij/Screenshot_from_2015_10_23_16_45_03.png

But after an update trough the API v3 with the following array: ['тест','тестинг', "test", "danish æøåø"]

I get :
http://s3.postimg.org/if59pbaf7/Screenshot_from_2015_10_23_17_08_51.png

I tried with Postman, I tried unicode,string,ascii ......... Please investigate.

Thank you !

Wrong route to reports top sellers

The route to reports top sellers is describes as being reports/sales/top_sellers whereas it looks to me as it should be reports/top_sellers, right ?

Coupons in Rest API

Hi,

I am using coupons rest api to get the discount in the create order.

Here is what i am passing to create order service
"coupon_lines": [{
"id":4334,
"code":"cstore",
"discount":5
}],

After applying the code i am not getting the discount in order section in admin. Please suggest me what is wrong.

Thanks

UPDATE PRODUCT Method sets price and regular_price to 0.00 ( API v2 + API v3)

GET
{
"product": {
"title": "Дамски боти в черно с връзки и заден цип",
"id": 47655,
"price": "199.00", - THE PRICE IS CORRECT
"regular_price": "199.00", - THE PRICE IS CORRECT
etc .....
etc ...........
}
}

"PUT" :
https://website.com/wc-api/v3/products/47655/?consumer_key=ck&consumer_secret=cs

DATA:

{
"product": {
"regular_price" : "106.00"
}
}

RESPONSE:
{
"product": {
"title": "Дамски боти в черно с връзки и заден цип",
"id": 47655,
"price": "0.00", ???????????? why is it 0 ?
"regular_price": "0.00", ?????????????? why is it 0 ?
etc .....
etc ...........
}
}

I also get frequent GATEWAY TIMEOUT error ........

Please advice or investigate as soon as possible.

Thanks for your efforts.

Best,
Yordan

Login Customer

Hi I'm totally new in woocommerce, I'm trying to do an iOS app using this api. I think all fits except for the login for a customer.

What endpoint should I use if a customer would like to login with his user(or email) and password in the server to get all his details.

Thanks.

Category ID's or names?

In the docs about product properties it says List of product categories names (string). In write-mode need to pass a array of categories IDs (integer) (uses wp_set_object_terms()) But in the examples on how to create a simple product there are lists of names.

Edit: I just tried with ID's and it started creating new categories with the names and slugs of the numbers. So I guess the correct way is to use the category titles. If that is the case then the docs doesn't explain how to assign a product to a sub category like Books/History

Oauth Spec Note

In the Oauth Tips section, the docs say:

Some OAuth libraries add an ampersand to the provided secret key before generating the signature. This does not adhere to the OAuth spec and the ampersand should be removed prior to generating the signature.

I think this is incorrect, though, given the spec at http://oauth.net/core/1.0a/#anchor15:

The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in RFC2104 where the Signature Base String is the text and the key is the concatenated values (each first encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&' character (ASCII code 38) even if empty.

Since Token Secret isn't used by WooCommerce I believe that the standard indicates that the & should be there anyway. So shouldn't the docs indicate that this is against spec? The Guzzle library I was using uses an & in the middle even if empty and had to be patched to make it work against the WooCommerce API.

Webhook request header properties documentation

In the documentation, the webhooks are spelled like this X-WC-Webhook-ID and what we actually receive is X-Wc-Webhook-Id camel case version.

Also, there seems to be a missing one, X-Wc-Webhook-Source.

Variations Properties -> 'images' should be 'image'

According to the class-wc-api-products.php file, the Variations section has an Attribute that is 'image' for the (single) image for the variation.

However, the documentation labels this attribute "images". Spent a while tracking down why my image wasn't uploading for the Variation!

failed with status 400

I am using the exact example provided here:

http://woothemes.github.io/woocommerce-rest-api-docs/?shell#create-an-order

Which failes horribly:

Error: call to URL https://foo.com/wc-api/v3/orders?consumer_key=ck_bc4fd38b21ae4f5c44da3cb8a64ed5a0951e0902&consumer_secret=cs_d6cfb1faf914534955ba1b5e6063577e90610bc3 failed with status 400, response {"errors":[{"code":"woocommerce_api_missing_order_data","message":"Ingen order data angivet for at oprette order"}]}, curl_error , curl_errno 0

The PHP code used is this:

$url = 'https://foo.com/wc-api/v3/orders?consumer_key=ck_bc4fd38b21ae4f5c44da3cb8a64ed5a0951e0902&consumer_secret=cs_d6cfb1faf914534955ba1b5e6063577e90610bc3';

$json_string =
'{
"order": {
"payment_details": {
"method_id": "bacs",
"method_title": "Direct Bank Transfer",
"paid": true
},
"billing_address": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "[email protected]",
"phone": "(555) 555-5555"
},
"shipping_address": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"customer_id": 2,
"line_items": [
{
"product_id": 1389,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": 10
}
]
}
}';

$content = json_encode($json_string);

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$json_response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ( $status != 201 ) {
die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
}

curl_close($curl);

$response = json_decode($json_response, true);

It is so poorly documented how to do this that it is extremely annoying!

Small typo on the API doc

In the "Order Properties" section, "shipping" and "billing"'s type is set to "array" but it should be "object"

Refund property on Order Object

Header should be "Refund line properties", not "Coupon line properties".

Refund Attribute "reason" is returned as "refund".

Filter Products

Hi, how about I have a doubt to filter a serious product, when filter for example by name all very well

` this.wooService.getProducts({ 'filter[name]' : 'Book Discount', }).then((products: Array) => {

  console.log(products);
  this.products = products;
  

  this.loadingModal.dismiss();
}, (reson) => {
  this.loadingModal.dismiss();
  this.errorModal.present();
});

`

But for some strange reason when I write 'filter [on_sale]': 'true' does not search for products with that status

That I have to do to configure the search well, since when I look for po on_sale does not bring anything or there is another way to perform the searches

A greetings and thanks for your time

Documentation for product properties incomplete

In the file class-wc-api-products.php there's this code at line 330

// Product name (slug).
if ( isset( $data['name'] ) ) {
    wp_update_post( array( 'ID' => $id, 'post_name' => sanitize_title( $data['name'] ) ) );
}

It's nowhere in the official documentation that 'name' is a property for a product and that it can be used to set the post_name, that's responsible for the product's url.

IMHO it's definitely worth mentioning in the docs, since modifying the post_name is an urgent feature, and I accidentally found it in the code.

btw. maybe it should also be implemented in the product create function

Auto generating API keys using our Application Authentication Endpoint

I created my wordpress with woo commerce web site. (wordpress 4.7.3, woocommerce 3.0.1)

I'm trying to test the wc-auth endpoint to generate api keys but the endpoint is not even there. In the Wiki it says v1 and on the website v2 and there's a bunch of 404 pages in the Wiki.

Could someone tell how can I enable the endpoint /wc-auth/v2/authorize please?

Get alternate image sizes from product?

Is it possible to get other image sizes than just the original from the REST API?
As i can figure out, the only way would be to get media ID and make another request using the WP API to wp-json/wp/v2/media/ endpoint.
But that seems like an awful lot of get requests, if you're looping through products from woo rest api, and just want to present a smaller image than the uploaded to the user.

So to sum it up - am i missing some obvious way to solve this?

Best regards

Product property grouped_products has incorrect type

In the documentation type of the Product property "grouped_products" is string but actual (in the result json) type is array (probably array of integers).

Property documentation:
grouped_products string List of grouped products ID, only for group type products.

Actual result:
... "grouped_products": [], ...

Creating categories and tags using the woocommerce REST api issue(V3)

Looks like the new V3 does not allow creating of product categories and tags when creating a product using the api:

print_r( $client->products->create( array( 'title' => 'product_name','sku' => 'sku_value', 'type' => 'simple', 'regular_price' => '1000', 'short_description'=>'short description', 'categories' => Array ('category1','category2','category3' ), 'tags'=> array('product_tag'))));

all the other properties are still created but not categories and tags. returns an empty array:

["categories"]=>
array(0) {
}
["tags"]=>
array(0) {
}

so question is: how are categories and tags created using the REST api V3?

Webhook creation requires 'secret' field

Using WooCommerce 2.6.8, Wordpress 4.6.1 on Apache

Calling /wp-json/wc/v1/webhooks with basic-authentication with this payload:

{
  "name": "Any name is valid",
  "topic": "product.created",
  "delivery_url": "http://requestb.in/tizasutj"
}

Returns a 400 response asking for a secret param.
It's stated in the documentation that's optional, and will use the default user's consumer secret

Sort products by price

Hi,

I am using woocommerce rest api for android app. I need to sort products by the price. How can I do that?

I have tried filter but it's not working.

Create Product

I want to create a product with oauth anf javascript (my website protocol is http).
I must use WooCommerce.post('products', data, function(err, data, res)...
but what is the library of "WooCommerce.post" to know this function?

Oauth Tips Clarification

I would recommend a bit of text like this added to the Oauth Tips section:

If including filter fields in your request, it saves a lot of trouble if you can order your filter fields alphabetically before submitting. Many Oauth libraries won't order subquery fields properly, resulting in invalid signatures.

This took me a long time to figure out.

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.