WooCommerce B2B Roles & Permissions Documentations - B2BWoo

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

Filters

    Frontend

  • wcb2brp_add_user_menu_label.

    Description:

    Modify menu name.

    Parameters:

    (string) $add_user_menu_label menu label.

  • wcb2brp_company_orders_menu_label.

    Description:

    Modify menu name.

    Parameters:

    (string) $company_orders_menu_label menu label.

  • wcb2brp_company_subscription_menu_label.

    Description:

    Modify menu name.

    Parameters:

    (string) $company_subscription_menu_label menu label.

  • wcb2brp_company_credit_menu_label.

    Description:

    Modify menu name.

    Parameters:

    (string) $company_credit_menu_label menu label.

  • wcb2brp_company_roles_menu_label.

    Description:

    Modify menu name.

    Parameters:

    (string) $company_roles_menu_label menu label.

  • wcb2brp_shared_carts_menu_label.

    Description:

    Modify menu name.

    Parameters:

    (string) $shared_carts_menu_label menu label.

  • wcb2brp_exceeded_credit_limit_notice

    Description:

    Modify notice of exceeded company credit payment limit.

    Parameters:

    (String) $exceeded_notice exceeded notice string.

    (Int) $credit_total credit.

  • wcb2brp_modify_company_title_on_myaccount.

    Description:

    Modify Company Title on My Account Page.

    Parameters:

    (string) $company_title Title of Company.

  • wcb2brp_my_account_company_orders_query.

    Description:

    Modify Query args for orders.

    Parameters:

    (array) $args Args .

  • wcb2brp_cat_rules_updated_notice

    Description:

    Modify notice of Category rules updated successfully.

    Parameters:

    (string) $cat_rules_updated_notice notice string.

  • restrict_to_cart_checkout_together_notice

    Description:

    Modify notice of Restrict to Cart only" and "Proceed to Checkout Only" cannot be selected together.

    Parameters:

    (string) $restrict_to_cart_checkout_together_notice notice string.

  • wcb2brp_disable_share_a_cart_notice

    Description:

    Modify notice of share a cart disable.

    Parameters:

    (string) $disable_share_a_cart_notice notice string.

  • wcb2brp_cart_rule_updated_notice

    Description:

    Modify notice of cart rule updated.

    Parameters:

    (string) $cart_rule_updated_notice notice string.

  • wcb2brp_price_limit_exceed_category_notice.

    Description:

    Modify notice of exceeded Price limit for category.

    Parameters:

    (string) $price_limit_exceed_cat_notice notice string.

    (int) $max_price max_price.

    (string) $category->name category_name.

  • wcb2brp_volume_limit_exceed_cat_notice.

    Description:

    Modify notice of exceeded Price limit for category.

    Parameters:

    (string) $volume_limit_exceed_cat_notice notice string.

    (int) $max_quantity max_quantity.

    (string) $category->name category_name.

  • wcb2brp_price_limit_exceed_category_notice.

    Description:

    Modify notice of exceeded Price limit for category.

    Parameters:

    (string) $price_limit_exceed_cat_notice notice string.

    (int) $max_price max_price.

    (string) $category->name category_name.

  • wcb2brp_volume_limit_exceed_cat_notice.

    Description:

    Modify notice of exceeded Price limit for category.

    Parameters:

    (string) $volume_limit_exceed_cat_notice notice string.

    (int) $max_quantity max_quantity.

    (string) $category->name category_name.

  • wcb2brp_restrict_to_checkout_notice.

    Description:

    Modify notice of You do not have permission to proceed to checkout.

    Parameters:

    (string) $restrict_to_checkout_notice notice string.

  • wcb2brp_restrict_to_checkout_notice.

    Description:

    Modify notice of You do not have permission to proceed to checkout.

    Parameters:

    (string) $restrict_to_checkout_notice notice string.

  • wcb2brp_cart_loaded_notice.

    Description:

    Modify notice of share a cart delete.

    Parameters:

    (string) $cart_loaded_notice notice string.

  • wcb2brp_share_cart_deleted_notice.

    Description:

    Modify notice of share a cart delete.

    Parameters:

    (string) $share_cart_deleted_notice notice string.

  • wcb2brp_share_cart_deleted_notice.

    Description:

    Modify notice of share a cart delete.

    Parameters:

    (string) $share_cart_deleted_notice notice string.

  • Backend

  • wcb2brp_modify_sales_by_company_menu.

    Description:

    Modify sales by company menu label.

    Parameters:

    (string) $modify_sales_by_company_menu string.

  • wcb2brp_modify_company_col_name_on_users.

    Description:

    Modify company column name on users list.

    Parameters:

    (string) $modify_company_col_name_on_users string.

