How to create a rule for specific attributes?

In this example, we'll create a rule to restrict the stock quantity to 12 units for product variations that match the attribute combination of Color: Green, Material: Silk, and Size: Medium.

The steps to create this scenario are below:

  1. Navigate to the rule creation section in the plugin settings.
Attribute stock rule configuration section
Attribute stock rule configuration section
  1. Set the rule status to enabled.
  2. Assign a title to the rule, such as "Restrict Stock for Green Silk Medium".
  3. Specify the SKU for the rule else it will auto generate from the title.
  4. Define the stock quantity to which the rule will apply, for example, 12 units.
  5. Add any additional notes or details about the rule.
  6. Optionally, set a low stock threshold to receive alerts when stock levels approach a certain limit.
  7. If needed, enable the "Limit Product Stock" option to restrict customers from choosing quantities beyond the defined stock quantity.
  8. Create a new group for the attribute combination.
  9. Add attributes and terms to the group:
    1. Attribute: Color, Term: Green
    2. Attribute: Material, Term: Silk
    3. Attribute: Size, Term: Medium
Attribute and term combination with multiplier
  1. For the created group, set the "Quantity Multiplier" field to 2. This means that if a product variation matches the specified attribute combination, 2 units of stock will be deducted from inventory.
  2. Save the rule settings.
  3. The rule is now active and will restrict the stock quantity to 6 units for product variations matching the attribute combination of Color: Green, Material: Silk, and Size: Medium.

Note: Here We have mentioned 6 units as stock because we have added 12 in stock in the rule and 2 as quantity multiplier for attribute and term combination. So in the end, 12/2 = 6 units of this combination can sell.

Now, we can check on the front end side how our product will look like when we apply rules to it.


The product will apply an attribute stock limit

If we have 4 stocks in the cart (which means our rule will understand 8 quantities as the stock multiplier is 2. e.g., 4 * 2 = 8). Then we add another 4 quantities into the cart then we can get a validation message.

Once we place an order on site it will show as our attribute stock status in the order note in the admin.

Attribute stock status show in order note

Note: As we can see there are 2 rules stocks are decrease. this is because we have matched the same combination in another rule. So our plugin will also update its stock status.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.