MiniVend Akopia Services

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

Re: How to delete item programmatically?



Hello Lee,

Here is a start for your problem. I have a similar situation as you. I have
a number of psuedo products that can not be ordered but I have to let
minivend know to remove these (code < 1000 and not starting with a letter).
So I made a positioned a usertag [basketcheck basket="name"] at the top of
basket.html, the page the user is directed to automatically when he orders
something.

Problem is though that the changes to the basket are not directly in effect
for the code that follows. Therefore I have to force a reload of the page to
make them valid.
I believe there is a reference to the shopping cart that might take effect
directly, but I can not use it because I am restricted by the Safe module.

I hope it helps,
Bas Bezemer


This is the code for the html-page

[if type=explicit compare="[basketcheck]"]
[tag op=header interpolate=1]
Status: 302 Found
Location: [area interpolate=1 href="special/noproduct" arg="[data session
arg]"]
Content-type: text/html
[/tag]
[/if]


This is the definition of teh usertag:

UserTag basketcheck Order basket
UserTag basketcheck Routine <<EOF
sub {
 my ($basket) = @_;
 $basket = "main" if ($basket eq "");
 my $cart = $Vend::Session->{carts}{$basket};
 my $item;
 my @newcart=();
 my $empty ="";
 foreach $item (@$cart)
 {
        if ($item->{code}<10000 && $item->{code}!~/^[A-Z]/ )
  {
   $empty=1;
   next;
  }
  @newcart = (@newcart, $item);
 }
 $Vend::Session->{carts}{$basket} = \@newcart;
 return $empty;
}
EOF



>******    message to minivend-users from Lee Nelson <jld123@pobox.com>
******
>
>Hello everyone,
>
>  I would like to be able to delete items from the
>cart automatically, with Perl code.  My Perl is
>pretty good, but I'm having some trouble getting
>this to work.
>
>  Do I just need to undef the item?  What's the
>syntax please?
>
>  In case you're curious, I only want one instance
>of the item to appear in the cart... If the user
>tries to add another, the first should disappear.
>I can do this on the form, or from a user tag.
>
>  I checked back through the mailing list archives,
>and couldn't find anything like this.
>
>  Thanks Much,
>
>    Lee Nelson

>-
>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: