Skip to content
This repository
Browse code

ENHANCEMENT: Tidy up of javascript esp. on checkout page.

ENHANCEMENT: Adding -js to product page css selector used in javascript.

ENHANCEMENT: Reduce number AJAX calls on checkout page, js tidy up.
  • Loading branch information...
commit 4e44433d3d50687abde34fae074c7ef96295dac3 1 parent bf5a608
Frank Mullenger authored
2  css/Shop.css
@@ -1393,7 +1393,7 @@
1393 1393
   float: left;
1394 1394
   padding: 0 5px;
1395 1395
 }
1396  
-.product .product-meta .product-price {
  1396
+.product .product-meta .product-price-js {
1397 1397
   font-size: 22px;
1398 1398
   font-weight: normal;
1399 1399
 }
2  css/less/Shop.less
@@ -240,7 +240,7 @@
240 240
      float: left;
241 241
      padding: 0 5px;
242 242
      
243  
-     .product-price {
  243
+     .product-price-js {
244 244
        font-size: 22px;
245 245
        font-weight: normal;
246 246
      }
21  javascript/CheckoutPage.js
@@ -2,6 +2,27 @@
2 2
     $(document).ready(function() { 
3 3
 
4 4
     	/**
  5
+    	 * Update the order form cart via AJAX, used by modifier fields
  6
+    	 * 
  7
+    	 * TODO need to namespace this properly
  8
+    	 */
  9
+    	window.updateOrderFormCartAJAX = function(event) {
  10
+
  11
+    		//AJAX call to update the cart
  12
+    		var values = $('#CheckoutForm_OrderForm').serialize();
  13
+    		
  14
+    		$.ajax({
  15
+			  url: window.location.pathname + '/updateOrderFormCart',
  16
+			  type: 'POST',
  17
+			  data: values,
  18
+			  success: function(data){
  19
+			    $('#checkout-order-table').replaceWith(data);
  20
+			  }
  21
+			});
  22
+    	}
  23
+    	updateOrderFormCartAJAX();
  24
+
  25
+    	/**
5 26
     	 * Shipping same address checkbox, copy across billing address and save current
6 27
     	 * shipping address to revert to
7 28
     	 */
21  javascript/FlatFeeShippingField.js
... ...
@@ -1,25 +1,6 @@
1 1
 (function($) { 
2 2
     $(document).ready(function() { 
3  
-
4  
-    	/**
5  
-    	 * Update the order form cart via AJAX
6  
-    	 */
7  
-    	function updateOrderFormCartAJAX() {
8  
-
9  
-    		//AJAX call to update the cart
10  
-    		var values = $('#CheckoutForm_OrderForm').serialize();
11  
-
12  
-    		$.ajax({
13  
-			  url: window.location.pathname + '/updateOrderFormCart',
14  
-			  type: 'POST',
15  
-			  data: values,
16  
-			  success: function(data){
17  
-			    $('#checkout-order-table').replaceWith(data);
18  
-			  }
19  
-			});
20  
-    	}
21  
-    	$('#CheckoutForm_OrderForm_Shipping-Country').live('change', updateOrderFormCartAJAX).change();
  3
+    	$('#CheckoutForm_OrderForm_Shipping-Country').live('change', updateOrderFormCartAJAX);
22 4
     	$('.modifier-set-field select').live('change', updateOrderFormCartAJAX);
23  
-    	updateOrderFormCartAJAX(); //This ruins the modifier field being set to the correct value for some reason
24 5
     })
25 6
 })(jQuery);
22  javascript/FlatFeeTaxField.js
... ...
@@ -1,26 +1,6 @@
1 1
 (function($) { 
2 2
     $(document).ready(function() { 
3  
-
4  
-    	/**
5  
-    	 * Update the order form cart via AJAX
6  
-    	 */
7  
-    	function updateOrderFormCartAJAX() {
8  
-
9  
-    		//AJAX call to update the cart
10  
-    		var values = $('#CheckoutForm_OrderForm').serialize();
11  
-    		
12  
-    		$.ajax({
13  
-			  url: window.location.pathname + '/updateOrderFormCart',
14  
-			  type: 'POST',
15  
-			  data: values,
16  
-			  success: function(data){
17  
-			    $('#checkout-order-table').replaceWith(data);
18  
-			  }
19  
-			});
20  
-    	}
21  
-    	$('#CheckoutForm_OrderForm_Shipping-Country').live('change', updateOrderFormCartAJAX).change();
  3
+    	$('#CheckoutForm_OrderForm_Shipping-Country').live('change', updateOrderFormCartAJAX);
22 4
     	$('.modifier-set-field select').live('change', updateOrderFormCartAJAX);
23  
-    	updateOrderFormCartAJAX(); //This ruins the modifier field being set to the correct value for some reason
24  
-
25 5
     })
26 6
 })(jQuery);
14  javascript/OptionGroupField.js
@@ -32,7 +32,6 @@
32 32
 	    			
33 33
 	    			var attributeID = e.currentTarget.id.replace(/AddToCartForm_AddToCartForm_Options-/i, '');
34 34
 	    			var optionID = e.currentTarget.value;
35  
-
36 35
 	    			
37 36
 	    			//If the next select exists, then call the AJAX to update it
38 37
 	    			if ($('#'+nextID).length) {
@@ -80,18 +79,9 @@
80 79
 				  success: function(data) {
81 80
 					  
82 81
 					dataObj = $.parseJSON(data);
83  
-					
84  
-					/*
85  
-					if (dataObj.priceDifference && $('#VariationPrice').length) {
86  
-						$('#VariationPrice').html(dataObj.priceDifference);
87  
-					}
88  
-					else if ($('#VariationPrice').length) {
89  
-						$('#VariationPrice').html('');
90  
-					}
91  
-					*/
92 82
 
93  
-					if (dataObj.totalPrice) { //&& $('.variation-prcie').length) {
94  
-						$('.product-price').html(dataObj.totalPrice);
  83
+					if (dataObj.totalPrice) { 
  84
+						$('.product-price-js').html(dataObj.totalPrice);
95 85
 					}
96 86
 				  }
97 87
 				});
1  javascript/RegionField.js
... ...
@@ -1,4 +1,3 @@
1  
-
2 1
 (function($) { 
3 2
 
4 3
 	//TODO need to namespace this properly
2  templates/Layout/Product.ss
@@ -8,7 +8,7 @@
8 8
 
9 9
   <div class="product-meta">
10 10
 	  <h1>$Product.Title</h1>
11  
-	  <h3 class="product-price">$Product.Amount.Nice</h3>
  11
+	  <h3 class="product-price-js">$Product.Amount.Nice</h3>
12 12
 	
13 13
 	  <div class="add-to-cart">
14 14
 	    $AddToCartForm(1)

0 notes on commit 4e44433

Please sign in to comment.
Something went wrong with that request. Please try again.