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:

  1. Laptop product with few options
  2. Warranty product
  3. Product Rule to add Warranty automatically
  4. Summary Variable
  5. 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'.
No alt text provided for this image
  • Provide following values and Click 'Save'.
No alt text provided for this image

Note:

  1. Summary variables are used get count, sum, average, min or max value Quote Line Product or Product Option.
  2. 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.
No alt text provided for this image

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'.
No alt text provided for this image
  • Provide following values & click 'Save'.
No alt text provided for this image
  • Go to 'Related' tab & click 'New' button on Error Condition related list.
No alt text provided for this image
  • Provide following values and click 'Save'.
No alt text provided for this image

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.
No alt text provided for this image

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 OptionsAttributes & click 'Save'.
  • On cart, along with LaptopMouse & 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.
No alt text provided for this image

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

Popular posts from this blog

Pricing Waterfall Model - Salesforce CPQ

Summary Variable - Salesforce CPQ

Percentage of Total Pricing - Salesforce