It looks like the old function is still in there:
parse error at or near "to"
I haven't looked at the ecommerce code for 3.x in about 6 months though. Try putting the code for the new function in its own SQL file, drop the function and create the new one.