Action and Filter Hook Reference
This is simply a list of action and filter hooks found within WooCommerce B2B Roles & Permissions files. View the source to see supported parameters and usage.
Filters
Actions
API Documentation
Authentication
WooCommerce B2B Roles & Permissions use Basic Authentication ,which accept Consumer Key as Username and Consumer Secret as Password generated by Woocommerce Rest Api (WooCommerce > Settings > Advanced > REST API).
Company
Get All Companies
Retrieve All Companies data.
HTTP Request
{{site_url}}wp-json/wc/v3/wcb2brp/company/get_all
Sample Response:
{
"status": 200,
"data": [
{
"ID": 338,
"company_name": "test",
"enable_credit_payment": "no",
"allow_assign_role": "yes",
"owner_email": "test1@test.com",
"credit_balance": 0,
"last_assign_credit": -20,
"consumed_credit": 42,
"logs": [
{
"id": "168",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "10.00",
"created": "2021-02-26 07:27:24"
},
{
"id": "169",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "12.00",
"created": "2021-02-26 07:32:21"
},
{
"id": "170",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "20.00",
"created": "2021-02-26 08:27:59"
},
{
"id": "171",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "20.00",
"created": "2021-02-26 09:40:54"
},
{
"id": "172",
"user_id": "61",
"post_id": "338",
"order_id": "339",
"event": "Company Credit Deducted",
"amount": "15.00",
"created": "2021-02-26 10:10:18"
},
{
"id": "173",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "-20.00",
"created": "2021-03-01 08:10:00"
},
{
"id": "174",
"user_id": "64",
"post_id": "338",
"order_id": "341",
"event": "Company Credit Deducted",
"amount": "27.00",
"created": "2021-03-01 08:12:58"
}
]
},
{
"ID": 281,
"company_name": "Realme",
"enable_credit_payment": "yes",
"allow_assign_role": "yes",
"owner_email": "rm@gmail.com",
"credit_balance": "870",
"last_assign_credit": 50,
"consumed_credit": 0,
"logs": [
{
"id": "126",
"user_id": "1",
"post_id": "281",
"order_id": "0",
"event": "Company Credit Added",
"amount": "500.00",
"created": "2020-12-15 11:08:39"
},
{
"id": "127",
"user_id": "42",
"post_id": "281",
"order_id": "0",
"event": "Company Credit Deducted",
"amount": "100.00",
"created": "2020-12-15 11:12:29"
},
{
"id": "128",
"user_id": "1",
"post_id": "281",
"order_id": "0",
"event": "Company Credit Added",
"amount": "100.00",
"created": "2020-12-15 11:14:10"
},
{
"id": "129",
"user_id": "42",
"post_id": "281",
"order_id": "0",
"event": "Company Credit Reverted",
"amount": "100.00",
"created": "2020-12-15 11:16:51"
},
{
"id": "130",
"user_id": "42",
"post_id": "281",
"order_id": "0",
"event": "Company Credit Deducted",
"amount": "100.00",
"created": "2020-12-15 11:20:55"
},
{
"id": "131",
"user_id": "1",
"post_id": "281",
"order_id": "0",
"event": "Company Credit Added",
"amount": "100.00",
"created": "2020-12-15 11:22:30"
},
{
"id": "132",
"user_id": "42",
"post_id": "281",
"order_id": "0",
"event": "Company Credit Deducted",
"amount": "200.00",
"created": "2020-12-15 11:24:22"
},
{
"id": "133",
"user_id": "1",
"post_id": "281",
"order_id": "0",
"event": "Company Credit Added",
"amount": "100.00",
"created": "2020-12-15 11:28:48"
},
{
"id": "134",
"user_id": "42",
"post_id": "281",
"order_id": "0",
"event": "Company Credit Reverted",
"amount": "100.00",
"created": "2020-12-15 11:29:51"
},
{
"id": "135",
"user_id": "42",
"post_id": "281",
"order_id": "0",
"event": "Company Credit Reverted",
"amount": "200.00",
"created": "2020-12-15 11:30:21"
},
{
"id": "136",
"user_id": "1",
"post_id": "281",
"order_id": "0",
"event": "Company Credit Added",
"amount": "20.00",
"created": "2020-12-16 12:34:07"
},
{
"id": "137",
"user_id": "1",
"post_id": "281",
"order_id": "0",
"event": "Company Credit Added",
"amount": "50.00",
"created": "2020-12-16 12:35:06"
}
]
},
{
"ID": 228,
"company_name": "abcd",
"enable_credit_payment": "yes",
"allow_assign_role": "no",
"owner_email": "",
"credit_balance": "1084",
"last_assign_credit": 44,
"consumed_credit": 0,
"logs": [
{
"id": "51",
"user_id": "1",
"post_id": "228",
"order_id": "0",
"event": "Company Credit Added",
"amount": "1000.00",
"created": "2020-11-06 05:33:20"
},
{
"id": "52",
"user_id": "1",
"post_id": "228",
"order_id": "0",
"event": "Company Credit Added",
"amount": "40.00",
"created": "2020-11-06 05:33:27"
},
{
"id": "53",
"user_id": "1",
"post_id": "228",
"order_id": "0",
"event": "Company Credit Added",
"amount": "44.00",
"created": "2020-11-06 05:35:14"
}
]
},
{
"ID": 183,
"company_name": "maria's company",
"enable_credit_payment": "yes",
"allow_assign_role": "no",
"owner_email": "maria.ilyas@codup.io",
"credit_balance": "1000",
"last_assign_credit": 1000,
"consumed_credit": 0,
"logs": [
{
"id": "46",
"user_id": "1",
"post_id": "183",
"order_id": "0",
"event": "Company Credit Added",
"amount": "1000.00",
"created": "2020-09-21 11:37:37"
}
]
},
{
"ID": 160,
"company_name": "Xbox",
"enable_credit_payment": "yes",
"allow_assign_role": "no",
"owner_email": "talha@codup.io",
"credit_balance": "2200",
"last_assign_credit": 1000,
"consumed_credit": 1200,
"logs": [
{
"id": "37",
"user_id": "1",
"post_id": "160",
"order_id": "0",
"event": "Company Credit Added",
"amount": "1000.00",
"created": "2020-09-04 14:15:12"
},
{
"id": "38",
"user_id": "28",
"post_id": "160",
"order_id": "0",
"event": "Company Credit Deducted",
"amount": "500.00",
"created": "2020-09-04 14:15:27"
},
{
"id": "39",
"user_id": "28",
"post_id": "160",
"order_id": "0",
"event": "Company Credit Deducted",
"amount": "30.00",
"created": "2020-09-04 14:20:21"
},
{
"id": "40",
"user_id": "29",
"post_id": "160",
"order_id": "0",
"event": "Company Credit Deducted",
"amount": "470.00",
"created": "2020-09-04 14:44:02"
},
{
"id": "41",
"user_id": "1",
"post_id": "160",
"order_id": "0",
"event": "Company Credit Added",
"amount": "200.00",
"created": "2020-09-04 16:24:47"
},
{
"id": "42",
"user_id": "30",
"post_id": "160",
"order_id": "0",
"event": "Company Credit Deducted",
"amount": "100.00",
"created": "2020-09-04 16:25:32"
},
{
"id": "43",
"user_id": "28",
"post_id": "160",
"order_id": "0",
"event": "Company Credit Deducted",
"amount": "100.00",
"created": "2020-09-04 16:27:29"
},
{
"id": "44",
"user_id": "1",
"post_id": "160",
"order_id": "0",
"event": "Company Credit Added",
"amount": "1200.00",
"created": "2020-09-21 11:30:11"
},
{
"id": "45",
"user_id": "1",
"post_id": "160",
"order_id": "0",
"event": "Company Credit Added",
"amount": "1000.00",
"created": "2020-09-21 11:34:33"
}
]
}
]
}
Delete Company
Delete Company.
HTTP Request
{{site_url}}wp-json/wc/v3/wcb2brp/company/delete_company
Available Parameters
Parameter | Description |
---|---|
company_id |
required |
Sample Response:
{
"status": 200,
"data": "Realme Deleted Successfully"
}
Get Company
Retrieve Company Details.
HTTP Request
{{site_url}}wp-json/wc/v3/wcb2brp/company/get_company
Available Parameters
Parameter | Description |
---|---|
company_id |
required |
Sample Response:
{
"status": 200,
"data": {
"ID": "338",
"company_name": "test",
"enable_credit_payment": "no",
"credit_balance": 0,
"last_assign_credit": -20,
"consumed_credit": 42,
"logs": [
{
"id": "168",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "10.00",
"created": "2021-02-26 07:27:24"
},
{
"id": "169",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "12.00",
"created": "2021-02-26 07:32:21"
},
{
"id": "170",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "20.00",
"created": "2021-02-26 08:27:59"
},
{
"id": "171",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "20.00",
"created": "2021-02-26 09:40:54"
},
{
"id": "172",
"user_id": "61",
"post_id": "338",
"order_id": "339",
"event": "Company Credit Deducted",
"amount": "15.00",
"created": "2021-02-26 10:10:18"
},
{
"id": "173",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "-20.00",
"created": "2021-03-01 08:10:00"
},
{
"id": "174",
"user_id": "64",
"post_id": "338",
"order_id": "341",
"event": "Company Credit Deducted",
"amount": "27.00",
"created": "2021-03-01 08:12:58"
}
]
}
}
Add Company
Add Company.
HTTP Request
{{site_url}}wp-json/wc/v3/wcb2brp/company/add_company
Available Parameters
Parameter | Description |
---|---|
company_name |
required |
owner_email |
- |
allow_assign_role |
optional -yes or no |
enable_credit_payment |
optional -yes or no |
credit |
- |
Sample Response:
{
"status": 200,
"data": {
"ID": 345,
"company_name": "test company",
"enable_credit_payment": "yes",
"allow_assign_role": "yes",
"owner_email": "test@c.com",
"credit_balance": "10",
"last_assign_credit": 10,
"consumed_credit": 0,
"logs": [
{
"id": "175",
"user_id": "1",
"post_id": "345",
"order_id": "0",
"event": "Company Credit Added",
"amount": "10.00",
"created": "2021-03-03 14:03:31"
}
]
}
}
Edit Company
Edit Company.
HTTP Request
{{site_url}}wp-json/wc/v3/wcb2brp/company/edit_company
Available Parameters
Parameter | Description |
---|---|
company_id |
required |
owner_email |
optional |
allow_assign_role |
optional -yes or no |
enable_credit_payment |
optional -yes or no |
credit |
optional |
company_name |
optional |
Sample Response:
{
"status": 200,
"data": {
"ID": "345",
"company_name": "edited test company",
"enable_credit_payment": "yes",
"allow_assign_role": "yes",
"owner_email": "edited@c.com",
"credit_balance": "20",
"last_assign_credit": 10,
"consumed_credit": 0,
"logs": [
{
"id": "175",
"user_id": "1",
"post_id": "345",
"order_id": "0",
"event": "Company Credit Added",
"amount": "10.00",
"created": "2021-03-03 14:03:31"
},
{
"id": "176",
"user_id": "1",
"post_id": "345",
"order_id": "0",
"event": "Company Credit Added",
"amount": "10.00",
"created": "2021-03-03 14:05:13"
}
]
}
}
Company Credit Payment
Update Ccp Settings
Update Company Credit Payment Gateway Settings.
HTTP Request
{{site_url}}wp-json/wc/v3/wcb2brp/ccp/update_settings
Available Parameters
Parameter | Description |
---|---|
enabled |
optional -yes or no |
title |
optional |
description |
optional |
instructions |
optional |
Sample Response:
{
"status": 200,
"data": {
"current_value": {
"enabled": "yes",
"title": "Company credit payment",
"description": "desc",
"instructions": "this is instructions"
}
}
}
Get Company Credit Details
Get Company Credit Details.
HTTP Request
{{site_url}}wp-json/wc/v3/wcb2brp/ccp/get_credit
Available Parameters
Parameter | Description |
---|---|
company_id |
required |
Sample Response:
{
"status": 200,
"data": {
"ID": "338",
"company_name": "test",
"credit_balance": 0,
"last_assign_credit": -20,
"consumed_credit": 42
}
}
Update Company Credit
Update Company Credit.
HTTP Request
{{site_url}}wp-json/wc/v3/wcb2brp/ccp/update_credit
Available Parameters
Parameter | Description |
---|---|
company_id |
required |
credit |
required |
Sample Response:
{
"status": 200,
"data": {
"ID": "338",
"company_name": "test",
"credit_balance": "20",
"last_assign_credit": 20,
"consumed_credit": 42
}
}
Company Users
Get All Users Of Company
Retrieve All users of Company.
HTTP Request
{{site_url}}wp-json/wc/v3/wcb2brp/users/get_users
Available Parameters
Parameter | Description |
---|---|
company_id |
required |
Sample Response:
{
"status": 200,
"data": [
{
"data": {
"ID": "63",
"user_login": "Postman",
"user_pass": "$P$BJ99yKTERPtTlEGeZ7aqrjREIdwAUL1",
"user_nicename": "postman",
"user_email": "postman@codup.io",
"user_url": "",
"user_registered": "2021-03-01 07:21:01",
"user_activation_key": "",
"user_status": "0",
"display_name": "Post Man"
},
"ID": 63,
"caps": {
"customer": true,
"wcb2brp_company_orders": true,
"wcb2brp_view_users": true
},
"cap_key": "wp_capabilities",
"roles": [
"customer"
],
"allcaps": {
"read": true,
"customer": true,
"wcb2brp_company_orders": true,
"wcb2brp_view_users": true
},
"filter": null
},
{
"data": {
"ID": "64",
"user_login": "test owner",
"user_pass": "$P$BY5J6qfximuGKkM0udsbJaVHBno8sX0",
"user_nicename": "test-owner",
"user_email": "asmazia642@gmail.com",
"user_url": "",
"user_registered": "2021-03-01 07:32:35",
"user_activation_key": "1614583955:$P$B9N8MlCQW2gCtRk1KUk.WvRlL5lMz51",
"user_status": "0",
"display_name": "test owner"
},
"ID": 64,
"caps": {
"wholesaler": true,
"wcb2brp_company_orders": true,
"wcb2brp_view_users": true,
"wcb2brp_add_user": true,
"wcb2brp_set_rules": true,
"wcb2brp_edit_user": true,
"wcb2brp_delete_user": true
},
"cap_key": "wp_capabilities",
"roles": [
"wholesaler"
],
"allcaps": {
"read": true,
"wholesaler": true,
"wcb2brp_company_orders": true,
"wcb2brp_view_users": true,
"wcb2brp_add_user": true,
"wcb2brp_set_rules": true,
"wcb2brp_edit_user": true,
"wcb2brp_delete_user": true
},
"filter": null
}
]
}
Add User To Company
Add User to Company.
HTTP Request
{{site_url}}wp-json/wc/v3/wcb2brp/users/add_company_user
Available Parameters
Parameter | Description |
---|---|
email |
required |
company_id |
required |
first_name |
optional if user exist |
last_name |
optional if user exist |
Sample Response:
{
"status": 200,
"message": "User qiddykumoc-0394@yopmail.com with ID 65 Added to Company test",
"data": {
"ID": 65,
"username": "first871552464",
"first_name": "first",
"last_name": "last",
"company_id": "338",
"company_name": "test",
"company_role": [
"company_user"
],
"company_owner": ""
}
}
Edit Company User
Edit Company User.
HTTP Request
localhost/codup-products/wp-json/wc/v3/wcb2brp/users/edit_company_user
Available Parameters
Parameter | Description |
---|---|
email |
required |
company_id |
required |
first_name |
optional |
last_name |
optional |
Sample Response:
{
"status": 200,
"message": "User qiddykumoc-0394@yopmail.com with ID 65 edited successfully",
"data": {
"company_id": "338",
"company_name": "test",
"company_role": [
"company_user"
],
"company_owner": ""
}
}
Credit Logs
Get Logs
Retrieve All Credit Logs. (filter by company id , item per page , page , email and Users within company)
HTTP Request
localhost/codup-products/wp-json/wc/v3/wcb2brp/credit_logs/get_logs
Available Parameters
Parameter | Description |
---|---|
email |
(optional) - get all user logs - use as filter |
order_id |
(optional) - get all orders logs - use as filter |
page |
- |
company_id |
- |
items_per_page |
- |
Sample Response:
{
"status": 200,
"data": [
{
"id": "177",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "20.00",
"created": "2021-03-03 14:12:06"
},
{
"id": "174",
"user_id": "64",
"post_id": "338",
"order_id": "341",
"event": "Company Credit Deducted",
"amount": "27.00",
"created": "2021-03-01 08:12:58"
},
{
"id": "173",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "-20.00",
"created": "2021-03-01 08:10:00"
},
{
"id": "172",
"user_id": "61",
"post_id": "338",
"order_id": "339",
"event": "Company Credit Deducted",
"amount": "15.00",
"created": "2021-02-26 10:10:18"
},
{
"id": "171",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "20.00",
"created": "2021-02-26 09:40:54"
},
{
"id": "170",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "20.00",
"created": "2021-02-26 08:27:59"
},
{
"id": "169",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "12.00",
"created": "2021-02-26 07:32:21"
},
{
"id": "168",
"user_id": "1",
"post_id": "338",
"order_id": "0",
"event": "Company Credit Added",
"amount": "10.00",
"created": "2021-02-26 07:27:24"
}
]
}
Company Orders
Get All Company Orders
Retrieve All Company Orders (Filter by Data range , is credit payment,item per page , page )
HTTP Request
{{site_url}}wp-json/wc/v3/wcb2brp/company_orders/get_orders
Available Parameters
Parameter | Description |
---|---|
company_id |
required |
item_per_page |
optional - default 10 |
page |
optional - default 1 |
credit_payment |
optional -yes or no - use as filter |
start_date |
optional - use as filter |
end_date |
optional - use as filter |
users |
optional- - use as filter - user ids (should be from same company) |
Sample Response:
{
"status": 200,
"data": [
{
"id": 341,
"parent_id": 0,
"status": "processing",
"currency": "USD",
"version": "5.0.0",
"prices_include_tax": false,
"date_created": {
"date": "2021-03-01 08:12:58.000000",
"timezone_type": 1,
"timezone": "+00:00"
},
"date_modified": {
"date": "2021-03-01 08:12:58.000000",
"timezone_type": 1,
"timezone": "+00:00"
},
"discount_total": "0",
"discount_tax": "0",
"shipping_total": "0.00",
"shipping_tax": "0",
"cart_tax": "0",
"total": "27.00",
"total_tax": "0",
"customer_id": 64,
"order_key": "wc_order_U2H0NftaTrNCg",
"billing": {
"first_name": "test",
"last_name": "test",
"company": "",
"address_1": "abc",
"address_2": "",
"city": "abc",
"state": "SD",
"postcode": "123",
"country": "PK",
"email": "asmazia642@gmail.com",
"phone": "123"
},
"shipping": {
"first_name": "test",
"last_name": "test",
"company": "",
"address_1": "abc",
"address_2": "",
"city": "abc",
"state": "SD",
"postcode": "123",
"country": "PK"
},
"payment_method": "wcb2brp-credit-payment",
"payment_method_title": "easy paisa",
"transaction_id": "",
"customer_ip_address": "110.93.240.113",
"customer_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36",
"created_via": "checkout",
"customer_note": "",
"date_completed": null,
"date_paid": {
"date": "2021-03-01 08:12:58.000000",
"timezone_type": 1,
"timezone": "+00:00"
},
"cart_hash": "f8b9a43b5346ebc03df6d38e7e73b85d",
"number": "341",
"meta_data": [
{
"id": 5846,
"key": "is_vat_exempt",
"value": "no"
},
{
"id": 5853,
"key": "_new_order_email_sent",
"value": "true"
}
],
"line_items": {
"159": {},
"160": {}
},
"tax_lines": [],
"shipping_lines": {
"161": {}
},
"fee_lines": [],
"coupon_lines": []
}
]
}
Custom Roles
Add Custom Role
Add Custom Role in Company.
HTTP Request
{{site_url}}wp-json/wc/v3/wcb2brp/custom_role/add_role
Available Parameters
Parameter | Description |
---|---|
company_id |
required |
custom_role |
required |
Sample Response:
{
"status": 200,
"message": "Custom Role our new role Successfully added"
}
Template Overriding
How To Edit
Edit files in an upgrade-safe way using overrides. Copy the template into a directory within your theme named
/codup-woocommerce-b2b-roles-permissions
keeping the same file structure but removing the /templates/
subdirectory.
The copied file will now override the WooCommerce B2B Roles & Permissions default template file.
Warning: Do not edit these files within the core plugin itself as they are overwritten during the upgrade process and any customizations will be lost.
Template list
Template files can be found within the /codup-woocommerce-b2b-roles-permissions/templates/
directory:
- admin
- cart
- emails
- myaccount