diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt
index 3f832ab62..66e894837 100644
--- a/docs/changelog/6.x.x.txt
+++ b/docs/changelog/6.x.x.txt
@@ -18,7 +18,8 @@
- fix: No Help link icon in Matrix edit page
- fix: Problems with In/Out Board (labeling only)
- fix: Adding HTTP Proxy
-
+ - fix: EMS Discount Pass Not Applied
+ - fix: Commerce checkout confirmation very confusing
6.99.3
- Someone removed the status from the submission templates. That has been
diff --git a/docs/upgrades/templates-6.99.4/commerce_checkout_confirmation.tmpl b/docs/upgrades/templates-6.99.4/commerce_checkout_confirmation.tmpl
new file mode 100644
index 000000000..6b339c7e4
--- /dev/null
+++ b/docs/upgrades/templates-6.99.4/commerce_checkout_confirmation.tmpl
@@ -0,0 +1,66 @@
+#PBtmpl0000000000000016
+
+ ·
+ ·
+
+
+
+
+
+
+
+ | Product |
+ Quantity |
+ Price |
+ Amount |
+ Each |
+
+
+
+
+
+
+
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+
+ |
+ |
+ |
+ |
+ |
+
+
+
+ | |
+ Subtotal |
+ |
+
+
+ | Shipping |
+ |
+
+
+ |
+ |
+
+
+ | Total |
+ |
+
+
+
+
+
+
diff --git a/lib/WebGUI/Commerce/Item/Event.pm b/lib/WebGUI/Commerce/Item/Event.pm
index d534e0757..5a8c79c5f 100644
--- a/lib/WebGUI/Commerce/Item/Event.pm
+++ b/lib/WebGUI/Commerce/Item/Event.pm
@@ -140,7 +140,7 @@ sub priceLineItem {
);
}
if ($numberOfPasses) {
- # $self->session->errorHandler->warn('adding a discount pass.');
+ #$self->session->errorHandler->warn('adding a discount pass.');
$passesInCart{$passId} = $numberOfPasses;
$totalPassesInCart += $numberOfPasses;
}
@@ -151,7 +151,7 @@ sub priceLineItem {
my $numberOfThisPass = $passesInCart{$passId};
# calculate discount.
if ($pass->{type} eq 'newPrice') {
- $self->session->errorHandler->warn('discounted price: '.$pass->{amount});
+ #$self->session->errorHandler->warn('discounted price: '.$pass->{amount});
$discountedPrice = (0 + $pass->{amount}) if ($price > (0 + $pass->{amount}));
} elsif ($pass->{type} eq 'amountOff') {
# not yet implemented!
@@ -160,14 +160,15 @@ sub priceLineItem {
}
# while we still have passes and items left to discount.
while ($numberOfThisPass && $quantity) {
- # $self->session->errorHandler->warn('applying a discount pass.');
+ #$self->session->errorHandler->warn('applying a discount pass.');
$totalPrice += $discountedPrice;
- $self->session->errorHandler->warn('new discounted price: '.$discountedPrice);
+ #$self->session->errorHandler->warn('new discounted price: '.$discountedPrice);
$quantity--;
$numberOfThisPass--;
}
}
# return the total of the discounted items plus the total of the non discounted items.
+ #$self->session->errorHandler->warn($totalPrice + ($quantity * $price));
return ($totalPrice + ($quantity * $price));
}
diff --git a/lib/WebGUI/Commerce/Transaction.pm b/lib/WebGUI/Commerce/Transaction.pm
index dd1bc12b6..c4931d27e 100644
--- a/lib/WebGUI/Commerce/Transaction.pm
+++ b/lib/WebGUI/Commerce/Transaction.pm
@@ -45,17 +45,17 @@ sub addItem {
$self->session->db->write("insert into transactionItem ".
"(transactionId, itemName, amount, quantity, itemId, itemType) values ".
"(".$self->session->db->quote($self->{_transactionId}).",".$self->session->db->quote($item->name).",".$self->session->db->quote(
- ($lineItemAmount)
+ ($lineItemAmount ne "")
?($lineItemAmount)
:($item->price)
).",".$self->session->db->quote(
- ($lineItemAmount)
+ ($lineItemAmount ne "")
?('1')
:($quantity)
).",".
$self->session->db->quote($item->id).",".$self->session->db->quote($item->type).")");
# Adjust total amount in the transaction table.
- $self->session->db->write("update transaction set amount=amount+".($item->price * $quantity)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
+ $self->session->db->write("update transaction set amount=amount+".$self->session->db->quote(($lineItemAmount ne "") ? ($lineItemAmount) : ($item->price * $quantity))." where transactionId=".$self->session->db->quote($self->{_transactionId}));
$self->{_properties}{amount} += ($item->price * $quantity);
push @{$self->{_items}}, {
transactionId => $self->{_transactionId},
diff --git a/lib/WebGUI/Operation/Commerce.pm b/lib/WebGUI/Operation/Commerce.pm
index a50e75d5c..3b7ca730c 100644
--- a/lib/WebGUI/Operation/Commerce.pm
+++ b/lib/WebGUI/Operation/Commerce.pm
@@ -236,7 +236,7 @@ If the user continues, the next sub called is www_checkoutSubmit.
sub www_checkoutConfirm {
my $session = shift;
- my ($plugin, $f, %var, $errors, $i18n, $shoppingCart, $normal, $recurring, $shipping, $total);
+ my ($plugin, $f, %var, $errors, $i18n, $shoppingCart, $normal, $recurring, $shipping, $total, $subTotal);
$errors = shift;
$i18n = WebGUI::International->new($session, 'Commerce');
@@ -255,15 +255,22 @@ sub www_checkoutConfirm {
# Put contents of cart in template vars
$shoppingCart = WebGUI::Commerce::ShoppingCart->new($session);
($normal, $recurring) = $shoppingCart->getItems;
-
+ my @copyOfNormal = @$normal;
foreach (@$normal) {
+ my $amount;
$_->{deleteIcon} = $session->icon->delete('op=deleteCartItem;itemId='.$_->{item}->id.';itemType='.$_->{item}->type);
$_->{'quantity.form'} = WebGUI::Form::integer($session,{
name => 'quantity~'.$_->{item}->type.'~'.$_->{item}->id,
value => $_->{quantity},
size => 3,
});
- $total += $_->{totalPrice};
+ my $priceLineItem = ($_->{item}->{priceLineItem}) ? ($_->{item}->priceLineItem($_->{quantity},\@copyOfNormal)) : undef; # pass in the quantity and the normal items in the cart.
+ # use the item plugin's lineItem method for price override
+ # situations.
+ $amount = ($priceLineItem ne "") ? ($priceLineItem) : ($_->{totalPrice});
+ $_->{item}->{price} = $amount;
+ $total += $amount; # tracks discount
+ $subTotal += $_->{totalPrice}; # ignores discount (we need this to show them an accurate subtotal and to calculate the discount given.)
}
foreach (@$recurring) {
$_->{deleteIcon} = $session->icon->delete('op=deleteCartItem;itemId='.$_->{item}->id.';itemType='.$_->{item}->type);
@@ -274,13 +281,13 @@ sub www_checkoutConfirm {
});
$total += $_->{totalPrice};
}
-
+
$var{normalItemsLoop} = $normal;
$var{normalItems} = scalar(@$normal);
$var{recurringItemsLoop} = $recurring;
$var{recurringItems} = scalar(@$recurring);
- $var{subTotal} = sprintf('%.2f', $total);
+ $var{subTotal} = sprintf('%.2f', $subTotal);
$shipping = WebGUI::Commerce::Shipping->load($session, $session->scratch->get('shippingMethod'));
$shipping->setOptions(Storable::thaw($session->scratch->get('shippingOptions'))) if ($session->scratch->get('shippingOptions'));
@@ -289,6 +296,8 @@ sub www_checkoutConfirm {
$var{total} = sprintf('%.2f', $total + $shipping->calc);
+ $var{discountsApplied} = sprintf('%.2f', $total - $subTotal - $shipping->calc);
+ $var{'discountsApplied.label'} = $i18n->echo("Discount Applied");
$plugin = WebGUI::Commerce::Payment->load($session, $session->scratch->get('paymentGateway'));
$f = WebGUI::HTMLForm->new($session);
@@ -388,14 +397,12 @@ sub www_checkoutSubmit {
$transaction = WebGUI::Commerce::Transaction->new($session, 'new');
foreach (@{$currentPurchase->{items}}) {
- my $priceLineItem = ($_->{item}->{priceLineItem})
- # pass in the quantity and the normal items in the cart.
- ?($_->{item}->priceLineItem($_->{quantity},\@copyOfNormal))
- :undef;
+ my $priceLineItem = ($_->{item}->{priceLineItem}) ? ($_->{item}->priceLineItem($_->{quantity},\@copyOfNormal)) : undef; # pass in the quantity and the normal items in the cart.
+ $session->errorHandler->warn("Price Line Item: $priceLineItem");
$transaction->addItem($_->{item}, $_->{quantity},$priceLineItem);
# use the item plugin's lineItem method for price override
# situations.
- $amount += ($priceLineItem)
+ $amount += ($priceLineItem ne "")
?($priceLineItem)
:($_->{item}->price * $_->{quantity});
$var->{purchaseDescription} .= $_->{quantity}.' x '.$_->{item}->name.'
';