Subversion Repositories SmartDukaan

Rev

Rev 2741 | Rev 2759 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2741 Rev 2755
Line 46... Line 46...
46
		}});
46
		}});
47
	});
47
	});
48
	
48
	
49
});
49
});
50
 
50
 
-
 
51
 
-
 
52
 
-
 
53
function addToCart(refdivid,reqtype){
-
 
54
     var seldata="";
-
 
55
     var tot=0;
-
 
56
     var saprt="";
-
 
57
     if(reqtype == "multi"){
-
 
58
          var containerdiv = "#" + refdivid;
-
 
59
          var par= containerdiv + " input[type=checkbox]:checked";
-
 
60
          var isMulti = false;
-
 
61
          $(par).each(function(){
-
 
62
        	  
-
 
63
	       	   var totalcolors = $(this).attr('totalcolors');
-
 
64
	           saprt = (tot>0)? "_":"";
-
 
65
               seldata += saprt+$(this).attr('itemid');
-
 
66
 
-
 
67
	           if(totalcolors != 1)	{
-
 
68
	        	   isMulti = true;
-
 
69
	       	   }
-
 
70
               tot++;
-
 
71
          });
-
 
72
          if(isMulti == true){
-
 
73
        	  alert("Some items are available in multiple colors. Please go to product page and select color you want.");
-
 
74
        	  return;
-
 
75
          } else	{
-
 
76
        	  var items = seldata.split('_');
-
 
77
        	  for(var i in items)	{
-
 
78
        		  trackEventWithGA('Order', 'Add to Cart', items[i]);
-
 
79
        	  }
-
 
80
          }
-
 
81
     }else if(reqtype == "single"){
-
 
82
          seldata = $("#item_id").val();
-
 
83
		  trackEventWithGA('Order', 'Add to Cart', seldata + '');
-
 
84
          tot=1;
-
 
85
     }else if(reqtype == "list"){
-
 
86
    	  var seldata=refdivid;
-
 
87
		  trackEventWithGA('Order', 'Add to Cart', seldata + '');
-
 
88
          tot=1;
-
 
89
     }
-
 
90
 
-
 
91
     if(tot > 0)	{
-
 
92
    	 jQuery.ajax({
-
 
93
    		 type: "POST",
-
 
94
    		 url: "/addtocart",
-
 
95
    		 data: "productid=" + seldata,
-
 
96
    		 success: function(msg){
-
 
97
    			 if(msg==""){
-
 
98
    				 window.location = "/cart";
-
 
99
    			 }else{
-
 
100
    				 displayRelatedProducts(msg);
-
 
101
    			 }
-
 
102
    		 }
-
 
103
    	 });
-
 
104
     } else	{
-
 
105
    	 alert("Please select atleast one product");
-
 
106
     }
-
 
107
}
-
 
108
 
-
 
109
 
51
function selectColor(){
110
function selectColor(){
52
	var selected = $(".colorSelLightBoxColor .content input[name='radColorSel']:checked");
111
	var selected = $(".colorSelLightBoxColor .content input[name='radColorSel']:checked");
53
	var itemid = selected.val();
112
	var itemid = selected.val();
54
 
113
 
55
	trackEventWithGA('Order', 'Select Product Color', itemid);
114
	trackEventWithGA('Order', 'Select Product Color', itemid);
56
	
115
	
57
	if(itemid == undefined)	{
116
	if(itemid == undefined)	{
58
		alert('Please select a color.');
117
		alert('Please select a color.');
59
	} else	{
118
	} else	{
60
		addToCart(itemid,'list');
119
		addToCart(itemid,'list');
61
		$.colorbox.close();
-
 
62
	}
120
	}
63
}
121
}
64
 
122
 
65
 
123
 
-
 
