Defining Advanced Rules Using Configuration Type

Use configuration type advanced rules to create product compatibility rules based on a condition. Compatibility rules determine if a product combination is valid.

Using Compatibility Rules, you can define that, when a product is added to the cart, related products are added with it. You can also automatically add, automatically remove, or recommend products based on other products in the cart.

For example, if you add more than one Samsung Galaxy S10e to the cart, then a Samsung Galaxy S20e is automatically added to the cart at no additional cost. You can also add another condition where if you purchase a modem or a mobile phone, such as a Samsung Galaxy S20e, then you get a six-month Internet plan.

To define advanced rules using Configuration type:

  1. Set up an interface implementation named ProductValidationInterface. For more information, see Interfaces, Implementations, and Services and Adding a New Interface Implementation.

    Set the default interface/Active Implementation Class to ValidationRulesImplementation. The interface implementation should point to Product Relationships.

    Product Validation Interface

  2. Create a product relationship. For more information, see Product Relationships Overview.

    Product relationship

    • Set the Relation Type to Auto-Add.

    • Set the AddMode to asRoot. The Samsung Galaxy S10e is the root.

  3. Set up an Entity Filter. For more information, see Create a Compatibility Rule.

    Set up an Entity Filter

    • Make sure the quantity is greater than 1 so the Auto-Add works.

    • For Entity Filter Conditions, the Field/Attribute/Related Object list is populated according to your selection in the Filter On Object Name field.

  4. From the App Launcher, click Vlocity Rules. For more information, see Accessing the Vlocity Rule Builder.

  5. Click New.

  6. Click Edit Mode.

  7. Enter a rule name and a description.

  8. In the first field, select Configuration.

  9. In the second field, use Order Product<OrderItem>. Opportunity and Quote are not applicable.

  10. Set the rule to Active.

    Customer SLA Rule Set

  11. Expand the FILTERS AND ACTIONS list and click the Filters button.

  12. Click Add to Rule Filter and specify the conditions to satisfy.

  13. Click the Actions button and specify the action to execute to satisfy that condition. For example, if you have an order line item with Samsung Galaxy S10e, then the Samsung Galaxy S20e will be automatically added as the action to satisfy the condition.

  14. Repeat the above steps to add more conditions and actions.

  15. Click Save.

  16. In your API platform, set the HTTP method to POST.

  17. Add the Samsung Galaxy S10e product to an empty basket:

    /services/apexrest/vlocity_digital/v3/catalogs/catalogCode/basket

    Add product to an empty basket

    The default quantity of the Samsung Galaxy S10e is 1. The Samsung Galaxy S20e has not yet been auto-added because the condition states that the Samsung Galaxy S10e product equals 1. Once the quantity of Samsung Galaxy S10e is greater than 1, then the Samsung Galaxy S20e is automatically added.

  18. Add the bundle context to the request body, which upgrades the line item quantity to 2.

    Add the bundle context to the request body

The Samsung Galaxy S20e is automatically added.

You can update fields that are related to the cart line items/order items. Based on those fields, you can write the entity filter. You can not use any fields on the order unless they are related to the order contract.

Logged-in users can pass all the entity filters that are related to Account ID and Contract ID as part of the orders. Anonymous users do not get those additional entity filters.