[interchange] Allow gift certificates to be counted correctly as one item by [nitems] tag.
Peter Ajamian <[email protected]>
| Newsgroups | gmane.comp.web.interchange.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 069f95c4a1b7ce7ddcb309c79e71e1f2ed251d9f Author: Peter Ajamian <[email protected]> Date: Wed Apr 25 00:31:22 2012 +1200 Allow gift certificates to be counted correctly as one item by [nitems] 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] lib/Vend/Util.pm | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) --- diff --git a/lib/Vend/Util.pm b/lib/Vend/Util.pm index d92e776..ce76ad9 100644 --- a/lib/Vend/Util.pm +++ b/lib/Vend/Util.pm @@ -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;