# Copyright 2002-2007 Interchange Development Group and others
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.  See the LICENSE file for details.

UserTag order               Order        code quantity
UserTag order               attrAlias    item code
UserTag order               attrAlias    sku code
UserTag order               attrAlias    table base
UserTag order               attrAlias    database base
UserTag order               attrAlias    db base
UserTag order               attrAlias    mv_ib base
UserTag order               attrAlias    href page
UserTag order               attrAlias    variant mv_sku
UserTag order               addAttr
UserTag order               PosNumber    2
UserTag order               Version      1.7
UserTag order               Routine      <<EOR
# Returns an href to place an order for the product PRODUCT_CODE.
# If AlwaysSecure is set, goes by the page accessed, otherwise 
# if a secure order has been started (with a call to at least
# one secure_vendUrl), then it will be given the secure URL
sub {
    my($code,$quantity,$opt) = @_;
	$opt = {} unless $opt;
	my @parms = (
					"mv_action=refresh",
				  );

	push(@parms, "mv_order_item=$code");
	push(@parms, "mv_order_mv_ib=$opt->{base}")
		if($opt->{base});

	push(@parms, "mv_cartname=$opt->{cart}")
		if($opt->{cart});

	push(@parms, "mv_order_quantity=$quantity")
		if($quantity);

	push @parms, "mv_sku=$opt->{mv_sku}" if $opt->{mv_sku};

	$opt->{form} .= "\n" . join "\n", @parms;

	$opt->{page} = find_special_page('order')
		unless $opt->{page};

	if ($opt->{area}) {
		return tag_area($opt->{page}, $opt->{arg}, $opt);
	}
	else {
		return tag_page($opt->{page}, $opt->{arg}, $opt);
	}
}
EOR
