I'd like to create a shopping cart price rule that gives a user 10% off their order when and if they complete a process on my Magento site.
There's a method here that inserts the rule directly to the database. That's a bit invasive for my tastes.
How would I go about this using Magento methods?
As a general principle, you should be able to do anything that the Magento system itself does without writing a single line of SQL. Almost all the Magento data structures use Magento Model classes.
Run the following code somewhere to see what a salesrule/rule model looks like. This assumes you've created a single Shopping Cart Price Rule in the admin with an ID of 1
Using the dumped data as a guide, we can programatically create a model using the following
For anyone that's curious, the above is generated code, using the technique discussed here
Have a look at my code.It will add Action condition.
If you want to add Condition for shopping cart price rule then follow this example.