[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: Weights change by size, and multiple sizes
Quoting Mark Rushing (rushing@orbislumen.net):
> ****** message to minivend-users from Mark Rushing <rushing@orbislumen.net> ******
>
> 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... :)
>
As it must. You didn't give any data examples, but I can guess...
UserTag compute_weight Order cart
UserTag compute_weight Routine <<EOR
sub {
my ($name) = @_;
my $cart;
if($name) {
$cart = $Vend::Session->{carts}{$name};
}
else {
$cart = $Vend::Items;
}
return 0 unless $cart;
my $weight;
foreach my $item (@$cart) {
my $item_weight = 0;
if ($item->{size}) {
$item_weight = Vend::Interpolate::tag_data(
'pricing',
"$item->{size}_weight",
$item->{code},
);
}
$item_weight = Vend::Interpolate::tag_data(
'products',
'weight',
$item->{code},
)
if ! $item_weight;
$weight += $item_weight;
}
return $weight;
}
EOR
Untested, but it should work (minivend.cfg).
--
Mike Heins http://www.minivend.com/ ___
Internet Robotics |_ _|____
131 Willow Lane, Floor 2 | || _ \
It's a little-known fact Oxford, OH 45056 | || |_) |
that the Y1K problem caused <mikeh@minivend.com> |___| _ <
the Dark Ages. -- unknown 513.523.7621 FAX 7501 |_| \_\