Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: [mv] Delete button for item (without Javascript)



******    message to minivend-users from Mike Heins <mikeh@minivend.com>     ******

Quoting Stefan Hornburg (racke@linuxia.de):
> I like to make a button which deletes one item from the basket.
> The following works, but I think this way to complicated.
> Any simpler approaches ?
> 
> [item-list]
> [perl interpolate=1]
> $i = 0;
> for (@$Items) {
>     if ($i == '[item-increment]' - 1) {
>         push (@qs, 'quantity' . $i++ . '=0');
>     } else {
>         push (@qs, 'quantity' . $i++ . '=' . $_->{quantity});
>     }
> }
> $Scratch->{qlist} = join ("\n", @qs);
> '';
> [/perl]
>     <td bgcolor="#999999"><img src="__IMAGE_DIR__/images/[item-field pic_mini]" width="33" height="32">[page form="
> mv_action=order
> mv_doit=refresh
> mv_nextpage=bottom
> [scratch qlist]
> "]<image src="images/button_delete.gif" border=0 width="33" height="31"></a></td>
> [/item-list]

Anything wrong with:

	<A HREF="[area
			href=ord/basket
			form='delete=[item-increment]'
		]">Delete from basket</A>

Then in basket:

	[calc]
		return unless $CGI->{delete};

		# using array allows multiple form-based delete
		my (@deletes) = grep /\d+/, split /\0+/, $CGI->{delete};

		my $cart = $Carts->{main};
		for @deletes {
		    # adjust down, 1 -> 0 etc.
		    $_--;
		    undef $cart->[$_];
		}
		@$cart = grep defined $_, @$cart;
		
		return;
	[/calc]

Of course, it would be more portable to use @@MV_PAGE@@ (or
__ORDER_STYLE__/basket in the demo) instead of ord/basket.

This comes up often enough that it may make sense to put
some auto-processing in.

-- 
Internet Robotics, 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.7621 fax 7501 <mikeh@minivend.com>

Light travels faster than sound. This is why some people appear bright
until you hear them speak. -- unknown
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: