Akopia Akopia Services

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

Re: [mv] inventory::qty/item-quantity condition



******    message to minivend-users from Handytman@aol.com     ******

Stan,
Here's how I did something similar. Picture if you will, a catolog with one 
shopping cart ("main") and an inventory.asc database where available 
quantities are tracked (for certain products) and an extra field in 
products.asc ("limited") which contains 'yes' for each product that is 
available in a limited quantity, and thus listed in inventory.asc.

This perl code loops through the contents of the main shopping cart, checks 
the "limited" field for each product, and if that contains 'yes,' it compares 
the quantity the customer has ordered with the quantity available (from 
inventory.asc.)

How does that work for you?

[perl arg="carts"]
   $out = '';
   $code = '';
   $qty = '';
   $ltd = '';

   # Loop over all items in cart:
   foreach my $item ( @{$Safe{'carts'}->{'main'}} ) {
    
    $code = $item->{'code'};
    $ltd = &tag_data('products', 'limited', $code);

    $out .= "";
    $out .= "item code = $code \n";

    # is this item available only in a limited quantity?
    if ( $ltd eq 'yes' ) {
        $qt_ord = $item->{'quantity'};
        $qt_avl = &tag_data('inventory', 'qty', $code);
        $out .= "limited? ***yes*** \n";
        $out .= "quantity ordered: $qt_ord\n";
        $out .= "quantity available: $qt_avl\n";
        
        if ($qt_ord > $qt_avl) {
            $out .= "Too many ordered. Must reduce quantity.";
            $item->{'quantity'} = $qt_avl;
            $out .= "Shopping cart now contains quantity of 
$item->{'quantity'}";
            }
        }
    
    $out .= "";
    }
   return $out;
  [/perl]



HTH,
Rob Maurer

In a message dated 2/5/00 1:32:20 PM Eastern Standard Time, 
stanc@amintech.com writes:

> Using MiniVend V3.14-3
>  I'm working on a cart which displays the "quantity on hand" on each order
>  page using [data inventory qty [item-code]].
>  
>  If sold out, the order pages display:
>  [if data inventory::qty::[item-code] < 1]
>  SOLD OUT
>  [else]
>  <A HREF="[area order [item-code]]">
>  PLACE ORDER</A>
>  [/else]
>  [/if]
>  
>  It is critical that the customer not be allowed to place an order for a
>  quantity that is greater than the quantity on hand for any item.  So...
>  on the checkout page, I was trying to do something like the following:
>  [item-list]
>  [if data inventory::qty::[item-code] < [item-quantity]]
>  [then][[item-quantity] == [data inventory::qty::[item-code]][/then]
>  [/if]
>  [/item-list]
>  As you can probably tell, I don't know how (or even 'if') this can be
>  accomplished.  Any suggestions will be most appreciated.
>  
>  Thanks!
>     - Stan
-
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: