Contract pricing

If your ERP has contract pricing functionality, the Stock2Shop B2B Trade Store allows you to create custom discount structures for each of your customers.

In the below documentation we will be covering:

What is a contract?

A contract exists on either a customer or a product, and it defines the rule for calculating a price. With our contract pricing feature, Stock2Shop can model complex pricing rule hierarchies that may exist in your ERP / accounting system to assign customers to pricing discounts per product.

Think of a contract as a set of rules to determine the price of a product for a specific customer. Below are some examples of how contracts can be set up:

  • For products in category “fruit”, give “wholesale” customers 10% off.
  • For products in category “fruit”, give “retail” customers 5% off.
  • For customers in group “wholesale”, give 10% off on “fruit”.
  • For customer “Acme Ltd”, give a fixed price of $10 for “bananas”.
  • For “bananas”, give “wholesale” customers a fixed price of $8.

Contract structure

A contract consists of the following elements:

  • Hierarchy: The order in which to load the contracts. The first applicable contract will be used.
  • Entity: The entity to which a particular contract applies. For example, a customer may have a contract with entity of “product”, or a product may have an entity of “customer”.
  • Key: The entity’s attribute to interrogate when considering a match. In the above example, this could be “product category” or “customer group”,
  • Value: The value of the contract, in the case of type discount, this would be a percentage expressed as an integer. In the case of a fixed price, it would be the price.
  • Type: A contract can specify a “fixed price” for a particular product, or it can designate a “discount” against a default price list.

The string representation of a contract looks like this:

order_{int}|entity_{string}|key_{string}|value_{string}|type_{string}

We could fill out a contract like this:

order_0|entity_product|key_category|value_fruit|type_discount

Contracts and meta data

Contracts are stored internally as key value data on customers and products. We call this meta data. Below is an example of some Meta data stored for a customer and product:

{
    "customer": {
        "company": "Acme Ltd",
        "meta": [
            {
                "key": "Group",
                "value": "Wholesale",
            }
        ]
    }
}
{
    "product": {
        "title": "Banana",
        "meta": [
            {
                "key": "Category",
                "value": "Fruit",
            }
        ]
    }
}

Adding in a contract to a product could look like this:

{
    "product": {
        "title": "Banana",
        "meta": [
            {
                "key": "Category",
                "value": "Fruit",
            },
            {
                "key": "order_0|entity_customer|key_Group|value_Wholesale|type_discount",
                "value": "8",
            }
        ]
    }
}

The above translates as follows:

For customers in group "wholesale", give 8% off on "bananas".

Adding in a contract to a customer could look like this:

{
    "customer": {
        "company": "Acme Ltd",
        "meta": [
            {
                "key": "Group",
                "value": "Wholesale",
            },
            {
                "key": "order_0|entity_product|key_Category|value_Fruit|type_discount",
                "value": "10",
            }
        ]
    }
}

The above translates as follows:

For products in category "fruit", give 10% off for "wholesale" customers.