Hi all,
We were finding it quite laborious individually changing the dropdown status of a page full of orders from processed to complete so got xcart to write some javascript to change them all with one click of a button. It was written for a 4.1 store but just successfully installed on a 4.5.5 version so guessing it would work on most shops.
1) Create a file called change_all_statuses.tpl in skin/common_files/ and put this in it:
Code:
{*
Parameters:
statuses - array of tag names
statuses_form - form name with these statuses
*}
<SCRIPT>
function change_stat_all() {ldelim}
var x, y;
var formname, arr, options;
formname = statuses_form;
arr = statuses;
if(!document.forms[formname] || arr.length == 0)
return false;
for(x = 0; x < arr.length; x++)
if(document.forms[formname].elements[arr[x]] && document.forms[formname].elements[arr[x]].options[document.forms[formname].elements[arr[x]].selectedIndex].value == 'P') {ldelim}
options = document.forms[formname].elements[arr[x]].options;
for(y = 0; y < options.length; y++)
if(options[y].value == 'C')
document.forms[formname].elements[arr[x]].options[y].selected = true;
{rdelim}
{rdelim}
</SCRIPT>
2) Open skin/common_files/main/orders_list.tpl
Code:
AFTER
var txt_delete_selected_orders_warning = "{$lng.txt_delete_selected_orders_warning|wm_remove|escape:javascript|strip_tags}";
INSERT
var statuses = new Array({foreach from=$orders item=v key=k}{if $k > 0},{/if}'order_status[{$v.orderid}]'{/foreach});
var old_statuses = new Array({foreach from=$orders item=v key=k}{if $k > 0},{/if}'order_status_old[{$v.orderid}]'{/foreach});
var statuses_form = 'processorderform';
AFTER
{include file="main/check_all_row.tpl" form="processorderform" prefix="orderids"}
INSERT
{include file="change_all_statuses.tpl"}
<div><a href="javascript:change_stat_all();">Change All Processed to Complete</a></div>
3) do a template cleanup
Hope somebody finds this useful!