If you're using the standard e-commerce Discount, I recommend hiding the discount Enabled checkbox from sellers, making the Enabled value false when Discounts are created, and allowing only admins to change the discount Enabled value. Doing the following steps is how you can implement this:
- Go to Modules > E-commerce > Classes and edit the Discount class.
- In the Fields tab, edit the DiscountEnabled field.
- In the Visibility condition field, add the following to only allow admin/global admin to see this field (you can modify this as needed):
(CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)) || (CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
- Save the changes.
-
Now you need to make sure all new discounts are created with the Enabled field set to false. Since you can't do that in the admin interface with the Default value, you'll need to create an event handler that sets the Enabled field to false. This DiscountInfo.TYPEINFO.Events.Insert.After event handler should do the trick:
private void DiscountInfo_Events_Insert_After(object sender, ObjectEventArgs e)
{
DiscountInfo discountInfo =
DiscountInfoProvider.GetDiscountInfo(((DiscountInfo)e.Object).DiscountID);
discountInfo.DiscountEnabled = false;
DiscountInfoProvider.SetDiscountInfo(discountInfo);
}
Now any discounts added by a seller would be disabled when they are created, and only admins/global admins can enable them.