Automatically finishing orders

Hiho! :slight_smile:

I noticed that orders are not finished automatically and it’s still possible to order after the order should have ended.
(Or is this a bug on my system…?)

So, is there a way to automatically finish orders?


Hi Martin,

At this moment orders are not automatically closed. The end date is more
an indicator until when members can order. Since someone needs to send
an email with the order anyway, I think it makes sense that this is a
manual action. (*)


  • Willem

(*) In the foodcoop-adam fork, the order will be sent to the supplier
automatically upon closing the order (when a supplier’s order_howto is
an email address). We would like to have automatic order cycles at some

Hi Willem!

Okay, thanks for this clarification!

So far we already had automated order emails, and of course it would be good to keep them when switching to Foodsoft (from a dreadful huge Google Docs spreadsheet…)
I adapted my order script to read the order information from the Foodsoft database, but it doesn’t make much sense to have an order cronjob if the order remains open in Foodsoft. :frowning:

I take it that just setting status = ‘finished’ in the database is not such a good idea…?


Hi Martin,

You could do an HTTP POST to https://foodcoop.test/f/orders/123/finish
which closes the order. Updating the database would not update the group
orders or send out emails to members.

  • Willem

Okay, I’ll try that. :slight_smile:
Thanks a lot!


Yay, seems to work! :slight_smile:

Here’s my script in case anyone’s interested:

set -e
set -u

user and password, urlencoded




temporary file for cookies

cookies=$( mktemp )
trap “rm -f ‘$cookies’” EXIT

get authenticity token

echo “Acquiring authenticity token…” >&2
wget -q -O -
–save-cookies “${cookies}” --keep-session-cookies
| sed -n ‘s/.<input name=“authenticity_token” type=“hidden” value="([^"])".*/\1/p’

log in

echo “Logging in…” >&2
wget -q -O /dev/null
–load-cookies “${cookies}” --save-cookies “${cookies}” --keep-session-cookies
–header “X-CSRF-Token: ${authenticity_token}”
–post-data “nick=${user}&password=${password}&authenticity_token=${authenticity_token}&foodcoop=f&utf8=%E2%9C%93”

finish order

echo “Closing order…” >&2
wget -q -O /dev/null \
–load-cookies “${cookies}” --keep-session-cookies
–header “X-CSRF-Token: ${authenticity_token}”
–post-data “”

echo “Done.” >&2

Thanks for sharing, Martin!