woocommerce-rest-api

Extending the woocommerce rest api

偶尔善良 提交于 2019-12-20 03:52:13
问题 I would like to extend the woocommerce rest api to include data of its 'booking' extension plugin. Currently this extension does not have default endpoints provided by the rest api. So far I have created a plugin, and I've added the following code; add_filter( 'woocommerce_rest_prepare_product', 'custom_data'); function custom_data($response, $object) { if( empty( $response->data ) ) return $response; $response->data['meta_data'] = get_post_meta( $object[ID], 'availability', true); return

Getting Blank screen after importing and using WooCommerce API

╄→гoц情女王★ 提交于 2019-12-13 19:12:31
问题 I'm trying to use WooCommerce API in Ionic4 application after importing API in my home page I cannot see anything on output screen below is code: home.page.ts import { Component } from '@angular/core'; import * as WC from '@woocommerce/woocommerce-rest-api'; @Component({ selector: 'app-home', templateUrl: 'home.page.html', styleUrls: ['home.page.scss'], }) export class HomePage { //Local Objet WooCommerce of type any WooCommerce: any; constructor() { this.WooCommerce = WC({ url: "https://shop

WooCommerce 3.5.4 and WordPress 5.0.3 REST API: Image upload broken (woocommerce_product_invalid_image_id)

非 Y 不嫁゛ 提交于 2019-12-13 18:08:26
问题 I am using v2 of the REST API. This code worked fine on an older version of WordPress and WooCommerce. I cannot upload an image to a product. The first error after the upgrade I got was: array ( 'code' => 'woocommerce_product_image_upload_error', 'message' => 'Invalid image: Sorry, this file type is not permitted for security reasons.', 'data' => array ( 'status' => 400, ), Resolved by adding following in wp-config.php to the bottom of the file: define('ALLOW_UNFILTERED_UPLOADS', true); The

How to get all products from woo-commerce?

淺唱寂寞╮ 提交于 2019-12-12 17:07:50
问题 I have setup Woo-Commerce which have more than 1000 products. Using Woocommerce rest api php library I am trying to get all products. But it gives me 10 products. If I use filter[limit] it gives me around 400 products not more than this. $res = $wc_api->get_products(array( 'filter[limit]' => 400 ) ); Can anyone say me how can I get all products from woocommerce? 回答1: For the latest version of the WC API, use $products = $client->products->get( '', ['filter[limit]' => -1] ); If it's not

What WooCommerce API should I use on the server?

久未见 提交于 2019-12-12 08:15:54
问题 I am writing a script to bulk-change product properties such as price, weight and dimension. I need to run the script directly on the server where WordPress (4.7.2) and WooCommerce (2.6.13) are installed. The options I could think of don't seem ideal to me: WooCommerce non-REST API would be my obvious choice, but it is relegated into a scary legacy folder which smells of deprecated. WooCommerce REST API (link) seems overkill: why should I go through authentication and use HTTP when I am

WooCommerce hooks - Product update deliver variation objects instead of IDs

一世执手 提交于 2019-12-11 19:45:44
问题 When receiving a product updated hook from WooCommerce, the payload contains a 'variations' array, which, however, only contains the IDs of the variations that belong to the updated product. How can I send the actual variation objects along with the product updated payload, instead of only the IDs of the variation (this way, I wouldn't need to send another request to the variations resource of the REST API to fetch them). Thanks! 回答1: You need to hook woocommerce_webhook_payload to build the

WooCommerce API creates images in media even if they exist

你。 提交于 2019-12-11 04:46:42
问题 What might be a reason? Trying to batch update product images (and price) in WooCommerce via REST API. Images already exist in wordpress media library and links are correctly copied. However, instead of using image it creates new image. Request: POST. URL: https://SiteURL/wp-json/wc/v2/products/xxxx?consumer_key=c______&consumer_secret=_____ Body: {"update":[ {"regular_price":"448", "images":[ {"src":"https://urlToImage.jpg", "position":0, "name": "test"} ],"id":"xxxx"}]} In response I can

WooCommerce REST API include attributes or custom fields in search

我的未来我决定 提交于 2019-12-11 04:45:44
问题 I need an extended search functionality available via REST API - mainly an ability to include product's attributes in a search query. I've seen a lot of similar questions but none of them are answered unfortunately. Is this even possible? And if so, any advice how or where I could modify the search query to include the product's attributes? 来源: https://stackoverflow.com/questions/38201510/woocommerce-rest-api-include-attributes-or-custom-fields-in-search

Enable WooCommerce on http

对着背影说爱祢 提交于 2019-12-10 12:06:00
问题 Iam working cart apllication. I installed WooCommerce plugin and generated keys in http server. But it is not returning any products data. Is WooCommerce works in HTTP or it works only in https? 回答1: The API works on both http and https protocols. For http you'll have to encode your requests and for https since its already encoded, you just pass the key and secret as parameters. Its best if you first test the response in POSTMAN. I'm attaching screenshot of a successful get response on HTTP.

WooCommerce REST API - Get Custom Fields for Order

女生的网名这么多〃 提交于 2019-12-06 02:37:14
I'm using the WooCommerce REST API ( http://woocommerce.github.io/woocommerce-rest-api-docs/#introduction ) and are able to download Customers, Orders etc successfully. My customer has added some custom fields to the checkout page, e.g.: po_number accounts_email I would like to be able to GET these custom fields when requesting an ORDER, e.g.: /wp-json/wc/v1/orders/4568 At the moment none of the custom fields are returned when I GET an Order. I've tried adding ?filter[meta]=true to the request URL but that doesn't make any difference. Is there a way I can modify the GET URL to include all