shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Customer Specific Pricing API

CSP API will help you Retrieve, Add, Update & Delete CSP rules for the products. this article will explain the usage of the CSP API feature.

Enable CSP API from WordPress admin Dashboard

  • Go to the CSP admin menu.
  • Select the settings tab.
  • Enable the API & save the settings as shown below.
Enable CSP API setting

Generating API keys

CSP API uses Woocommerce Rest API keys to interact with your website, follow the steps below to generate WooCommerce rest API keys

  • Login to your Admin Dashboard
  • Click WooCommerce Admin menu > Settings
WooCommerce Settings
  • To generate the new Rest API key pair Click on Advance Tab > REST API > ADD KEY
  • Add key description, select the user, Select permissions & Click “Generate API Key” button. (Refer the image below)
Generating WooCommerce Rest API Keys
  • Consumer Key & Consumer Secret will be visible on the window as shown below. copy these keys & keep safe as you won’t be able to see them again after leaving the page.
Consumer Key & Consumer Secret For WooCommerce Rest API

How To Use CSP API

Authorization Type: Oauth v1.0
(you have to replace “https://cspdev.wisdmlabs.net/” in request URI with your site name where the CSP API is enabled)

GET Requests : (To fetch the existing rules)

  • Get user-specific CSP rules
    • By user email
    • By user ID
      • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/usp/user-id/5
    • All user-specific rules for the product
      • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/usp/product-id/18
    • User-specific rules for the product & the specified user
      • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/usp/product-id/18/user-id/5/
  • Get role-specific CSP rules
    • By role slug
      • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/rsp/role/whole-seller
    • By product id
      • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/rsp/product-id/18
    • By product ID & role
      • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/rsp/product-id/18/role/whole-seller
  • Get group-specific CSP rules
    • By group name
      • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/gsp/group/?group_name=Special_Customers
    • By product id
      • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/gsp/product-id/18
    • By product ID & group name
      • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/gsp/product-id/18/group/?group_name=Special Customers

POST Requests : (To add/update the existing rule)

Hash Is to be calculated by running md5 on the string “18|4|1|%|10” for the following request, “<product id>|<customer id>|<min quantity>|<discount type>|<csp price>

  • Add/Update User Specific CSP Rule
    • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/usp/

JSON Request Body

{
"csp_data": [
{
"product_id": 18,
"customer_id": 4,
"min_qty": 1,
"discount_type": "%",
"csp_price": 10,
"hash": "ca843e8ef04374b162116d927c297eb2"
}
]
}

JSON Response

{
"success": {
"ca843e8ef04374b162116d927c297eb2": "Record added."
}
}
  • Add/Update Role Specific CSP Rule
    • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/rsp/

JSON Request Body

{
"rsp_data": [
{
"product_id": 18,
"role": "whole-seller",
"min_qty": 1,
"discount_type": "%",
"rsp_price": 14,
"hash": "45f5dea384bd9b32e375468cf0bbc935"
}
]
}

JSON Response

{
"success": {
"45f5dea384bd9b32e375468cf0bbc935": "Record updated."
}
}
  • Add/Update Group-Specific CSP Rule
    • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/gsp/

JSON Request Body

{
"gsp_data": [
{
"product_id": 18,
"group_name": "Special_Customers",
"min_qty": 2,
"discount_type": "%",
"gsp_price": 13,
"hash": "e3c4e764e300d103eaf6a29c0f6cd64f"
}
]
}

JSON Response

{
"success": {
"e3c4e764e300d103eaf6a29c0f6cd64f": "Record updated."
}
}

Delete Requests : (To delete the existing rule)

  • Delete User-Specific CSP Rule
    • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/usp/

JSON Request Body

{
"csp_data": [
{
"product_id":18,
"customer_id": "5",
"min_qty": 1,
"discount_type": "%",
"csp_price": 10,
"hash":"875e61c5d51a72a8af2c07f8a304aea6"
}
]
}

JSON Response

{
"success": [
"875e61c5d51a72a8af2c07f8a304aea6"
]
}
  • Delete Role-Specific CSP Rule
    • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/rsp/

JSON Request Body

{
"rsp_data": [
{
"product_id": 18,
"role": "whole-seller",
"min_qty": 1,
"discount_type": "%",
"rsp_price": 10,
"hash": "80e6a5380f0b5e17fb22b029af0c75aa"
}
]

JSON Response

{
"success": [
"80e6a5380f0b5e17fb22b029af0c75aa"
]
}
  • Delete Group-Specific CSP Rule
    • https://cspdev.wisdmlabs.net/wp-json/wc/v3/csp/gsp/

JSON Request Body

{
"gsp_data": [
{
"product_id": 18,
"group_name": "Special_Customers",
"min_qty": 1,
"discount_type": "%",
"gsp_price": 10,
"hash": "7e5d4ffd3e418f9242d409eb5fe37d8e"
}
]
}

JSON Response

{
“success”: [
“7e5d4ffd3e418f9242d409eb5fe37d8e”
]
}

Updated on January 23, 2020
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Was this article helpful?

shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php
shvsh > /home/1168859.cloudwaysapps.com/rcyqmhwrmv/public_html/docs/wp-content/plugins/ht-knowledge-base/ht-knowledge-base.php

Related Articles