Git Product home page Git Product logo

wc-api-dev's Introduction

wc-api-dev's People

Contributors

allendav avatar budzanowski avatar claudiosanches avatar claudiulodro avatar coderkevin avatar jameskoster avatar jeffstieler avatar justinshreve avatar ryelle avatar timmyc 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

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

wc-api-dev's Issues

Media Endpoint [ Idea / Suggestion ]

Woo supports adding downloadable files for products, but right now there is no way to upload this files using woo rest api.

Same issue for images / gallery / featured image.
(You can clone an image from an url though, but not upload from Desktop)

Surely you can use wp-json/wp/v2/media, but that needs additional permission -
Ref: woocommerce/woocommerce#19730 (comment)

What about adding a clone of this endpoint to Woo, or just open up for this specific endpoint through Woo oauth as an exception from the other WP Endpoints ?

Fetching customers with specific username gets all the customers

Steps to reproduce the issue:

  1. conduct a get request to fetch customers
  2. add username="value" as a query parameter
  3. log the the returned customers

Expected/actual behavior:

When I follow those steps, I see the list of the whole customers returned

I was expecting to see only the list of the customers whose usernames match the passed query value

Adding and removing coupons from orders, with calculation

Related to woocommerce/woocommerce#18236

The current API supports the old way of updating coupons - manually. You handle both the update of line item prices, and the setting of the discount total.

Ref https://woocommerce.github.io/woocommerce-rest-api-docs/#order-properties where discount_total is defined in the API call.

For the next version of the API it would be great to add a new method or endpoint to apply a coupon (or remove a coupon) from an order and have everything done for you, in the same way you can now apply/remove coupons in WP admin by entering the coupon code.

cc @claudiulodro @claudiosanches for endpoint feedback. What would be the optimal solution?

Ability to fetch a list of orders matching more than one status, bonus using a status search wildcard

Currently the Woo API endpoint for /orders only allows filtering by a single order status. It would be helpful if we could pass in a list or array of order statuses to match results on. Example:

"status":"processing, pending, on-hold"

or

"status":{"processing", "pending", "on-hold"}

An even cooler feature would be to allow for wildcard matching on an order status filter:

"status":"wc-%"

in this example above the % would be the wildcard and an example of statuses it would match would be:

  • wc-new-order
  • wc-yay
  • wc-red

Thanks!

New endpoint to get woo order statuses

There is a generic post status API available, so this one would be lower priority. It would just be nice to not have to pull all the post statuses and then filter out by just the ones prefixed with 'wc-`.

Ideally the results would provide enough information so we know which ones are custom and which ones are core. An example of a result may look like this:

data: [{
	"id":1,
	"status":"processing",
	"label":"Processing",
	"is_core":true
},{
	"id": 200,
	"status":"wc-gold",
	"label":"Gold Status",
	"is_core":false,
	"created_by":{
		{
		  "type": "plugin",
		  "name": "WooCommerce",
		  "url": "https://woocommerce.com/",
		  "author_name": "Automattic"
		}
	}
}]

I'm still learning about all that's available so if anything crucial is missing or something doesn't make sense, feel free to add or change as necessary.

Support for hourly stats granularity

With some new stats endpoints being worked on, perhaps an hour-by-hour sales/revenue/etc breakdown by day could be one of the options added to the API?

(This has come up in the context of the mobile apps.)

woocommerce_rest_product_query in V2

I have implemented the following filter to be able to query post_modified:

//Filter to add new query args
add_filter( "woocommerce_rest_product_query", array( $this, 'custom_product_query_args' ), 10, 3 ); 
/**
 * Add new query args to products.
 */
function custom_product_query_args( $args, $request ) {
	if ( isset( $request['modify_before'] ) ) {
		$args['date_query']['cds_modify_date']['before'] = $request['modify_before'];
		$args['date_query']['cds_modify_date']['column'] = 'post_modified';
	}

	if ( isset( $request['modify_after'] ) ) {
		$args['date_query']['cds_modify_date']['after'] = $request['modify_after'];
		$args['date_query']['cds_modify_date']['column'] = 'post_modified';
	}
	return $args;
}

