Validating a cart using Product Rule - Salesforce CPQ
Hi All,
Welcome to my new article.
While shopping online, many time we have seen that when we add any product to our shopping cart, it automatically adds another product to cart which is mandatory.
Now in case we remove that product, we will not be allowed to process further as that product was necessary to be available in cart to place an order
Ever wondered how this validation is getting handled in background?
Today we will learn how can we do that using Salesforce CPQ.
Use Case
We are purchasing a laptop online, now while adding laptop to the shopping cart it automatically adds warranty to the shopping cart.
Laptop doesn't get sold without warranty, if we remove warranty product from cart then we will not be allowed to place an order.
Now for the above scenario, we are going to need following things:
- Laptop product with few options
- Warranty product
- Product Rule to add Warranty automatically
- Summary Variable
- Product Rule to validate cart for having Warranty product
We are starting directly with Product Rule setup for validating cart.
Note: Kindly visit my previous articles to learn how products can be automatically included using Product Rule.
Steps to follow:
- Go to all tabs & open Summary Variable tab.
- Click 'New'.
- Provide following values and Click 'Save'.
Note:
- Summary variables are used get count, sum, average, min or max value Quote Line Product or Product Option.
- Here we wants to validate that a quote line for Warranty is available in cart or not and thus we have created a summary variable which is taking count of line item on which Product Code is 'WT-01' which is a product code for Warranty product.
- Create another Summary variable to get count of Laptop product in cart.
Note: We will have to create this summary variable and use that in Product Rule otherwise we will not be able to save the blank cart as well if needed.
- Go to all tabs & open Product Rule tab.
- Click 'New'.
- Provide following values & click 'Save'.
- Go to 'Related' tab & click 'New' button on Error Condition related list.
- Provide following values and click 'Save'.
Note: Here in Error Condition we are checking that our summary variable's value equals 0 then our validation message will appear on screen and it will not allows us to save the quote.
Summary variable will have value > 0 only if there is a quote line for warranty product available on cart and it that case the validation
- Create another Error Condition as shown in screenshot.
That is all, We are done with the necessary setup. now let us test the build.
Configuration Test
- Create a new Quote.
- Click 'Edit Lines'.
- Click 'Add Product'.
- Select 'Laptop' from Product Selection screen & click 'Select' button.
- Select Product Options, Attributes & click 'Save'.
- On cart, along with Laptop, Mouse & Key Board, we can see another line for product 'Warranty' which got automatically added when added Laptop to cart.
- Remove Warranty product from cart and click 'Save'. You will not be able to save the quote and will get following error message.
See how easy it was to setup a rule to validate a cart?
Feel free to reach out if you have any questions/suggestions.
Kindly also subscribe to my youtube channel SFDC Learning to get learning from video tutorials.
Thanks,
Mehul Parmar
Comments
Post a Comment