I am trying to prevent products and variations from being deleted through the WooCommerce REST API. Deletion should still be able from the admin interface, though.
Is there any way to achieve this?
Can I somehow overwrite the behaviour of the WooCommerce REST API when a DELETE request is sent?
Thanks!
Related
We are running a WooCommerce shop and want to make our orders available to an external shipping contractor via the WooCommerce REST API.
However, not all orders are relevant to this contractor and he should not be able to access orders with only virtual products due to security and privacy reasons.
Is there a filter available where I can hide these orders from the REST API? I know how to do the filter, I just don't know if the right filter hooks exists to only filter posts (orders) accessed via the REST API. The WooCommerce Docs are not very clear on that subject. Thanks!
I am trying to access my site's Subscription Products via REST API. At wc/v1/subscriptions I can get the active subscriptions, and at wc/v3/products I can get all products except subscriptions.
There isn't anything in the WC Subscriptions documentation about subscription products. This site implies that I can provide an API for this, but I am not a PHP programmer. I do have access to the server and can put code in functions.php or wherever it would belong.
Can anyone provide me with the code to achieve this? I ask here because I hope it's relatively simple, like the get_posts_meta code I've found on a number of blogs/sources to expose some other API data.
Thanks a lot.
New to woocommerce ,i develop a sale file app , i decide to use woocommerce rest API i can show products
/wc-api/v2/products
I know how can add to order
/wc-api/v2/orders
How can add product to cart and checkout and connect to bank gateway?
The cart is part of a session and is saved in the MySQL table wp_woocommerce_sessions. This table is accessed using a WC_Session_Handler object. AFAIK the WooCommerce REST API does not provide access to WC_Session_Handler objects.
I don't understand exactly what you are trying to do but if you want to access the cart through the REST API I think you will need to implement your own REST controller for the wp_woocommerce_sessions table. This isn't that difficult to do as you can modify one of the existing WooCommerce REST controllers to work with WC_Session_Handler objects to access the wp_woocommerce_sessions table.
But, beware a WooCommerce session is bound to a browser session through cookies and you need to handle that binding.
I am building a webshop with React, Wordpress v4 and Woocommerce Rest api v2.
I am a bit confused on how to proceed with authentication. I understand that for some requests like place an order or create a new product I need to authenticate.
But I also need to be able to just retrieve all products for a customer who visits the site for the first time and just wants to browse through all our products.
What is the best practice here?
My thoughts are:
Create a public, separate layer with PHP or Node which securely stores the Woocommerce API keys and provides public endpoints (only GET, i.e. GET /products)
Access those endpoints via JS/React and render the products
Create another separate layer for placing orders which requires the costumer to authenticate (i.e. POST /orders)
Also, instead of adding a separate layer I could use the Wordpress function add_action( 'rest_api_init',...
Is there a better way to do it or am I missing something? Or can I retrieve the Woocommerce Products somehow via the Wordpress API endpoints without api keys?
Okay, somehow I was thinking the wrong way. As wordpress lists all products which were created in woocommerce as a regular Wordpress post with post-type product, I just have to make a request to the Wordpress API (NOT the Woocommerce API!), in my example:
http://laflor.wordpress.local/wp-json/wp/v2/product
I have wordpress site with woocommerce shop and I’m selling among others UrBackup client accounts on my server.
Do you have any idea how to automatically add UrBackup user after order in woocommerce?
Or maybe easier will be create shop based on different engine?
Any advice, tips? :)
After poking around a bit, it looks like UrBackup has an API you can use, that most likely has a 'create account' endpoint. I didn't see it immediately in their not-so-great documentation, but you'd think it'd HAVE to be there somewhere! There's also a PHP API kit you could integrate into your WordPress site here:
https://bitbucket.org/opensaucesystemsdevelopment/urbackup-api.git
So, you could load in this class, and after a WooCommerce order is placed, call the API endpoint to create a user. To do this with WooCommerce, you'd need to create a function on the "woocommerce_order_status_completed" hook.
http://hookr.io/actions/woocommerce_order_status_completed/
This would let you run any custom code you'd like after an order's payment has completed. Thus, you could check an order for if it contains the UrBackup product, and if so call the UrBackup API to create an account based on the current user's data.
Should work!