Akopia Akopia Services

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

[ic] Set mv_price upon addition to cart



On my results page, when a user clicks "add to cart", I would like to set 
$Carts->{main}->[$line]{mv_price} for that lineitem.

I'm trying to do it with mv_click code, but the item doesn't seem to be 
added to the cart until after mv_click (i.e. after refresh).  My mv_click 
happens to do [munge_quantity], so that's where I'm working in...

So I thought I would try to do
[set munge_quantity]
mv_price=99.99
[/set]

But that didn't take either.

However, I *can* modify mv_price if I loop through the entire cart.  But 
why do that when I just want to set the price once when the user adds it to 
his cart?

I've been pouring over docs and the mailing list for the past 14 hours, and 
at this point I would appreciate any tips or directional suggestions.  Thanks!

-Dan

Here's a snippet:

[set munge_quantity]
mv_price=99.99
[calc]
         $Scratch->{did_order} = 1;
         @q = split /\0/, $CGI->{mv_order_quantity};
         for (@q) {
                 next unless length $_;
                 $_ = "=$_";
         }
         @parms = grep /^mv_oi\d+/ && $CGI->{$_}, keys %{$CGI};

         # If we have parms, means an individual buy. If we don't
         # we want to strip empty items
         unless (@parms) {
                 @i = split "\0", $CGI->{mv_order_item};
                 for(my $i = 0; $i < @i; $i++) {
                         next if length($q[$i]);
                         $i[$i] = '';
                 }
                 @i = grep length($_), @i;
                 @q = grep length($_), @q;
                 $CGI_array->{mv_order_quantity} = \@q;
                 $CGI->{mv_order_quantity} = join "\0", @q;
                 $CGI_array->{mv_order_item} = \@i;
                 $CGI->{mv_order_item} = join "\0", @i;
                 return;
         }
         my $item = $parms[0];
         $item =~ /(\d+)/ or return;
         my $idx = $1;
         $idx--;
         $CGI->{mv_order_item} = $CGI->{$item};
         $CGI->{mv_order_quantity} = "$q[$idx]";

# munge_quantity done, now modify price
# (this works, but doesn't access the last lineitem)
         my $cart = $Carts->{main};
         my $price = 99.99;

         for( my $i = 0; $i < @$cart; $i++) {
                 $cart->[$i]{mv_price} = $price;
         }
         return;
[/calc]
         [bounce href="[history-scan exclude=nothing]"]
[/set]


Dan Browning, Cyclone Computer Systems, danb@cyclonecomputers.com


_______________________________________________
Interchange-users mailing list
Interchange-users@lists.akopia.com
http://lists.akopia.com/mailman/listinfo/interchange-users


Search for: Match: Format: Sort by: