Contract Overview

Contracts allow an organization or customer group to purchase specific products from a store and a specific price for a specific time.

They allow catalog filtering and price rules to be applied to products that change the items available for purchase along with the price of those items. This contract can then be assigned to a customer group or organization in the B2B model.

Creating a Price Rule

Log into Management Center and select the Catalog Filter and Pricing option.

You can make any kind of price rule you need for the contract. A simple example is to create a new price list, add some products, and then create a rule that uses the first condition matched. The branches are then set up to match a product in the new price list or default to the existing price list.

Creating a Catalog Filter

Using the same Catalog Filter and Pricing option in Management Center, create a catalog filter by selecting categories or SKUs to explicitly include or exclude. Typically, categories and SKUs will be included by default, so they just need to be excluded.

A filter can be applied to a contract, and then multiple contracts may be applied to a customer. In that case, each filter is treated independently of the other. For example, category A, B, C may exist with A being excluded. Another filter could exclude B. When both are applied, the first filter includes B since it’s not explicitly excluded and the second filter includes A for the same reason. The result is A, B, and C are all included.

To get around this, the filters need to include and exclude categories. So if the filters were set up so that A was included while B and C were excluded, and the same way for B and C, applying two filters would include A, but exclude the rest. The next filter would include B, but exclude the rest. With both excluding C, only A and B would be available.

The other option is to have the base contract exclude everything. Then each contract would only do to include catalog entries without having to also explicitly exclude the others.

Create the Contract

Create the contract by using Accelerator. Participants can be added, which are orgentities that are descendants of the basecontract organization. Catalog Filter lets you create a new catalog filter, which is not the same as selecting the one created from Management Center.

Under the Extended TC option, Catalog Filter and Price Rule tables allow you to select the ones created in CMC.

Errors

The common error is:
The catalog entry number “1234” and part number “ABC123” is not valid for the current contract.

Which will prevent the cart from being submitted. This appears to be an issue with the multiple contracts. Not all contracts will be validated. When the order item is added to the table, the contract id is also passed in. When storefronts, especially custom code, go from dealing with one contract to several, it’s common to see the current trading agreements from the command context be used, which is an array, and just default to using the first one.

By default, the database is used to check for entitlement unless wc.search.entitlement in the storeconf table is set to 1. This would use Solr for the product entitlement checks instead of going to the database. Solr expressions are created and saved in the expressions table. Using Solr for both catalog display and entitlement ensures that both are in sync.

If this error still happens with Solr being used for both, the wrong contract id could be saved into the orderitems table. During product entitlement checking, that’s the id that will be used to valid the product, and not any other contract ids that are associated.

During order item add, the contract id is passed in. By default, the customer must select the contract to use while browsing. For custom solutions that show multiple contracts that are mixed together without requiring the customer to first pick a contract to shop under, a custom solution would need to be created to pass in the required contact id during add to cart or to call the setContractInSessionCmd to put the active contract at the time of browsing. IBM doesn’t support multiple contracts displayed mixed together. The customer would have to select the contract manually from a list to use the out of the box code.

Once the contract id is being correctly saved as the trading_id in the orderitems table, that error should go away, and the order will submit as expected.