Commit 17d6e4bb authored by Malcolm Blaney's avatar Malcolm Blaney

Fixed a few cart bugs and formatting issues. Also try to avoid a

few flashes of unstyled content.
parent e96e5249
Pipeline #5193352 passed with stage
in 1 minute and 58 seconds
......@@ -547,9 +547,11 @@ class Cart extends Base {
// the shopping cart name can be different from the stock item. (Maybe
// even allow stock deduction of $weight against a bulk item?
foreach ($us_cart as $us_item => $us_values) {
$quantity = (float)$us_values['quantity'];
if ($quantity < 0.01) continue;
$item = $mysqli->escape_string($us_item);
$price = (float)$us_values['price'];
$quantity = (float)$us_values['quantity'];
list($verified, $weight) = $this->VerifyItem($item, $price);
if (!$verified) {
$order_verified = false;
......@@ -564,7 +566,7 @@ class Cart extends Base {
}
else {
$item_names .= '<tr><td>'.$item.'</td><td>'.$quantity.'</td>'.
'<td>$'.number_format($price, 2, '.', '').'</td></tr>';
'<td>$'.number_format($price * $quantity, 2, '.', '').'</td></tr>';
}
$total_price += $price * $quantity;
$total_weight += $weight * $quantity;
......
......@@ -28,7 +28,7 @@ if(!this.dobrado.cart){dobrado.cart={};}
(function(){'use strict';var cart={};var settings=null;var editor=null;var itemIndex=0;var shippingIndex=0;var browserTarget="";var previousScroll=0;$(function(){if(dobrado.localStorage()){if(localStorage.cart){cart=JSON.parse(localStorage.cart);cartMiniTotal();}}
if($(".cart").length===0){return;}
checkDownloads();$(".cart-item .item-add").button().click(cartAdd);$(".cart-item .item-quantity").val("0");$(".cart-item .item-quantity").spinner({min:0,spin:cartQuantity,change:cartQuantity});$("#cart-checkout").button({disabled:true}).click(checkout);$("#anchor-cart-checkout-link").click(checkout);$("#cart-tabs").tabs();$("#cart-confirm-button").button().click(confirmPurchase);$("#cart-continue-button").button().click(function(){$("#cart-checkout-dialog").dialog("close");});$("#customer-detail-method").change(toggleCustomInput);if($("#customer-detail-method").val()==="pickup"){$("#customer-detail-description").parent().show();}
$("#customer-detail-submit").button().click(customerDetail);$(".cart-item .item-name a").click(cartItem);$(".cart-item a .item-image").click(cartItem);$(window).scroll(fixMiniTotal);fixMiniTotal();if($(".cart-payment-message").html()!==""){$(".cart-payment-message button").button().click(paymentDone);$(".cart-payment-message").dialog({modal:true,position:{my:"top",at:"top+50",of:window},title:"Payment",width:450,height:200,close:paymentDone,create:dobrado.fixedDialog});}
$("#customer-detail-submit").button().click(customerDetail);$(".cart-item .item-name a").click(cartItem);$(".cart-item a .item-image").click(cartItem);$(window).scroll(fixMiniTotal);fixMiniTotal();$(".cart").show();if($(".cart-payment-message").html()!==""){$(".cart-payment-message button").button().click(paymentDone);$(".cart-payment-message").dialog({modal:true,position:{my:"top",at:"top+50",of:window},title:"Payment",width:450,height:200,close:paymentDone,create:dobrado.fixedDialog});}
$("#cart-checkout-dialog").dialog({autoOpen:false,modal:true,position:{my:"top",at:"top+50",of:window},title:"Checkout",width:550,height:500,create:dobrado.fixedDialog});$("#cart-editor").dialog({autoOpen:false,close:close,position:{my:"top",at:"top+50",of:window},title:"Cart Editor",width:760,height:500,create:dobrado.fixedDialog});$("#cart-item-dialog").dialog({autoOpen:false,position:{my:"top",at:"top+50",of:window},title:"Cart Item",width:700,height:500,create:dobrado.fixedDialog});$("#cart-edit-button").button({icons:{primary:"ui-icon-pencil"},text:false}).click(cartEditor);cartTotal();$.each(cart,function(name,item){var id=item.id;if(id){var cssName=id.match(/^cart-item-id-(.+)$/);if(item.selected&&cssName&&cssName.length===2){$("#"+id+" .item-add").button({label:"Remove from cart"});$("#item-quantity-"+cssName[1]).spinner("value",item.quantity);}}});});function checkDownloads(){$(".cart-download-list li").each(function(i){var file=$(this).html();setTimeout(function(){location.href="/php/download.php?file="+file;},i*10000);});}
function cartPrice(item){var price=0;var checkMinimum=false;if(item.attr("id")){price=item.val();checkMinimum=true;}
else{price=item.html();}
......
......@@ -82,6 +82,8 @@ if (!this.dobrado.cart) {
$(window).scroll(fixMiniTotal);
// Also call fixMiniTotal in case the window is already scrolled.
fixMiniTotal();
// Once everything is set, show the cart in case it's hidden in css.
$(".cart").show();
if ($(".cart-payment-message").html() !== "") {
$(".cart-payment-message button").button().click(paymentDone);
......
......@@ -25,7 +25,7 @@
// for the JavaScript code in this page.
if(!this.dobrado){var dobrado={};}
(function(){'use strict';dobrado.current="";dobrado.timer=2000;dobrado.dynamicPolling=true;var ignoreResponse=false;$(function(){dobrado.token=$(".dobrado-token").attr("id");$(".horizontal-menu").show().menu({position:{my:"left top",at:"left bottom"}});if($("indie-action").length!==0&&$(".reader").length===0){dobrado.indieConfig();}});dobrado.indieConfig=function(){var iframe=null;var indieConfigInfo='';function currentSettings(config){if($("#indie-config-dialog").length===0){var text='<div>Your currently stored settings:'+'<p class="indie-config-settings">';if(config.follow){text+="<b>follow</b>: "+config.follow.split("&follow")[0]+"<br>";}
(function(){'use strict';dobrado.current="";dobrado.timer=2000;dobrado.dynamicPolling=true;var ignoreResponse=false;$(function(){dobrado.token=$(".dobrado-token").attr("id");$(".horizontal-menu").menu({position:{my:"left top",at:"left bottom"}});$(".horizontal-menu").show();if($("indie-action").length!==0&&$(".reader").length===0){dobrado.indieConfig();}});dobrado.indieConfig=function(){var iframe=null;var indieConfigInfo='';function currentSettings(config){if($("#indie-config-dialog").length===0){var text='<div>Your currently stored settings:'+'<p class="indie-config-settings">';if(config.follow){text+="<b>follow</b>: "+config.follow.split("&follow")[0]+"<br>";}
if(config.like){text+="<b>like</b>: "+config.like.split("&like")[0]+"<br>";}
if(config.post){text+="<b>post</b>: "+config.post.split("&post")[0]+"<br>";}
if(config.repost){text+="<b>repost</b>: "+config.repost.split("&repost")[0]+"<br>";}
......
......@@ -43,8 +43,9 @@ if (!this.dobrado) {
// A security token is sent with each request to the server.
dobrado.token = $(".dobrado-token").attr("id");
// Initialise any menus using the "horizontal-menu" class.
$(".horizontal-menu").show().menu({ position: { my: "left top",
at: "left bottom" } });
$(".horizontal-menu").menu({ position: { my: "left top",
at: "left bottom" } });
$(".horizontal-menu").show();
// If there are any indie-action tags on the page they are converted to
// normal links using stored indie-config settings.
// (The reader module calls indieConfig once the feed has loaded.)
......
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