B2BKing does not have its own API, as all of its data is stored as user/product metadata. Per our previous emails, user and product data can be accessed by using the WordPress or WooCommerce APIs. It's best to use the WooCommerce API where possible.
1) A group is a wordpress post, of the custom post type named b2bking_group. You would need to insert a post of this type to create a group.
2) To assign a customer to a customer group, the following 2 user meta keys need to be set for the customer:
-> b2bking_b2buser must have the value yes
-> b2bking_customergroup must have the value of the group ID (the POST ID of the group), for example 1234
3) This is a bit unclear, as the plugin does not have a feature to change the price based on the link used. The way it works is that when a user views a product, if they are logged in as a user part of group X, they will simply see the price of group X. It depends on the user they are logged in as. The product link is always the same normal link.
Please confirm what is the POST request json body to create Group? The json body you provided earlier doesn't have group name which means that we will create a noname group?
{
"status": "publish",
"type": "product",
"title": "My New Product"
}
You will have the same authentication error.
So it has something to do with the Wordpress authentication process for APIs. I don't know exactly how this works, we are not experts in this and it is not our field of expertise.
There are no issues with the creation of products, customers or orders in the woocommerce using standard woocommerce API the issue is only that I can't create a group using your plugin, that's all :)
Hi there, Could you please send a link to the API documentation?
It would be very important for us as we are trying to integrate with Sage.
Thanks
Hi Zoltan,
Thank you for purchasing our plugin.
B2BKing does not have its own API, as all of its data is stored as user/product metadata. Per our previous emails, user and product data can be accessed by using the WordPress or WooCommerce APIs. It's best to use the WooCommerce API where possible.
For that API's documentation, please see https://woocommerce.github.io/woocommerce-rest-api-docs/
Generally to integrate with Sage, it may be best to start with an existing solution such as https://www.woosage.com/ or https://www.codelessplatforms.com/solutions/woocommerce-sage-integration/
Kind regards,
Stefan
Hi there,
1) A group is a wordpress post, of the custom post type named b2bking_group. You would need to insert a post of this type to create a group.
2) To assign a customer to a customer group, the following 2 user meta keys need to be set for the customer:
-> b2bking_b2buser must have the value yes
-> b2bking_customergroup must have the value of the group ID (the POST ID of the group), for example 1234
3) This is a bit unclear, as the plugin does not have a feature to change the price based on the link used. The way it works is that when a user views a product, if they are logged in as a user part of group X, they will simply see the price of group X. It depends on the user they are logged in as. The product link is always the same normal link.
Kind regards,
Stefan
Hi there,
It would be a JSON body type.
You would use the following endpoint:
https://yoursite.com/wp-json/wp/v2/b2bking_group
A simple request like this would work:
I suggest you see our guide here on point 2.1: https://woocommerce-b2b-plugin.com/docs/import-or-setup-dynamic-rules-programatically/
It is for creating dynamic rules via REST API, but the same principles apply for creating groups via REST API.
Hi there,
1) You can simply access the http://yoursite.com/wp-json/wp/v2/b2bking_group URL and you will get a JSON list of all group posts:
Or with something else by making a GET request to that URL.
I am not sure if there's any way to get only the names of the groups (titles) unfortunately.
2)
Sorry, can you explain that or give an example? What do you mean by property responses?
Kind regards,
Stefan
Hi Stefan, thanks.
The integration developer would join this conversation if that's ok. Its easier if he asks questions directly than me.
Hi Stefan,
Please confirm what is the POST request json body to create Group? The json body you provided earlier doesn't have group name which means that we will create a noname group?
Best regards, Anton.
Hi Anton,
To configure a specific group name, you can enter it like this:
Then I can see it here:
Kind regards,
Stefan
Hi Stefan,
thx, for your reply. Unfortunately, it says that the creation failed
see the request and response in attach
Best regards, Anton.
Hi Anton,
The URL of the request there seems incorrect. I see you are using a URL ending in wc/v3/create_user_group.
The URL should be https://yoursite.com/wp-json/wp/v2/b2bking_group , replacing yoursite.com
Hi,
thx, sorry, got cross-referenced emails and used the wrong url.
anyway I tried but it failed with a strange error:
{
"code": "rest_cannot_create",
"message": "Sorry, you are not allowed to create posts as this user.",
"data": {
"status": 401
}
}
I, as a user in the admin, can create a group. API has full permissions(read/write)
Best regards, Anton.
You need to use a plugin like this one:
https://wordpress.org/plugins/wp-rest-api-authentication/
You can configure it like this:
Hi,
thx for your reply but, why do I need 3rd party app to be authorized in WooCommerce if it already has an authentication process?
Best regards, Anton.
Hi Anton,
This is not specific to our plugin. Our groups are simply custom post types in WordPress.
You can try to create another custom post type, for example try to use this URL
http://yoursite.local/wp-json/wp/v2/product
and create a WooCommerce product with this input
You will have the same authentication error.
So it has something to do with the Wordpress authentication process for APIs. I don't know exactly how this works, we are not experts in this and it is not our field of expertise.
Hi,
There are no issues with the creation of products, customers or orders in the woocommerce using standard woocommerce API
the issue is only that I can't create a group using your plugin, that's all :)
Best regards, Anton.
Creating items via wp/v2/product is using the WordPress API, not the WooCommerce API.
This is not a feature of our plugin, it is a feature of WordPress, we did not write this API.
I don't know the details of how its authentication works. You would need to look into the documentation of the WordPress V2 API.
B2BKing does not have its own API.
Since this is custom coding, this is not something we can support or handle directly for you.
Hi,
ok, then it makes sense, thx
I will ask website devs to install those API plugins
Best regards, Anton.