Get data from Woocommerce via server api
-
@orange said in Get data from Woocommerce via server api:
Just thinking, what if we make a .JSON file that has all of the download links, product images, product versions...etc
But if you want to customise any of that data or perform server side operations on it the REST API can't help you. This was my main problem with using REST and why I went with a custom plugin.
-
@orange @d-healey Would you guys be able to help me with a PHP example involving jwt?
I'm not well versed in PHP so I've been going over the tutorial at https://www.w3schools.com/php/ all day. I'm successfully using HISE to communicate with woo license manager endpoints like @orange so hopefully it's helpful that I'm not starting from the ground up.Using postman.co, I can POST to my wordpress JWT endpoint (/wp-json/jwt-auth/v1/token) and get a response:
{ "token": "xxxxxAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.xxxxxxodHRwczpcL1wvd29yZHByZXNzLmtvcm5lZmYuY28iLCJpYXQiOjE2NTEwMDI5NjIsIm5iZiI6MTY1MTAwMjk2MiwiZXhwIjoxNjUxNjA3NzYyLCJkYXRhIjp7InVzZXIiOnsiaWQiOiIxIn19fQ.xxxxxxPb9vASKhLm5Vgp0zxS2acm-JgM9aJOvDf0Q", "user_email": "xxxxxxxxxxx@xxxxx.xx", "user_nicename": "dankorneff", "user_display_name": "dankorneff" }
What is the proper way to make a POST call in PHP and store/use this token in the http header?
-
@dustbro
What is the proper way to make a POST call in PHP
You don't. The call is made from the client (HISE in our case) and is processed by the server.
If you're making the call from HISE you need to use
Server.setHttpHeader(["Authorization: Bearer " + token]);
before you make the call. Then you use eitherServer.callWithGET()
orServer.callWithPOST()
as needed; -
@dustbro said in Get data from Woocommerce via server api:
What is the proper way to make a POST call in PHP and store/use this token in the http header?
I haven't done this in PHP yet. Why do you need that?
-
@orange @d-healey I don't think I explained myself very well. :)
I'm designing a user dashboard on my wordpress website (completely independent from HISE) that will display products, license info, downloads, etc.
So basically pulling info from:/wp-json/wclm/v3/get-current-user-licenses/ /wp-json/wclm/v3/activate/ /wp-json/wclm/v3/deactivate/ /wp-json/wc/v3/customers/ /wp-json/wp/v2/users/
And displaying it in a useful way.
-
@dustbro If you are accessing data on your own server you need to access that data directly or through an API, there shouldn't be a need to make POST/GET requests within your own server.
I'm designing a user dashboard on my wordpress website (completely independent from HISE) that will display products, license info, downloads, etc.
Doesn't WooCommerce give you all this already?
-
you need to access that data directly or through an API, there shouldn't be a need to make POST/GET requests within your own server.
From what I'm reading, I need to use the API to access my license manager database, and the API can only communicate thru HTTP requests... and JWT authentication is required to access the endpoints. so I'm back to square one.
Doesn't WooCommerce give you all this already?
The standard user area in woocommerce leaves a lot to be desired. License codes are practically hidden in the order details page, then the customer has to go to a separate page to find their download link.
-
The standard user area in woocommerce leaves a lot to be desired. License codes are practically hidden in the order details page, then the customer has to go to a separate page to find their download link.
@dustbro There are plugins for this. We use https://yithemes.com/themes/plugins/yith-woocommerce-customize-myaccount-page/
Also, this plugin should automatically add a section to the My Account area for licenses: https://www.licensemanager.at/
You don't need any JWT authentication, and at most you'll just need a few Read/Write calls from that license manager plugin. I've already looked at literally all the options and plugins available for license management via Woocommerce, and that's the best option by a mile.
-
@Casey-Kolb @dustbro @d-healey @orange Noob alert but where should I begin to make a license delivery system in woo please?
-
-
@dustbro
The standard user area in woocommerce leaves a lot to be desired. License codes are practically hidden in the order details page, then the customer has to go to a separate page to find their download link.
Yes, the standard Woocommerce account page is boring, but as @Casey-Kolb suggested, you can go with a plugin to customize the layout.
Also if the user login to their account successfully directly on the website, you won't need JWT authentication. But if you want to make a separate website for the account page & licenses particularly, then you'll need that JWT auth to use the APIs. In this case, I will suggest going with a PHP developer on Upwork or Fiverr.
-
@d-healey said in Get data from Woocommerce via server api:
I avoided the REST API entirely and created a custom wordpress plugin, this gives complete flexibility to pull from Wordpress, WooCommerce, and the license manager plugin I'm using (different one to Orange).
I think I need to do the same. Any chance you can give some insight on creating a plugin that will give me access to the woocommerce customer download links?
-
@Dan-Korneff Have you made a plugin before?
-
@d-healey No. I'm going thru the plugin tutorial now
-
@Dan-Korneff That's what I did too. Once you've made a basic plugin and got a feel for it get back to me and I'll help you get up and running