Permalink
Browse files

Allow gift certificates to be counted correctly as one item by [nitem…

…s] tag.

Currently gift certificates will be counted as several items by [nitems] due to
the quantity being the amount.  This change allows [nitems] to count a gift
certificate line as a single item provided:

* The gift_cert field (or equivalent) is added to the AutoModifier line in
  catalog.cfg, and...

* The name of the gift_cert field is passed to the [nitems] tag in the
  gift_cert attribute, typically as [nitems gift_cert=gift_cert]
  • Loading branch information...
pajamian committed Apr 24, 2012
1 parent eb29fbf commit 069f95c4a1b7ce7ddcb309c79e71e1f2ed251d9f
Showing with 6 additions and 0 deletions.
  1. +6 −0 lib/Vend/Util.pm
View
@@ -1460,6 +1460,12 @@ sub tag_nitems {
$total = 0;
foreach $item (@$cart) {
next if $attr and ! $sub->($item->{$attr});
+
+ if ($opt->{gift_cert} && $item->{$opt->{gift_cert}}) {
+ $total++;
+ next;
+ }
+
$total += $item->{'quantity'};
}
$total;

0 comments on commit 069f95c

Please sign in to comment.