[ic] Extension to MaxQuantityField functionality
Davor Ocelic
docelic at spinlocksolutions.com
Tue Jun 24 17:09:28 UTC 2008
Hey folks,
As you might know, MaxQuantityField allows multiple fields to be
specified, such as
MaxQuantityField f1 f2
and then the max allowed quantity is the sum of values in f1 and f2.
Included is a patch that extends the syntax supported in
MaxQuantityField by allowing fields to have "=" or "?" prefix.
- Default behavior is unchanged.
- Specification of "=f2" would override any previous max quantity
amount with value f2
- Specification of "?f2" would override any previous value only if
f2 > 0.
Throw in your comments before I commit it.
diff -ruNP cvs-head/lib/Vend/Cart.pm cvs-head,gc/lib/Vend/Cart.pm
--- cvs-head/lib/Vend/Cart.pm 2008-03-25 18:13:21.000000000 +0100
+++ cvs-head,gc/lib/Vend/Cart.pm 2008-04-30 22:40:01.000000000 +0200
@@ -258,11 +258,26 @@
$col = $tab;
$tab = $item->{mv_ib} || $Vend::Cfg->{ProductFiles}[0];
}
- $item->{mv_max_quantity} +=
$quantity_cache{"$tab.$col.$item->{code}"} ||
($quantity_cache{"$tab.$col.$item->{code}"} = ::tag_data($tab, $col,
$item->{code}));
+ if ( $tab =~ s/^=// ) {
+ $item->{mv_max_quantity} =
$quantity_cache{"$tab.$col.$item->{code}"} = ::tag_data($tab, $col,
$item->{code});
+ goto DONE_QUANTITY_ADJUST;
+ }
+ elsif ( $tab =~ s/^\?// ) {
+ if ( $item->{mv_max_quantity} ) {
+ $item->{mv_max_quantity} =
$quantity_cache{"$tab.$col.$item->{code}"} = ::tag_data($tab, $col,
$item->{code}) if
+ ::tag_data($tab, $col, $item->{code});
+ goto DONE_QUANTITY_ADJUST;
+ }
+ }
+ else {
+ $item->{mv_max_quantity} +=
$quantity_cache{"$tab.$col.$item->{code}"} ||
($quantity_cache{"$tab.$col.$item->{code}"} = ::tag_data($tab, $col,
$item->{code}));
+ }
}
$item->{mv_max_quantity} -= $total_quantity{$item->{code}};
$item->{mv_max_quantity} = 0 if $item->{mv_max_quantity} < 0;
+ DONE_QUANTITY_ADJUST:
+
if(
length $item->{mv_max_quantity}
and
More information about the interchange-users
mailing list