[ic] MaxQuantityField, cart.pm modification;
to allow for stock at multiple locations
John1
list_subscriber at yahoo.co.uk
Mon May 3 13:36:49 EDT 2004
On Monday, April 19, 2004 1:57 AM, kevin at cursor.biz wrote:
> John1 [list_subscriber at yahoo.co.uk] wrote:
>> It would be good if the MaxQuantityField code in cart.pm could cope
>> with more than 1 quantity field in the inventory table.
>>
>> e.g. In a scenario where there are 3 warehouses:
>>
>> MaxQuantityFiled inventory::quantity1::quantity2::quantity3
>>
>> where quantity1, quantity2 and quantity3 are 3 separate fields in
>> table "inventory", recording stock levels at the 3 warehouse.
>>
>> For illustration, starting at line 223 of cart.pm, my code
>> modification to cope with 2 columns is:
>>
>> if($Vend::Cfg->{MaxQuantityField}) {
>> my ($tab, $col1, $col2) = split /:+/,
>> $Vend::Cfg->{MaxQuantityField}; if(! length $col1) { $col1 =
>> $tab; $tab = $item->{mv_ib} || $Vend::Cfg->{ProductFiles}[0];
>> } $item->{mv_max_quantity} = ::tag_data($tab, $col1,
>> $item->{code}) + ::tag_data($tab, $col2, $item->{code});
>>
> As you said, the above will extend the MaxQuantityField to allow two
> (and only two - not one or three etc.) quantity columns. You could
> possibly allow for any number as follows:
>
> if($Vend::Cfg->{MaxQuantityField}) {
> my ($tab, @cols) = split /:+/, $Vend::Cfg->{MaxQuantityField};
> my $max = 0;
>
> unless (scalar(@cols)) {
> push(@cols,$tab);
> $tab = $item->{mv_ib} || $Vend::Cfg->{ProductFiles}[0];
> }
> foreach (@cols) {
> next unless $_;
>
> $max += ::tag_data($tab, $_, $item->{code}) || 0;
> }
> $item->{mv_max_quantity} = $max if $max;
> ...
> }
>
> Just typed in - untested.
>
> If this was thought to be a generally useful feature then I'd prefer
> to see it not as "inventory::quantity1::quantity2::quantity3", but
> rather as "inventory::quantity1, inventory::quantity2,
> sometable::somecol",
> which would allow for multiple inventory tables and/or multiple
> columns
> in any table. That might look a little like this:
>
> if($Vend::Cfg->{MaxQuantityField}) {
> my $max = 0;
>
> foreach my $pair
> (split('[\s,]+',$Vend::Cfg->{MaxQuantityField})) { next
> unless $pair;
>
> my ($tab, $col) = split /:+/, $pair;
> if(! length $col) {
> $col = $tab;
> $tab = $item->{mv_ib} ||
> $Vend::Cfg->{ProductFiles}[0]; }
> $max += ::tag_data($tab, $col, $item->{code}) || 0;
> }
> $item->{mv_max_quantity} $max if $max;
> ...
> }
>
> Again, the above was just typed in - no testing was performed.
>
> A similar change would probably need to be made to the
> MinQuantityField code for consistency.
>
> If you would like to create, test and submit a patch then its
> inclusion in future releases will be considered.
>
Kevin - thanks for your great reply and code suggestion. Sorry for my delay
in responding.
Can you point me in the direction of a "Submitting a patch - How to"?
Do I need to install CVS? I don't expect that I will be submitting many
patches as my Perl isn't up to much, so if there is a way I can submit a
patch without installing CVS that would be great.
More information about the interchange-users
mailing list