Actions

    Frontend

  • wcb2brp_credit_logs_inserted.

    Description:

    Runs when credit log inserted.

  • wcb2brp_company_credit_payment_process.

    Description:

    Runs when Company Credit Payment used in order.

  • wcb2brp_delete_custom_role.

    Description:

    Runs when custom role delete on frontend.

  • wcb2brp_delete_user_action

    Description:

    Fires on Delete Company User.

  • wcb2brp_add_user_action

    Description:

    Fires on Add Company User.

  • wcb2brp_edit_user_action

    Description:

    Fires on Edit Company User.

  • wcb2brp_cat_rules_updated.

    Description:

    Runs when Category rules updated successfully.

  • wcb2brp_cart_rules_updated.

    Description:

    Runs when cart rules updated successfully.

  • wcb2brp_add_to_cart_not_valid.

    Description:

    Runs when wcb2brp add to cart not valid.

  • wcb2brp_update_cart_not_valid.

    Description:

    Runs when wcb2brp update to cart not valid.

  • wcb2brp_disable_access_to_checout.

    Description:

    Runs when You do not have permission to proceed to checkout.

  • wcb2brp_cart_shared.

    Description:

    Runs after cart shared.

  • wcb2brp_cart_loaded.

    Description:

    Runs when shared cart loaded.

  • wcb2brp_shared_cart_deleted.

    Description:

    Shared Cart Deleted.

  • wcb2b_add_company_email_before_content.

    Description:

    Add content after email content.

    Parameters:

    (int) $company_id company_id.

  • wcb2b_add_company_email_after_content.

    Description:

    Add content after email content.

    Parameters:

    (int) $company_id company_id.

  • wcb2b_add_c_user_email_before_content.

    Description:

    Add content after email content.

    Parameters:

    (int) $user_id user_id.

  • wcb2b_add_c_user_email_after_content.

    Description:

    Add content after email content.

    Parameters:

    (int) $user_id user_id.

  • wcb2b_share_cart_email_before_content.

    Description:

    Add content after email content.

    Parameters:

    (int) $user_id user_id.

  • wcb2b_share_cart_email_after_content.

    Description:

    Add content after email content.

    Parameters:

    (int) $user_id user_id.

  • wcb2brp_before_add_user_form.

    Description:

    Add content before Add User form.

  • wcb2brp_after_add_user_form.

    Description:

    Add content after Add User form.

  • wcb2brp_before_roles_form.

    Description:

    Add content before roles form.

  • wcb2brp_after_roles_content.

    Description:

    Add content after roles content.

  • wcb2brp_before_logs_filter.

    Description:

    Add content before all logs.

  • wcb2brp_after_credit_logs.

    Description:

    Add content after all logs.

  • wcb2brp_before_edit_user_form.

    Description:

    Add content before edit user form.

  • wcb2brp_after_edit_user_form.

    Description:

    Add content after edit user form.

  • wcb2brp_before_orders_filter.

    Description:

    Add content before Filter on All orders page.

  • wcb2brp_after_orders_list.

    Description:

    Add content after all orders listing.

  • wcb2brp_before_sharecart_byme_content.

    Description:

    Add content before share cart by me content.

  • wcb2brp_after_sharecart_byme_content.

    Description:

    Add content after share cart by me content.

  • wcb2brp_before_sharecart_withme_content.

    Description:

    Add content before share cart with me content.

  • wcb2brp_after_sharecart_withme_content.

    Description:

    Add content after share cart with me content.

  • wcb2brp_before_subscription_filter.

    Description:

    Add content before Filter on all subscriptions page.

  • wcb2brp_after_subscription_orders.

    Description:

    Add content after all subscriptions page.

    Parameters:

    (string) $wcb2brp_after_subscription_orders content.

  • wcb2brp_before_view_order.

    Description:

    Add content before view order.

  • wcb2brp_after_view_order.

    Description:

    Add content after view order.

  • wcb2brp_before_view_subscription.

    Description:

    Add content before view subscription.

  • wcb2brp_after_view_subscription.

    Description:

    Add content after view subscription.

  • Backend

  • wcb2brp_map_company_to_user_admin.

    Description:

    Runs when user map to company.

  • wcb2brp_map_company_role_to_user_admin.

    Description:

    Runs when user map to company role.

  • wcb2brp_map_user_as_owner_admin.

    Description:

    Runs when user map to owner.

  • wcb2brp_map_company_rules_user_admin.

    Description:

    Runs when user map to company rules.

  • wcb2brp_status_change_to_deducted.

    Description:

    Runs when order status change to deducted.

    Parameters:

    (int) $order_id order_id

  • wcb2brp_status_change_to_reverted.

    Description:

    Runs when order status change to reverted.

    Parameters:

    (int) $order_id order_id

  • wcb2brp_after_credit_logs_admin.

    Description:

    Add content after all logs list on admin.

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

GET
{{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

DELETE
{{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

GET
{{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

POST
{{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

PUT
{{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

PUT
{{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

GET
{{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

PUT
{{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

GET
{{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

POST
{{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

PUT
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

GET
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

GET
{{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

POST
{{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
WooCommerce B2B Roles & Permissions hooks documentation generated by Codup

Let’s Talk

We’re currently seeking beta testers for our managed cloud offering. Interested?