1. Documentation /
  2. Role Based Pricing for WooCommerce

Role Based Pricing for WooCommerce

Setup and Configuration

↑ Back to top
After activating WooCommerce Role Based Pricing, you can see the “Price by User Role” in the WordPress admin menu and access the product level settings from the product edit page.

Set up Role Based Pricing from Product Level

↑ Back to top

Go to the product edit page and click on the “price by user role” to access the product level settings. The product level settings allow you to,

  • Select user role and customer for which you want to change the prices
  • Set a fixed price or increase/decrease price by a percentage or a fixed amount
  • Set up minimum and maximum order quantity

Change Prices for Specific Variation

↑ Back to top

To update the price for any variation, go to the product edit page and edit the variation. Under the variations settings, you can see the new “Price by User Roles” section. From here you can update the price for each variation. Please note, currently, there is no option to update prices in bulk for attributes and variations.

Set up Role Based Pricing in Bulk

↑ Back to top

To update product prices for specific user roles or customers in bulk go to “Price by User Role” from left admin menu and navigate to “Add New Rule”. While adding a new rule you can,

  • Specify the user role or customers for which you want to update prices.
  • Select products or categories for which you want to change prices
  • Set a fixed price or increase/decrease price by a percentage or a fixed amount
  • Set up minimum and maximum order quantity

Same discount will be applied to all variations of a variable product.

General Settings:

↑ Back to top

Using the general settings tab, you can customize following options:

  • Control tax on discounts
  • Enforce min and max quantity (If enabled the customer won’t be able to purchase out defined quantity range in role based pricing. If unchecked, the customer will be able to purchase outside the range but at existing price)
  • Exclude user roles (If you have too large list of user roles, you can exclude some from this settings. Once excluded, they wont appear in product pages for configure role based pricing for them)
  • Apply role based pricing discount/markup on regular or sale OR do not apply role based discount at all if the product is already on sale price

Import Export Prices:

↑ Back to top

You can import and export role based pricing and rules from the extension settings tab. The formate for CSV file has been well explained to ensure smooth import and export operations. 

WooCommerce Role based prices import export

 

Hide Price and Add to Cart Button

↑ Back to top

Go to Role-Based Pricing from admin menu and go to Hide Price settings. Here you can configure the following options,

  • Hide price and add to cart
  • Hide only add to cart
  • Hide for not logged in users
  • Hide for registered users (specific user roles)
  • Replace price with custom text
  • Replace Add to Cart with new customizable button
  • Customize Button Text & Link
  • Hide for specific products and categories
  • To hide for the entire catalog, select all categories

Understand the Priorities

↑ Back to top

The plugin has specific priorities to handle overlapping price adjustments. Here is how the default priorities work.

1.  Product Level Settings
1a. Price set for specific customer
1b. price set for specific user role

2. Rule-Based Settings
2a. Price set for specific customer
2b. Price set for specific user role

Common issues & their fixes:

↑ Back to top

Customer-specific pricing is working but role-based pricing is NOT working

When you configure customer-specific pricing, the rule-based pricing will not work for that specific customer however it will work for the rest of the customers and user roles.

How to create user roles? I cannot see wholesale user role after installing this extension.

This extension does not add user roles, you can use any free available user roles editor plugin to add roles. Once the roles are added the same roles will start appearing in extension configurations.

After setting up the role-based pricing – the add to cart button is not working.

When you configure minimum quantity great than 1.  On the front end, the product will not be added to the cart unless the customer enters quantity more than the minimum limit or less than the maximum limit. You are not seeing any notification, probably because you have not added any minimum/maximum quantity error message. Go to backend > Role-based pricing and navigate to “settings” page to add custom messages for minimum and maximum quantities.

Is it compatible with Product Addons?

No, the plugin compatible with default variations. Currently, it’s not compatible with any product options or addons plugin. However, it is listed under our future development plans.

REST API Compatibility (Readonly)

↑ Back to top

Role Based Pricing supports rest API readonly access. To utilise REST API you must be using:

  1. WooCommerce 3.5+.
  2. WordPress 4.4+.
  3. Role-based pricing 1.6.1+
  4. Pretty permalinks in Settings > Permalinks so that the custom endpoints are supported. Default permalinks will not work.
  5. You may access the API over either HTTP or HTTPS, but HTTPS is recommended where possible.

Authentication

We have extended v3 version of WooCommerce REST API. Read more about the WooCommerce authentication here.
https://woocommerce.github.io/woocommerce-rest-api-docs/#authentication

List all pricing rules

↑ Back to top

You can list all role based pricing rules using the following,

