MiniVend Akopia Services

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

Re: Weights change by size, and multiple sizes



I am making a jewelry store and have run into the exact same problem.  Basically the weight of
a piece of jewelry is never exact.  Take a bracelet for example, if you buy it in the store its
listed weight is 2.2 grams.  But in reality, it can be anywhere from 1.9-2.4 grams.  What my
clients site is attempting to do is guarantee you are getting the exact weight.  The way we are
doing this is each product will be weighed and have its exact weight added to the inventory
database where it will look something like this:
code     types
1234     2.1,1.9,2.2,2.3,2.2,2.2,2.1 ...
the way this will work is when they view an item it will use the next available weight from
types and when they checkout it will remove that weight from inventory database.  I do not yet
know if i will have a problem with concurrent customers viewing and attempting to order the
same item at once, i have not yet tested it.

Back to your problem, the products prices are also dependent upon the length a customer
selects.  Changing the weight modifies the price.  What i have done is gotten the weight of
each item when it is 17" long and then figured out a grams/inch formula.  So i take the weight
in the database divided by 17 and multiply that times $item->{length}.  The only problem I have
is that it seems modifies can only be chosen offv the basket page and not the flypage?  I gotta
play around with it a little bit but on my flypage i have an [item_accessories length] and the
value of $item->{length} doesnt get set until they select the length off of basket.html in a
diff [item_accessories length] and hit recalc.  Below is the UserTag im using to figure out
prices.  I havent gotten up to shipping yet but i think it should work the same way.  There are
alot of variables flying around in my tag that most ppl could just ignore as my price is also
being modified by the current value of silver and the current exchange rate between dollars and
lyras :P  So if you can read my code i hope it helps but otherwise send me an email.  And if
anyone can help me with getting an item modifier to work on my flypage i'd appreciate it.

CommonAdjust <<EOF
"[tag touch products][/tag][price-mod][/price-mod]"
products:price
EOF

########### UserTag
UserTag price-mod HasEndTag
UserTag price-mod Interpolate
UserTag price-mod Routine <<EOR
sub {
    use Vend::Util;
    use Vend::Data;
    use Vend::Cart;
    use Vend::Server;
    my $s = $Vend::Interpolate::s;
    my $item = $Vend::Interpolate::item;
    my $adj=0;
    my $code=$item->{'code'};
    print("item: $item \n s: $s \n item->{'code'}: $item->{'code'} \n item->{'length'}:
$item->{'length'} \n item->{'mv_order_length'}: $item->{'mv_order_length'} \n
item->{'length0'}: $item->{'length0'}");
    # Do whatever you want to price here
    if ( $code =~ /05-02-/ ) {
## BEGIN LENGTH CODE
        my $lngth = database_field('products',$code,'length');
        my @lengths = split(/,/, $lngth);
        if ($lngth =~ /\*/) {
            for (my $i=0; $i<@lengths; $i++)
            {
                if($lengths[$i] =~ /\*/) {
                    $lngth = substr($lengths[$i],0,-1);
                }
            }
        } else {
            $lngth = $lengths[0];
        }
        my @newlength = split(/=/,$lngth);
        my $length = $newlength[1];
#        print("lngth: $lngth \n lengths: @lengths \n newlength: @newlength \n length:
$length");
## END LENGTH CODE
## BEGIN GRS CODE
        my $typefield = database_field('inventory',$code,'type');
        if($typefield =~ /"/) {
            $typefield = substr($typefield,1,-1);
        }
        my @types = split(/,/, $typefield);
        my $GRS = shift(@types);
#        my $GRS = database_field('products',$code,'GRS');
#        print("typefield: $typefield \n types: @types \n GRS: $GRS");
## END GRS CODE
        my $PER = database_field('products',$code,'PER');
        my $CUP = database_field('products',$code,'CUP');
        my $HOOK = database_field('products',$code,'HOOK');
        my $grsInch = $GRS/$PER;
        my $addons = $HOOK + 2*($CUP);
        my $dlsGram = $Global::Variable->{SVALUE}/31.1035;
        my $dlsLra = $Global::Variable->{LCONV};
        my $totalGs = ($grsInch*$length) + $addons;
        my $sub = $totalGs * $dlsGram;
        my $labor = $totalGs * $dlsLra*180;
        my $newprice = $sub + $labor;
        my $profit = $newprice * .6;
        my $price = $newprice + $profit;
#       print("code: $code \n GRS: $GRS \n PER: $PER \n CUP: $CUP \n HOOK: $HOOK \n grsInch:
$grsInch \n addons: $addons \n dlsGram: $dlsGram \n flsLra: $dlsLra \n lngth: $lngth \n
totalGs: $totalGs \n sub: $sub \n labor: $labor \n newprice: $newprice \n profit: $profit \n
price: $price");
        return $price;
    }
    return $adj;
}
EOR

Good Luck,
Ezra Gilbert

Ed LaFrance wrote:

> ******    message to minivend-users from Ed LaFrance <edlafrance@printexusa.com>     ******
>
> Mark wrote -
> >
> >I'm very sorry to take up the bandwidth here -- I've gotten most of my
> >initial questions answered by the search engine on the minivend site --
> >thank you to whomever set that up.
> >
> >I have been unable to shed any light on my problem.  I know there are
> >some cludge-y ways to accomplish this, but I was hoping for a more
> >elegant (simple) solution than what I've been able to come up with --
> >hopefully using the database structures and tags instead of code patches
> >here and there.
> >
> >Scenerio:
> >
> >Items have multiple sizes.
> >Each size is a different price. (hence, pricing.asc fields: code vs.
> >size = price)
> >Each size is a different weight.
> >
> >For computing shipping weights, which do you think?
> >
> >1. A separate shipprice.asc database (code vs size = weight) -- if so,
> >how could I make the basket look up the weight with multiple sizes
> >possible?
> >
> >2. Including extra fields in the pricing.asc database to designate
> >weights for sizes -- if so, how would I make it know a particularly
> >selected size was to be a corresponding weight, and similarly, how would
> >I make the basket know about this weight?
> >
> >It seems to always come down to the basket...  :)
> >
> >I would so very much appreciate any help someone might give me with this
> >frustration.
> >
> >Thanks,
>
> Mark - this no doubt sounds like one of those "kludgy" solutions, but if I
> was in your boat and I had to have it working soon, I would just create a
> unique product record for each permutation of each product (i.e., XXX-A,
> XXX-B, etc).  That would take care of the weight and price differences. I
> would then structure my HTML and flypages (if you are using them) to
> present the information to the user as cohesively as possible, which might
> mean alot of static HTML so that the unique item codes can be presented as
> size "options" for the "main" item.  It may sound like alot of work
> (actually, it is), but at least it is obvious and straight-foward :-)
>
> Good Luck!
>
> - Ed L.
>
> -
> PRINTEX Marking Technologies
> 12113 Kirkham Rd.
> Poway, CA  92064  U.S.A.
> (858) 513-2418
> (800) 982-1928
> (858) 513-2419 fax
> edlafrance@printexusa.com
> http://www.printexusa.com
>
> -
> 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: