Akopia Akopia Services

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

Re: [mv] Forcing new shipping selection



******    message to minivend-users from "Christopher P. Lindsey" <lindsey@mallorn.com>     ******

> For a qty of 1 or 2, economy post is OK but 3 or more will be couriered.
> 
> How can one either automagically change to a new shipping code or force
> the customer to change their selection ?

Your best bet is to use a usertag within ord/checkout.html.  For example,
I do:

   <SELECT MV=loop MV.ARG="[checkshipmodes
                            state='[value state]' country='[value country]'
                            ]"
            MV.OPTION="mv_shipmode"
            onChange="this.form.submit()"
            NAME="mv_shipmode"
    >

This calls a UserTag (called checkshipmodes) with the state and country
as an argument.  I can then check certain conditions and return a list
of available shipping options, which cross-reference into your shipping.asc
file.

Here's my checkshipmodes:

   UserTag checkshipmodes InsideHTML
   UserTag checkshipmodes Order state country
   UserTag checkshipmodes Routine <<EOR
   sub {
      my ($state, $country) = @_;
      my $shipmode;

      return "noship" if $state =~ /HI/i;
      $shipmode .= "ground " if ($state =~ /^(?:WA|OR|ID|CA|UT|NV)$/i ||
                                  $country !~ /^(?:United States|US)$/i);
      $shipmode .= "2-day" if ($state !~ /WA/i &&
                                  $country =~ /^(?:United States|US)$/i);
      return $shipmode;
   }
   EOR

And then shipping.asc has:

   2-day   2nd day air     quantity        0       9999999 f [perl arg="sub items values" interpolate=1]twoday({[item-list] '[item-code]' => {'price' => '[item-price]', 'shipping_id'  => '[item-field shipping_id]', 'quantity' => '[item-quantity]'},[/item-list]}) [/perl]

   ground  Ground  quantity        0       9999999 f [perl arg="sub items values" interpolate=1]ground({[item-list] '[item-code]' => {'price' => '[item-price]', 'shipping_id'  => '[item-field shipping_id]', 'quantity' => '[item-quantity]'},[/item-list]}) [/perl]

(Don't worry about the embedded perl; that's just so that I can do extra
calculations at ship time).

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