It works great with V1 of the api, but doesn't seems to work with V2. Am I doing something wrong?

Ability to set 'onbackorder' stock status for products

Related to woocommerce/woocommerce#11259

WC 3.3 introduces a new 'onbackorder' stock status for products.

For products that have stock management enabled the status automatically gets changed to 'onbackorder' when inventory is below 0 and backorders are allowed, so we don't have to do anything special for that situation.

For products that don't have stock management enabled, there is no way to set the 'onbackorder' status through the API.

Here are two relevant product properties from the API:

in_stock | boolean | Controls whether or not the product is listed as “in stock” or “out of stock” on the frontend. Default is true. (No way to make this toggle between 'instock', 'outofstock', and 'onbackorder' statuses)

backordered | boolean | Shows if the product is on backordered.READ-ONLY (This is read only)

I think we have a few potential options here:

  1. Make the backordered property not read only and set 'onbackorder' status if it is true.
  2. Deprecate in_stock in favor of a new param called stock_status. This will let us use any current or future stock statuses.
  3. Make valid params for in_stock be true, false, and onbackorder.

These changes would be for API v3.

Retrieve orders by date modified in 3.6

In this #65 thread it is mentioned that filtering by date_modified in the REST API would be available in WooCommerce 3.6, but after reading the change log I could not seem to find it mentioned?

Will WooCommerce 3.6 support this feature? We have been waiting for it for a long time, and it is pretty critical for our integration.

I opened a new issue because commenting was limited to collaborators on the other thread.

After/before date filtering does not fully support ISO 8601

This is a known WP core issue: https://core.trac.wordpress.org/ticket/41032 which was logged here:

woocommerce/woocommerce#19976

As the support for the ISO 8601 spec of date format is not quite correct, you cannot specify the timezone that the date is transmitted in. As such I propose that all dates are assumed to be UTC and are handled as such even when the default timezone is not running in UTC. Alternatively, proper implementation of the ISO 8601 spec would allow for the timezone to be sent along with the DateTime of such filters.

It might be possible to work around this and handle after/before timezone conversion our side. Needs investigation.

How to contribute in WC API?

Hello,
I have known about the WooCommerce API. I want to contribute in it.
I have cloned this code in wp-content/plugins.
I have checked the get products API via postman.
If I am changing in this plugin code that not affect in API.
So how can I check it with postman?

API - woocommerce_currency should return separate field for symbol

When using the wc-api to get general settings /wc/v2/settings/general, the woocommerce_currency object has an options array that has the following format:

{AED: "United Arab Emirates dirham (د.إ)"}

This results in having to use a regex to separate the country and currency name from the currency symbol.

I propose that the options object should take this format:

{ AED: { country: "United Arab Emirates", currency: "dirham", symbol: "د.إ" } }

It may be good to look into a data endpoint instead/in addition, since this is a setting, not a way to get the correct symbol.

From woocommerce/woocommerce#15101

Excluding subscriptions from /orders

Hey there!

I need to make a GET at /orders that only return unique orders (that are not subscriptions). That filter is currently showing in the WooCommerce dashboard:

screen_shot_2017-07-18_at_3_30_04_pm

However, I can't seem to find a way to do it via the REST API, is that currently doable? The only solution I can think of right now is to remove the subscriptions client-side but because of the paging that is extremely inconvenient.

Cheers

Unit Test Failures (2): Product Variations get_parent_id()

Observed with today's master against today's WooCommerce master

wc-api-dev $ phpunit
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Installing WooCommerce...
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 4.8.7 by Sebastian Bergmann and contributors.

Runtime:	PHP 5.6.29
Configuration:	/Users/allendav/Sites/localhost/wc32_us/wp-content/plugins/wc-api-dev/phpunit.xml
Warning:	The Xdebug extension is not loaded
		No code coverage will be generated.

...............................................................  63 / 220 ( 28%)
...........E..........F.F..............................PHP Fatal error:  Call to a member function get_parent_id() on boolean in /Users/allendav/Sites/localhost/wc32_us/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-variations-controller.php on line 168

Fatal error: Call to a member function get_parent_id() on boolean in /Users/allendav/Sites/localhost/wc32_us/wp-content/plugins/woocommerce/includes/api/class-wc-rest-product-variations-controller.php on line 168

Refunds; add ability to refund line items

Reported in woocommerce/woocommerce#18573

Most of the line item props are read only in API v2, and it's actually not possible to refund line items because there is no way to map them to line items in the parent order.

Core does record the link between order line items and refund line items, in meta, so this could be exposed.

  • Most of the props are readonly - https://woocommerce.github.io/woocommerce-rest-api-docs/#order-refund-properties This should be revised. Product ID and so on should probably be read only so they always match the parent order.
  • It's completely broken in v2 because some of the props do not match what core expects e.g. qty vs quantity.
  • We need to return and allow the user to define _refunded_item_id to link refunded line to order line. This needs to be validated to ensure the line exists in the order.

cc @claudiosanches

General Api missing a lot of features.

Can we have some api to calculate tax, filter shipping method based on country, state, zip code inputs. I am trying to use the api to make same features as woocommerce checkout page. The countries and states for billing and shipping should be dynamic based on the general settings in the woocommerce setting.

Add a field indicating a note "type" to the order notes api

We'd like to create a view in the mobile app that visually distinguishes between different types of notes:

  • System status
  • Note to customer
  • Private note

The API currently only provides customer_note=true|false which is fine for determining a public vs private note, but no data is provided that would allow us to flag a note as "system generated". Wp-admin uses different colors to represent the system generated status so it looks like something we do track:

screen shot 2018-04-30 at 4 24 21 pm

Orders: Get "new" orders from one API request

For store on calypso, "new" orders are any in 'pending', 'processing', or 'on-hold'. If I want to get those orders via the API, I can't do it in one request - currently status only accepts a single status string, or 'any', but no (apparent) way to request a subset of statuses.

One solution would be to pass in a list of statuses, status[]=pending&status[]=processing&status[]=on-hold, and returning all orders that match one of those. This would be useful for other combined status listings, like if we wanted to include completed, cancelled (and refunded?) orders in a list of "finished" orders.

Another solution would be to allow the API to accept status=new, and behind the scenes translate that to [ pending, processing, on-hold ]. If wc extensions can add custom statuses, this might be better so they can indicate if some new status should be considered "new".

Invalid parameter(s): meta_data [rest_invalid_param]

Any attempts to update an order's meta_data fail.

This goes against the API documentation http://woocommerce.github.io/woocommerce-rest-api-docs/#order-properties

WordPress 4.9.2
WooCommerce 3.2.6
wc-api-php 2.0.0
Memory: 10 of 128 MB (8%) | WP LIMIT: 128 MB | PHP 7.1.12

Outline of API call (PHP using wc-api-php 2.0.0):

$woocommerce = new Client(
    'https://www....',
    '...',
    '...',
    [
        'wp_api' => true,
        'version' => 'wc/v2'
    ]
);

...create/load an wooOrder with $orderId

$data = [
  'id' => $orderId,
  'meta_data' => [ '_custom_field' => '24.54' ]
];

$woocommerce->put('orders/'.$orderId, $data);

ERROR log

[31-Jan-2018 09:49:53 Europe/London] PHP Fatal error:  Uncaught Automattic\WooCommerce\HttpClient\HttpClientException: Error: Invalid parameter(s): meta_data [rest_invalid_param] in /home/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php:348
Stack trace:

#0 /home/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php(378): Automattic\WooCommerce\HttpClient\HttpClient->lookForErrors(Object(stdClass))

#1 /home/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php(414): Automattic\WooCommerce\HttpClient\HttpClient->processResponse()

#2 /home/vendor/automattic/woocommerce/src/WooCommerce/Client.php(69): Automattic\WooCommerce\HttpClient\HttpClient->request('orders/7712', 'PUT', Array)

#3 /home/woocommerce.php(95): Automattic\WooCommerce\Client->put('orders/7712', Array)

#4 /home/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php on line 348

Add total order count in the metadata of the /orders endpoint

Use Case
Need a way to get a total count of orders for a site that allows for providing an optional filter (or ideally a range of filters as requested in #114).

Possible Implementation
This could be a standalone endpoint but it may make it more flexible if it were included in the metadata of the GET /orders response. So if we send in a request for orders, regardless of per_page value, the metadata would include an element containing the total orders available for the order status filter provided (or ANY if none provided). Having an additional element that lists total orders regardless of filter may also be nice.

Filtering products using attributes does not work

I have an attribute called "Flavor" with ID: 1 and an attribute_term within the flavor attribute called "Banana" with ID:23 ... when I try to retrieve products with Banana Flavor using the following query:

this.WooCommerce.getAsync(products/?attribute=1&attribute_term=23&page=1).then( async (data) => { let newProducts = JSON.parse(data.body); console.log(newProducts) }, (err) => { console.log(err) });

I get the entire list of existing products.

MailChimp REST API schemas

Info

Durin development on MailChimp integration new REST endpoints where created. They lack proper schema description of returned data.

Woocommrece Rest Api V2 Sorting Product with default WordPress Options and Getting Country and State list

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate
  • The issue still exists against the latest master branch of WooCommerce on Github (this is not the same version as on WordPress.org!)
  • I have attempted to find the simplest possible steps to reproduce the issue
  • I have included a failing test as a pull request (Optional)

I'm using woocommerce RestApi v2 in Android. There is sorting options: date, id, include, title and slug. Default is date.

  1. I want to know that how to do sorting by Default Sorting ,Sort By Popularity,Sort By Average Rating,Sort by newness,Sort by Price: low to high,Sort By Price:high to low . These option is by default availabe at shop page but how to do in api?

  2. How to get country [ Name,Code] and its states?
    I got in php we can do this-

    global $woocommerce;
    $countries_obj   = new WC_Countries();
    $countries   = $countries_obj->__get('countries');
    $default_country = $countries_obj->get_base_country();
    $default_county_states = $countries_obj->get_states( $default_country );`
    

how can I do this via rest api? without using php api?

Variation image setting doesn't work

Setting a variation image with the wc-api-dev plugin doesn't work. I think I know why, and will get a fix up tomorrow. I think it's related to how we extend/load the files.

Cannot retrieve products from child category

I have a category named "New Products" that includes the new products that also belong to different categories like the "Accessories" category. For example, I have 20 products inside the "Accessories" category ... 3 of them are new (belong to the "New Products" category as well). So how to retrieve these 3 products. I tried this (New Products category ID: 35 and Accessories category ID:18 :

this.WooCommerce.getAsync(products?category=18&category=35&page=1).then( async (data) => { let newProducts = JSON.parse(data.body); console.log(newProducts) }, (err) => { console.log(err) });

The result is all the products in both categories with no repetition.

Orders: Add `author` to notes list response

Currently in wp-admin, the notes list display shows the user who left the comment:

screen shot 2017-08-11 at 1 21 39 pm

This has also been carried into the display for order notes in calypso:

screen shot 2017-08-11 at 1 22 26 pm

So we need to get this info from the API (and presumably also send it when creating a note as well).

Fix Failing Tests

The test suite here has 3 failing tests against 3.2.6, and is completely not running against 3.3 Beta. Prior to the release of 3.3 we should ensure the test suite is running without failures and fix any regressions that might result from the 3.3 upgrade.

There were 3 errors:

1) WC_Tests_API_Orders::test_create_order
Undefined index: id

/srv/www/wordpress-develop/public_html/src/wp-content/plugins/wc-api-dev/tests/unit-tests/orders.php:170

2) Products_API::test_update_product
Undefined index: items

/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:1092
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:1110
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:1092
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:907
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api/class-wp-rest-request.php:858
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api/class-wp-rest-server.php:874
/srv/www/wordpress-develop/public_html/src/wp-content/plugins/woocommerce/tests/framework/vendor/class-wp-test-spy-rest-server.php:35
/srv/www/wordpress-develop/public_html/src/wp-content/plugins/wc-api-dev/tests/unit-tests/products.php:197

3) Products_API::test_create_product
Undefined index: items

/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:1092
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:1110
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:1092
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:907
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api/class-wp-rest-request.php:858
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api/class-wp-rest-server.php:874
/srv/www/wordpress-develop/public_html/src/wp-content/plugins/woocommerce/tests/framework/vendor/class-wp-test-spy-rest-server.php:35
/srv/www/wordpress-develop/public_html/src/wp-content/plugins/wc-api-dev/tests/unit-tests/products.php:336

ERRORS!
Tests: 220, Assertions: 755, Errors: 3.

Update - with the removal of the Webhook test classes in #79 the test suite is running fine against master of woocommerce now, though we do still have some failures:

There were 4 errors:

1) WC_Tests_API_Orders::test_create_order
Undefined index: id

/srv/www/wordpress-develop/public_html/src/wp-content/plugins/wc-api-dev/tests/unit-tests/orders.php:170

2) Products_API::test_update_product
Undefined index: items

/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:1092
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:1110
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:1092
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:907
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api/class-wp-rest-request.php:858
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api/class-wp-rest-server.php:874
/srv/www/wordpress-develop/public_html/src/wp-content/plugins/woocommerce/tests/framework/vendor/class-wp-test-spy-rest-server.php:35
/srv/www/wordpress-develop/public_html/src/wp-content/plugins/wc-api-dev/tests/unit-tests/products.php:197

3) Products_API::test_create_product
Undefined index: items

/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:1092
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:1110
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:1092
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api.php:907
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api/class-wp-rest-request.php:858
/srv/www/wordpress-develop/public_html/src/wp-includes/rest-api/class-wp-rest-server.php:874
/srv/www/wordpress-develop/public_html/src/wp-content/plugins/woocommerce/tests/framework/vendor/class-wp-test-spy-rest-server.php:35
/srv/www/wordpress-develop/public_html/src/wp-content/plugins/wc-api-dev/tests/unit-tests/products.php:336

4) Settings::test_validation_image_width
Undefined index: value

/srv/www/wordpress-develop/public_html/src/wp-content/plugins/wc-api-dev/tests/unit-tests/settings.php:737

--

There was 1 failure:

1) Settings::test_get_group
Failed asserting that an array contains Array &0 (
    'id' => 'woocommerce_demo_store'
    'label' => 'Store notice'
    'description' => 'Enable site-wide store notice text'
    'type' => 'checkbox'
    'default' => 'no'
    'value' => 'no'
    '_links' => Array &1 (
        'self' => Array &2 (
            0 => Array &3 (
                'href' => 'http://example.org/index.php?rest_route=/wc/v3/settings/general/woocommerce_demo_store'
            )
        )
        'collection' => Array &4 (
            0 => Array &5 (
                'href' => 'http://example.org/index.php?rest_route=/wc/v3/settings/general'
            )
        )
    )
).

/srv/www/wordpress-develop/public_html/src/wp-content/plugins/wc-api-dev/tests/unit-tests/settings.php:191

ERRORS!
Tests: 220, Assertions: 749, Errors: 4, Failures: 1.

Disable Jetpack Sync during Shutdown for REST API Requests

Jetpack sync during the shutdown hook is adding about 4 seconds to product creation and probably other requests too.

Let's filter jetpack_sync_sender_should_load to false during a REST_REQUEST as a temporary measure, until

See also woocommerce/woocommerce#16158

cc @mikejolley @westi @DanReyLop @justinshreve

When this api version is going to be released

I didn't find other place to ask this question. I am waiting for this api version for some months however it is not released yet. Can someone tell when its going to be released?

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.