HTTP Request:

/wp-json/wc/v3/role_based_rules/

CURL:

curl https://example.com/wp-json/wc/v3/role_based_rules 
\-u consumer_key:consumer_secret

Response:

[
    {
        "data": {
            "id": 6601,
            "title": "Rule Two",
            "all_products": "",
            "products": [
                "16",
                "13"
            ],
            "categories": [
                "6601"
            ],
            "date_created": "",
            "date_created_gmt": "",
            "date_modified": "",
            "date_modified_gmt": "",
            "post_status": "publish",
            "priority": 3,
            "customers_rules": "",
            "user_roles_rules": {
                "administrator": {
                    "discount_type": "fixed_price",
                    "discount_value": "100",
                    "min_qty": "6",
                    "max_qty": "18",
                    "replace_orignal_price": ""
                },
                "editor": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "author": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "contributor": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "subscriber": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "customer": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "shop_manager": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "translator": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "group_leader": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "guest": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                }
            }
        },
        "headers": [],
        "status": 200
    }
]

List Role Based Pricing by Product

↑ Back to top

Using the following, you can fetch the role based prices by product. The result will list product level role based pricing and role based pricing implement from rules if any.

HTTP Request:


/wp-json/wc/v3/role_based_pricing/product/{product_id}

CURL


curl https://example.com/wp-json/wc/v3/role_based_pricing/product/{product_id}
\-u consumer_key:consumer_secret

Response

Variable Product


[
    {
        "product_id": 13,
        "title": "Hoodie",
        "sku": "woo-hoodie",
        "type": "variable",
        "variations": {
            "29": {
                "variation_id": 29,
                "title": "Hoodie - Red, No",
                "type": "variation",
                "customers_rules": [
                    {
                        "ID": "29",
                        "customer_name": 21,
                        "discount_type": "fixed_price",
                        "discount_value": "200",
                        "min_qty": "0",
                        "max_qty": "0",
                        "replace_orignal_price": "yes"
                    }
                ],
                "user_roles_rules": {
                    "administrator": {
                        "discount_type": "fixed_price",
                        "discount_value": "100",
                        "min_qty": "",
                        "max_qty": ""
                    },
                    "editor": [
                        false
                    ],
                    "author": [
                        false
                    ],
                    "contributor": [
                        false
                    ],
                    "subscriber": [
                        false
                    ],
                    "customer": [
                        false
                    ],
                    "shop_manager": [
                        false
                    ],
                    "translator": [
                        false
                    ],
                    "group_leader": [
                        false
                    ],
                    "guest": [
                        false
                    ]
                }
            },
            "30": {
                "variation_id": 30,
                "title": "Hoodie - Green, No",
                "type": "variation",
                "customers_rules": "",
                "user_roles_rules": {
                    "administrator": [
                        false
                    ],
                    "editor": [
                        false
                    ],
                    "author": [
                        false
                    ],
                    "contributor": [
                        false
                    ],
                    "subscriber": [
                        false
                    ],
                    "customer": [
                        false
                    ],
                    "shop_manager": [
                        false
                    ],
                    "translator": [
                        false
                    ],
                    "group_leader": [
                        false
                    ],
                    "guest": [
                        false
                    ]
                }
            },
            "31": {
                "variation_id": 31,
                "title": "Hoodie - Blue, No",
                "type": "variation",
                "customers_rules": "",
                "user_roles_rules": {
                    "administrator": [
                        false
                    ],
                    "editor": [
                        false
                    ],
                    "author": [
                        false
                    ],
                    "contributor": [
                        false
                    ],
                    "subscriber": [
                        false
                    ],
                    "customer": [
                        false
                    ],
                    "shop_manager": [
                        false
                    ],
                    "translator": [
                        false
                    ],
                    "group_leader": [
                        false
                    ],
                    "guest": [
                        false
                    ]
                }
            },
            "36": {
                "variation_id": 36,
                "title": "Hoodie - Blue, Yes",
                "type": "variation",
                "customers_rules": "",
                "user_roles_rules": {
                    "administrator": [
                        false
                    ],
                    "editor": [
                        false
                    ],
                    "author": [
                        false
                    ],
                    "contributor": [
                        false
                    ],
                    "subscriber": [
                        false
                    ],
                    "customer": [
                        false
                    ],
                    "shop_manager": [
                        false
                    ],
                    "translator": [
                        false
                    ],
                    "group_leader": [
                        false
                    ],
                    "guest": [
                        false
                    ]
                }
            }
        }
    },
    {
        "data": {
            "rule_id": 6601,
            "title": "Rule Two",
            "all_products": "",
            "products": [
                "16",
                "13"
            ],
            "categories": [
                "6601"
            ],
            "date_created": "",
            "date_created_gmt": "",
            "date_modified": "",
            "date_modified_gmt": "",
            "post_status": "publish",
            "priority": 3,
            "customers_rules": "",
            "user_roles_rules": {
                "administrator": {
                    "discount_type": "fixed_price",
                    "discount_value": "100",
                    "min_qty": "6",
                    "max_qty": "18",
                    "replace_orignal_price": ""
                },
                "editor": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "author": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "contributor": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "subscriber": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "customer": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "shop_manager": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "translator": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "group_leader": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "guest": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                }
            }
        },
        "headers": [],
        "status": 200
    }
]

Simple Product:


[
    {
        "product_id": 14,
        "title": "Hoodie with Logo",
        "sku": "woo-hoodie-with-logo",
        "type": "simple",
        "customers_rules": {
            "10000": {
                "customer_name": "1",
                "discount_type": "percentage_decrease",
                "discount_value": "20",
                "min_qty": "10",
                "max_qty": "20",
                "replace_orignal_price": "yes"
            }
        },
        "user_roles_rules": {
            "administrator": {
                "discount_type": "percentage_decrease",
                "discount_value": "25",
                "min_qty": "10",
                "max_qty": "20",
                "replace_orignal_price": "yes"
            },
            "editor": [
                false
            ],
            "author": [
                false
            ],
            "contributor": [
                false
            ],
            "subscriber": [
                false
            ],
            "customer": {
                "discount_type": "percentage_decrease",
                "discount_value": "10",
                "min_qty": "5",
                "max_qty": "20",
                "replace_orignal_price": "yes"
            },
            "shop_manager": [
                false
            ],
            "translator": [
                false
            ],
            "group_leader": [
                false
            ],
            "guest": {
                "discount_type": "percentage_increase",
                "discount_value": "10",
                "min_qty": "",
                "max_qty": "",
                "replace_orignal_price": "yes"
            }
        }
    },
    {
        "data": {
            "rule_id": 94,
            "title": "Rule for Administrator",
            "all_products": "yes",
            "products": [
                "14",
                "13"
            ],
            "categories": [
                "94"
            ],
            "date_created": "",
            "date_created_gmt": "",
            "date_modified": "",
            "date_modified_gmt": "",
            "post_status": "publish",
            "priority": 1,
            "customers_rules": "",
            "user_roles_rules": {
                "administrator": {
                    "discount_type": "fixed_decrease",
                    "discount_value": "1000",
                    "min_qty": "1",
                    "max_qty": "10",
                    "replace_orignal_price": ""
                },
                "editor": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "author": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "contributor": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "subscriber": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "customer": {
                    "discount_type": "fixed_price",
                    "discount_value": "250",
                    "min_qty": "",
                    "max_qty": "",
                    "replace_orignal_price": ""
                },
                "shop_manager": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "translator": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "group_leader": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "guest": {
                    "discount_type": "fixed_price",
                    "discount_value": "150",
                    "min_qty": "5",
                    "max_qty": "10",
                    "replace_orignal_price": ""
                }
            }
        },
        "headers": [],
        "status": 200
    }
]

List all category pricing rules

↑ Back to top

This will help you to list role based pricing rules applying to any specific category only.

HTTP Request:


/wp-json/wc/v3/role_based_pricing/product/{category_id}

CURL:


curl https://example.com/wp-json/wc/v3/role_based_pricing/product/{category_id}
\-u consumer_key:consumer_secret

Response:


[
    {
        "data": {
            "id": 6601,
            "title": "Rule Two",
            "all_products": "",
            "products": [
                "16",
                "13"
            ],
            "categories": [
                "6601"
            ],
            "date_created": "",
            "date_created_gmt": "",
            "date_modified": "",
            "date_modified_gmt": "",
            "post_status": "publish",
            "priority": 3,
            "customers_rules": "",
            "user_roles_rules": {
                "administrator": {
                    "discount_type": "fixed_price",
                    "discount_value": "100",
                    "min_qty": "6",
                    "max_qty": "18",
                    "replace_orignal_price": ""
                },
                "editor": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "author": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "contributor": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "subscriber": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "customer": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "shop_manager": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "translator": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "group_leader": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                },
                "guest": {
                    "discount_type": "",
                    "discount_value": 0,
                    "min_qty": 0,
                    "max_qty": 0,
                    "replace_orignal_price": ""
                }
            }
        },
        "headers": [],
        "status": 200
    }
]