Does this mean that it settles all the old orders, and for new orders we need to continue to manually settle and close the order?


Quote Originally Posted by philip_clarke View Post
I think carlvt88 is certainly along the correct lines, although I am not sure why the sort order is 999, but looking through some test data it does appear correct. I'd say that as a minimum the code should be

Code:
insert into so_payments (orders_id, payment_amount) 
select orders_id, value from zen_orders_total zot where zot.sort_order=999;
Which puts a space inbetween so_payments and the first bracket but leaves zen_orders_total as the default name, because I don't think the Install SQL patches box can add the correct table prefix to the second table in a sub-select query. Oh and one would need MySQL 4+ as the database backend in case anyone has joined this conversation late.

For the newbie the above code adds all the payments from the table orders_total (default name is zen_orders_total), to the super orders payments table so_payments which may on your system have zen_ stuck in front of the table name. If there are any DB_prefix errors that turn up using the above code, try adding or removing zen_ in front of the table name. if you get this error

ERROR: Cannot execute because table zen_so_payments(orders_id, does not exist.

it's because there is not a space in between the word payments and the first bracket in carlvt88's otherwise excellent code.

Philip.