Custom Logic in shopVOX: Evaluating Multiple Boolean Modifiers

Tyler MacDonald Updated by Tyler MacDonald

When working with custom logic in shopVOX, you might encounter situations where you need to evaluate multiple boolean modifiers. In this guide, we'll explore how to handle three boolean modifiers: High_Quality, White_Ink, and Double_Side. We'll look at how to evaluate these modifiers logically to determine the appropriate actions based on their combinations.

Understanding the Boolean Modifiers

  • High_Quality: Indicates whether the item is of high quality.
  • White_Ink: Indicates whether white ink is used in the printing process.
  • Double_Side: Indicates whether the item is printed on both sides.

Logical Evaluation of Boolean Modifiers

When you want to evaluate these modifiers, especially in a dropdown menu or as default items, you must consider the hierarchy and combinations of these choices. Since shopVOX does not toggle between multiple booleans natively, you need to implement logic to handle various combinations. The key is to determine the action to take based on whether 1, 2, or all 3 modifiers are selected.

Here's a step-by-step approach to implement this logic:

  1. All Three Modifiers Selected: When all three modifiers (High_Quality, White_Ink, and Double_Side) are selected, a specific action should be taken.
  2. Two Modifiers Selected: You need to evaluate the combinations where two of the three modifiers are selected and determine the actions accordingly.
  3. One Modifier Selected: Similarly, you must handle cases where only one of the modifiers is selected.
  4. No Modifiers Selected: Finally, if none of the modifiers are selected, a default action or no action should be taken.

Example Custom Code

Below is a pseudo code example demonstrating how you might implement this logic in the custom code box in shopVOX

(High_Quality && White_Ink && Double_Side) ? DoSomethingForAllThree
: (High_Quality && White_Ink) ? DoSomethingForHighQualityAndWhiteInk
: (High_Quality && Double_Side) ? DoSomethingForHighQualityAndDoubleSide
: (White_Ink && Double_Side) ? DoSomethingForWhiteInkAndDoubleSide
: (High_Quality) ? DoSomethingForHighQuality
: (White_Ink) ? DoSomethingForWhiteInk
: (Double_Side) ? DoSomethingForDoubleSide
: DoNothing;

Detailed Explanation of the Code

  • All Three Selected: (High_Quality && White_Ink && Double_Side) ? DoSomethingForAllThree checks if all three modifiers are true. If so, it sets action to DoSomethingForAllThree.
  • Two Modifiers Selected: The next conditions check for all possible pairs of modifiers:
    • (High_Quality && White_Ink) ? DoSomethingForHighQualityAndWhiteInk sets action to DoSomethingForHighQualityAndWhiteInk if both High_Quality and White_Ink are true.
    • (High_Quality && Double_Side) ? DoSomethingForHighQualityAndDoubleSide sets action to DoSomethingForHighQualityAndDoubleSide if both High_Quality and Double_Side are true.
    • (White_Ink && Double_Side) ? DoSomethingForWhiteInkAndDoubleSide sets action to DoSomethingForWhiteInkAndDoubleSide if both White_Ink and Double_Side are true.
  • One Modifier Selected: The next conditions check if only one modifier is true:
    • (High_Quality) ? DoSomethingForHighQuality sets action to DoSomethingForHighQuality if only High_Quality is true.
    • (White_Ink) ? DoSomethingForWhiteInk sets action to DoSomethingForWhiteInk if only White_Ink is true.
    • (Double_Side) ? DoSomethingForDoubleSide sets action to DoSomethingForDoubleSide if only Double_Side is true.
  • No Modifiers Selected: The final condition sets action to DoNothing if none of the modifiers are true.

This structure ensures that you can handle each possible combination of the boolean modifiers effectively, providing a clear and organized way to implement custom logic in shopVOX. By carefully considering the hierarchy and combinations, you can create a robust and flexible system for your custom logic needs.

How did we do?

Product Templates - Custom Formula Logic

Mastering the Use of &&, ||, and === in Ternary Operations

Contact