1

How can I create a rule to process checkout for all orders. Te be more specific: I'm creating a shop in which the whole checkout is based on a cronjob. So customers add their products to the shopping cart and every week at friday a cronjob is processed to process all shopping carts and create a order for them. Payment is not necessary, and users can not manually complete orders.

I've tried to create this in rules, but their is only the option to "Complete checkout for an order" not all orders.

0

There is no default Commerce rules action that selects all orders. You're going to have to build your own action, or find a contrib module that provides it for you, that selects such a list of commerce orders to act upon.

0

You can do a lot with rules, but that doesn't mean you should... but if you were going to try it, you might start here:

  1. Create a new Rule Component. (This is important.)
  2. Use rules to Fetch entity (Commerce Order) by property (status) to have it generate a list of commerce order entities. (Alternatively, you could use Views Rules to be a bit more granular.)
  3. Use Rules to loop over the list that has been loaded.
  4. Inside the loop, use the "Complete checkout for an order" action.

It may be advantageous for you to do some other stuff to (create a new transaction, send an email, etc). In that case, create a new rule component and use that inside your loop. Just make the action rule take an order as a parameter and then you can do a bit more. You could use that to check the conditions of an order (user, date, etc.) before processing it, too.

Finally, set up the Rules Scheduler module that ships with Rules and schedule the main rule to run when you'd like. Just make sure that the rule you schedule reschedules itself, otherwise it'll only run once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.