How do you guys suggest doing a warranty order ? Right now I use a discount code to make the order 100% free, so I impersonate the customer and place the order.
Is there a better way so I don't have to have discount codes that will give free products if the code got misused?
I think discount code is a reasonable way to do it. You could have a custom discount requirement rule created to check for impersonating.
(Or, if you are a user of Shipping Director, you can prevent checkout by checking for use of discount and not IsImpersonating. contact us if you need more info)
Add new 'Shipping Director' record - a variable to calculate when warranty. For example, if the Coupon Code is "warranty" (or "warranty a", or "warranty b", etc. below we use Contains() for match) :
Type Boolean Name IsWarranty Expression Customer.GetAttribute("DiscountCouponCode").Contains("""warranty""")
(Be sure to put in all those quote characters. The syntax is a little funny since nopC started to support multiple coupon codes. Maybe we'll add a helper function to next version of SD ;)
Then follow that record with
Type ErrorExit Name Check valid warranty usage Expression [IsWarranty] and NOT IsImpersonating Description "Invalid use of warranty coupon"
OK, just to set the record straight on this ;) ...
Although the HasAttribute extension works, it won't be able to check the DiscountCouponCode as in the above example (Coupon Code is "warranty" or "warranty a", or "warranty b", etc.). nopCommerce now supports multiple coupon codes stored in XML in the DiscountCouponCode attribute. If there is no coupon code entered, then the attribute will be the null string, and you cannot call methods (like ToLower() ) on null strings. So, to test any variation ("warranty a", or "warranty b", etc.), you can do this workaround: