jQuery("#select-shipping").click(function(){
// Open the dialog, start with the "loading page"
$("#shipping-select").load('func/shipping_load.php').dialog({
bgiframe: true,
autoOpen: true,
position: 'center',
title: 'Select Shipping Method',
width: 400,
height: 400,
modal: true,
buttons: {
'Apply Shipping': function() {
var bValid = true;
if (bValid) {
var fship = $('input[name=shipping]:checked').val();
var arr = fship.split('-');
var shipPrice = arr[1];
var shipMeth = arr[0];
var subOrder = $("#d_total").val();
if ($('#customer-discount').val() != 'false') {
var minDis = subOrder * ("."+$("#customer-discount").val());
var nTotal = subOrder - minDis;
var orderTotal = nTotal + parseFloat(shipPrice) + parseFloat($("#tax").val()); /* Order Total minus customer discount */
$("#order_discount_amount").val("-"+minDis.toFixed(2));
}
else {
var orderTotal = parseFloat(subOrder) + parseFloat(shipPrice) + parseFloat($("#tax").val()); /* Order Total, No Discount */
}
$("#order_total").val(orderTotal.toFixed(2)),
$("#shipcost").val(parseFloat(shipPrice)),
$("#shipping_method").html(shipMeth);
$(this).dialog("destroy");
}
},
'Close Window': function() {
$(this).dialog("destroy");
}
},
close: function() {
$(this).dialog("destroy");
}
});
// This portion actually runs the PHP code to get the rate results from UPS & FedEx
$.ajax({
type: "POST",
url: "func/shipping_selection.php",
data: "shipid=" + $("#customer-ship-id").val() + "&cartid=" + $("#cart_id").val(),
success: function(html){
$('#sLoader').fadeOut("fast");
$("#sLookup").html(html);
}
});
}); |