Commit a3fa74a4 authored by Malcolm Blaney's avatar Malcolm Blaney

Itemise purchases in a table for order confirmation.

parent c8c6308b
Pipeline #4603420 failed with stage
in 1 minute and 16 seconds
......@@ -354,9 +354,9 @@ class Cart extends Base {
'!state<br>!country<br>"',
'"cart-display-item","","<h2>!name</h2><img src="!image">'.
'!description',
'"cart-email","","To !first !last<br>Thank you for your '.
'order!The following is a confirmation of your purchases '.
'and contact details:<br><br>Items: !items<br><b>Total: '.
'"cart-email","","To !first !last<br>Thanks for your order! '.
'The following is a confirmation of your purchases and '.
'contact details:<br><br>!items<br><b>Total: '.
'$!amount</b><br><br>Email: !email<br>Address:<br>!address'.
'<br>!city<br>!postcode<br>!state<br>!country<br><br>"'];
$this->AddTemplate($template);
......@@ -374,6 +374,7 @@ class Cart extends Base {
'"","#customer-detail-submit","margin-left","7.3em"',
'"","#customer-detail-submit","margin-top","1em"',
'"","#cart-total-table","margin","10px"',
'"","#cart-total-table tr:last-child","font-weight","bold"',
'"","#cart-item-form","background-color","#eeeeee"',
'"","#cart-item-form","border","1px solid #aaaaaa"',
'"","#cart-item-form","border-radius","2px"',
......@@ -532,7 +533,9 @@ class Cart extends Base {
// Look for shipping rules that match the given locations.
$rules = $this->ShippingRules($city, $state, $country);
$item_names = '';
// Paypal does not allow a detailed item description.
$item_names = $method === 'paypal' ? 'Items: ' :
'<table><th>Item Name</th><th>Quantity</th><th>Price</th>';
$total_price = 0;
$total_weight = 0;
$order_verified = true;
......@@ -553,14 +556,23 @@ class Cart extends Base {
$order_verified = false;
break;
}
if ($item_names !== '') $item_names .= ', ';
$item_names .= $item;
if ($quantity > 1) {
$item_names .= ' ('.$quantity.')';
if ($method === 'paypal') {
if ($item_names !== '') $item_names .= ', ';
$item_names .= $item;
if ($quantity > 1) {
$item_names .= ' ('.$quantity.')';
}
}
else {
$item_names .= '<tr>'.$item.'</tr><tr>'.$quantity.'</tr><tr>'.$price.
'</tr>';
}
$total_price += $price * $quantity;
$total_weight += $weight * $quantity;
}
if ($method !== 'paypal') {
$item_names .= '</table>';
}
if ($first === '' || $last === '' || $email === '' || $address === '') {
$order_verified = false;
}
......
......@@ -59,11 +59,11 @@ function cartMiniTotal(){var total=0;$.each(cart,function(name,item){if(item.sel
function fixMiniTotal(){var currentScroll=$(this).scrollTop();if(previousScroll<=100&&currentScroll>100){$(".cart-total").parent().parent().addClass("fixed-wrapper-style");$(".cart-total").parent().addClass("fixed-style");}
else if(previousScroll>100&&currentScroll<=100){$(".cart-total").parent().parent().removeClass("fixed-wrapper-style");$(".cart-total").parent().removeClass("fixed-style");}
previousScroll=currentScroll;}
function cartTotal(shipping,processing){var total=0;var quantity=0;var table='<table class="cart-total-table">';$.each(cart,function(name,item){if(item.selected&&item.price!==0){total+=item.price*item.quantity;quantity+=item.quantity;table+='<tr><td>'+name+'</td><td>'+item.quantity+'</td><td>$'+(item.price*item.quantity).toFixed(2)+'</td></tr>';}});$(".cart-total .number").html("$"+total.toFixed(2));if(shipping){total+=shipping;table+='<tr><td>Shipping Cost</td><td></td><td>$'+
function cartTotal(shipping,processing){var total=0;var quantity=0;var table='<table id="cart-total-table">';$.each(cart,function(name,item){if(item.selected&&item.price!==0){total+=item.price*item.quantity;quantity+=item.quantity;table+='<tr><td>'+name+'</td><td>'+item.quantity+'</td><td>$'+(item.price*item.quantity).toFixed(2)+'</td></tr>';}});$(".cart-total .number").html("$"+total.toFixed(2));if(shipping){total+=shipping;table+='<tr><td>Shipping Cost</td><td></td><td>$'+
shipping.toFixed(2)+'</td></tr>';}
if(processing){total+=processing;table+='<tr><td>Processing Fee</td><td></td><td>$'+
processing.toFixed(2)+'</td></tr>';}
table+='<tr><td><b>Total</b></td><td>'+quantity+'</td><td>$'+
table+='<tr><td>Total</td><td>'+quantity+'</td><td>$'+
total.toFixed(2)+'</td></tr></table>';if(total===0){table="";$("#cart-checkout").button("option","disabled",true);}
else{$("#cart-checkout").button("option","disabled",false);}
return table;}
......
......@@ -308,7 +308,7 @@ if (!this.dobrado.cart) {
function cartTotal(shipping, processing) {
var total = 0;
var quantity = 0;
var table = '<table class="cart-total-table">';
var table = '<table id="cart-total-table">';
$.each(cart, function(name, item) {
if (item.selected && item.price !== 0) {
total += item.price * item.quantity;
......@@ -329,7 +329,7 @@ if (!this.dobrado.cart) {
table += '<tr><td>Processing Fee</td><td></td><td>$' +
processing.toFixed(2) + '</td></tr>';
}
table += '<tr><td><b>Total</b></td><td>' + quantity + '</td><td>$' +
table += '<tr><td>Total</td><td>' + quantity + '</td><td>$' +
total.toFixed(2) + '</td></tr></table>';
if (total === 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment