- 28 Sep 2022
- 1 Minute to read
Product can only be purchased by a team paying customer or a team admin
- Updated on 28 Sep 2022
- 1 Minute to read
This rules prevents customers and admins to purchase a product if the customer making the purchase isn't a team paying customer or team admin. It is great way to help team admins and paying customers prevent their team members from making certain purchases without their approval.
You need the following details to set up this rule:
- The ID of the product that can't be purchased if the customer isn't a team paying customer or a team admin.
Check out our tutorial on Finding Product IDs.
Log in to the Admin Panel if you aren't already.
Click Settings > Validation rules.
Click Add rule.
Click on Manual entry.
Name your validation rule.
Add a Description for your rule to let other admins know what it does at a glance.
Enable the This rule is active toggle.
Select Product sale in the Record type.
Add the Error message to display if the validation rule is not met.
Add the following code snippet to the Formula field.
record.Product.Id <> PRODUCT_ID OR record.Coworker.IsPayingMember() OR record.Coworker.IsTeamAdministrator()
- Replace PRODUCT_ID with the relevant product ID.
In the example below, the product ID is 123456789.
record.Product.Id <> 123456789 OR record.Coworker.IsPayingMember() OR record.Coworker.IsTeamAdministrator()
Click the Save Changes button.
All done! We recommend trying to purchase the relevant product using a dummy customer account who isn't a team admin or paying customer. If you receive the error message you've defined in the rule, you're good to go!