124
function displayRelatedProducts(message){
-
 
125
	var radBtn = "<div id='cartRecommendationBox'>";
-
 
126
	jQuery.ajax({
-
 
127
		type: "GET",
-
 
128
		url: "/related-products/" + $("#product_id").val(),
-
 
129
		data: "productid=" + $("#product_id").val(),
-
 
130
		success: function(msg)	{
-
 
131
			radBtn += "<h3 style='margin-top:5px; margin-bottom:5px;'>" + message + "</h3>";
-
 
132
			if($.trim(msg)!=""){
-
 
133
				radBtn += "<span style='font-size:14px; color:#003300; background-color:#ffffdd;  margin-bottom:8px;'>You can check out following similar products</span><hr size=1/>";
-
 
134
			}
-
 
135
			radBtn += msg;
-
 
136
			radBtn += '<div class="clearBoth"></div></div>';
-
 
137
			
-
 
138
	    	$.colorbox({
-
 
139
	    		html:radBtn,
-
 
140
	    		width:"400px",
-
 
141
	    		height:"410px",
-
 
142
	    		
-
 
143
	    		onComplete: function(){
-
 
144
	    			$('#cartRecommendationBox').show().find('.widgetChkBox').hide();
-
 
145
	    		},
-
 
146
	    		onCleanup: function(){
-
 
147
	    			$('#cartRecommendationBox').hide();
-
 
148
	    		}
-
 
149
	    	});
-
 
150
		}
-
 
151
	});		
-
 
152
}
-
 
153
 
-
 
154
 
-
 
155
 
66
function addResearch(refdivid, reqtype){
156
function addResearch(refdivid, reqtype){
67
     var research_tot = $("#research_total").val();
157
     var research_tot = $("#research_total").val();
68
     var seldata = [];
158
     var seldata = [];
69
     var tot = 0;
159
     var tot = 0;
70
     
160
     
Line 142... Line 232...
142
          alert("Please select atleast one product");
232
          alert("Please select atleast one product");
143
     }
233
     }
144
}
234
}
145
 
235
 
146
 
236
 
147
function addToCart(refdivid,reqtype){
-
 
148
     var seldata="";
-
 
149
     var tot=0;
-
 
150
     var saprt="";
-
 
151
     if(reqtype == "multi"){
-
 
152
          var containerdiv = "#" + refdivid;
-
 
153
          var par= containerdiv + " input[type=checkbox]:checked";
-
 
154
          var isMulti = false;
-
 
155
          $(par).each(function(){
-
 
156
        	  
-
 
157
	       	   var totalcolors = $(this).attr('totalcolors');
-
 
158
	           saprt = (tot>0)? "_":"";
-
 
159
               seldata += saprt+$(this).attr('itemid');
-
 
160
 
-
 
161
	           if(totalcolors != 1)	{
-
 
162
	        	   isMulti = true;
-
 
163
	       	   }
-
 
164
               tot++;
-
 
165
          });
-
 
166
          if(isMulti == true){
-
 
167
        	  alert("Some items are available in multiple colors. Please go to product page and select color you want.");
-
 
168
        	  return;
-
 
169
          } else	{
-
 
170
        	  var items = seldata.split('_');
-
 
171
        	  for(var i in items)	{
-
 
172
        		  trackEventWithGA('Order', 'Add to Cart', items[i]);
-
 
173
        	  }
-
 
174
          }
-
 
175
     }else if(reqtype == "single"){
-
 
176
          seldata = $("#item_id").val();
-
 
177
		  trackEventWithGA('Order', 'Add to Cart', seldata + '');
-
 
178
          tot=1;
-
 
179
     }else if(reqtype == "list"){
-
 
180
    	  var seldata=refdivid;
-
 
181
		  trackEventWithGA('Order', 'Add to Cart', seldata + '');
-
 
182
          tot=1;
-
 
183
     }
-
 
184
 
-
 
185
     if(tot > 0)	{
-
 
186
    	 jQuery.ajax({
-
 
187
    		 type: "POST",
-
 
188
    		 url: "/addtocart",
-
 
189
    		 data: "productid=" + seldata,
-
 
190
    		 success: function(msg){
-
 
191
    			 if(msg==""){
-
 
192
    				 window.location = "/cart";
-
 
193
    			 }else{
-
 
194
    				 alert(msg);
-
 
195
    			 }
-
 
196
    		 }
-
 
197
    	 });
-
 
198
     } else	{
-
 
199
    	 alert("Please select atleast one product");
-
 
200
     }
-
 
201
}
-
 
202
 
237
 
203
 
238
 
204
function scrollWinToTop(){
239
function scrollWinToTop(){
205
    $('html, body').animate({
240
    $('html, body').animate({
206
      scrollTop: $("body").offset().top
241
      scrollTop: $("body").offset().top