Solved

Jquery Calculation Value Incorrect

Posted on 2014-02-20
8
476 Views
Last Modified: 2014-02-20
See the below link:

http://www.themarblegroup.co.uk/get-a-free-quote/

If you fill out part of the quote form. For example.

1) Select any worktop material
2) Under worktop piece sizes add 1000 for the width and 1000 for the length.
3) Scroll down to the Calculate Quote button and submit.

You will notice the price on the left hand side of the button is ridiculously high!

I have noticed if you enter 1 for the worktop width and 1 for the worktop length it gives the correct price. i.e. The calculation must be set up for metres instead of millimetres.

Below is the code for the page. Can you please let me know where I change the calculation to you can enter millimetres and get the correct result.

<?php
/*
Template Name: Get Free Quotes
*/
 get_header();?>
 <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/jquery.formatCurrency.js"></script>
 <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/jquery.formatCurrency.en-GB.js"></script>
<?php $tpl_default_settings = get_post_meta($post->ID,'_tpl_default_settings',TRUE);
	  $tpl_default_settings = is_array($tpl_default_settings) ? $tpl_default_settings  : array();
	  
	  $page_layout  = array_key_exists("layout",$tpl_default_settings) ? $tpl_default_settings['layout'] : "content-full-width";
  	  $show_sidebar = false;
	  $sidebar_class= "";
	  
	  switch($page_layout):
		case 'with-left-sidebar':
			$page_layout 	=	"with-left-sidebar";
			$show_sidebar 	= 	true;
			$sidebar_class 	=	"left-sidebar";
		break;
		
		case 'with-right-sidebar':
			$show_sidebar 	= 	true;
		break;
	  endswitch;
	  
	  #Page Top Code Section
	  $mytheme_options = get_option(IAMD_THEME_SETTINGS);
	  $mytheme_integration = $mytheme_options['integration'];
	  if(isset($mytheme_integration['enable-single-page-top-code']))	echo stripslashes($mytheme_integration['single-page-top-code']);?>
      
      <!-- **Primary Section** -->
      <section id="primary" class="<?php echo $page_layout;?>">
				
				<div id="marble_table">
				<table>
				<tr>
				 <td>Select your brand:</td>
				 <td colspan="2"><select id="marble_db_brandname" name="marble_brandname"></select></td>
				</tr>
				<tr>
				 <td>Select your worktop material:</td>
				 <td><select id="marble_db_product" name="marbe_product" size="8"></select></td>
				 <td><div id="marble_image"></div></td>
				</tr>
				<tr>
				 <td>Select thickness:</td>
				 <td colspan="2"><select id="marble_db_thickness" name="marble_thickness"></select></td>
				</tr>
				<tr>
				 <td>Worktop piece sizes:</td>
				 <td>Length(mm):</td>
				 <td>Depth(mm):</td>
				</tr>
				<tr>
				 <td>
				   <input id="marble_wpp" type="submit" value=" + " />
				   <input id="marble_wpm" type="submit" value=" - " />
				 </td>
				 <td>
				  <div id="marble_wpl" class="marble_wprl">
				   <input name="wps_l[]" type="text" maxlength="6" value="0" />
				   <input name="wps_l[]" type="text" maxlength="6" value="0" />
				   <input name="wps_l[]" type="text" maxlength="6" value="0" />
				  </div>
				 <td>
				  <div id="marble_wpr" class="marble_wprl">
				   <input name="wps_d[]" type="text" maxlength="6" value="0" />
				   <input name="wps_d[]" type="text" maxlength="6" value="0" />
				   <input name="wps_d[]" type="text" maxlength="6" value="0" />
				  </div>
				 </td>
				</tr>
				<tr>
				 <td>Upstands/Splashback piece sizes:</td>
				 <td>Length(mm):</td>
				 <td>Height(mm):</td>
				</tr>
				<tr>
				 <td>
				   <input id="marble_upp" type="submit" value=" + " />
				   <input id="marble_upm" type="submit" value=" - " />
				 </td>
				 <td>
				  <div id="marble_upl">
				   <input name="ups_l[]" type="text" maxlength="6" value="0" />
				   <input name="ups_l[]" type="text" maxlength="6" value="0" />
				   <input name="ups_l[]" type="text" maxlength="6" value="0" />
				  </div>
				 <td>
				  <div id="marble_upr">
				   <input name="ups_d[]" type="text" maxlength="6" value="0" />
				   <input name="ups_d[]" type="text" maxlength="6" value="0" />
				   <input name="ups_d[]" type="text" maxlength="6" value="0" />
				  </div>
				 </td>
				</tr>
				<tr>
				 <td>Number of cut-outs for a sink:</td>
				 <td colspan="2"><input id="marble_sink" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
				<tr>
				 <td>Sink mounting style:</td>
				 <td colspan="2">
				  <select id="marble_db_style" name="wps">
				   <option value='2'>Polished</option>
				   <option value='3'>Unpolished</option>
				  </select>
				 </td>
				</tr>
				<tr>
				 <td>Number of sets of drainer grooves:</td> <!--Set Of Drainer Grooves (5 Grooves per set) -->
				 <td colspan="2"><input id="marble_grooves" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
				<tr>
				 <td>Number of cut-outs for a hob: </td>  <!--Hob Cut Out -->
				 <td colspan="2"><input id="marble_hob" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
				<tr>
				 <td>Number of tap holes:</td>  <!-- Tap Holes -->
				 <td colspan="2"><input id="marble_tab" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
				<tr>
				 <td>Number of plug holes:</td> 
				 <td colspan="2"><input id="marble_plug" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
        
        <!-- added by RJ -->
        <tr>
				 <td>Polished Area Details:</td>
				 <td colspan="2"><input id="marble_polishedarea" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
        
         <tr>
				 <td>Polished sink cut out :</td>
				 <td colspan="2"><input id="marble_polishedsink" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
        
        <tr>
				 <td>Curves :</td>
				 <td colspan="2"><input id="marble_curves" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
        
        <tr>
				 <td>Angles :</td>
				 <td colspan="2"><input id="marble_angles" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
        <tr>
				 
				 <td colspan="3"><center><input type="button" class="showhide" value=" Click here for choice of edge detail"/></center></td>
				</tr>
        
          
        <tr class="hide" style="display:none;" id="showhidediv">
        <td colspan=3 > <!-- Second part -->
         <table border=1 width="100%"> 
          <tr>
				 <td style="width:356px;">Double Pencil(standard edge):</td>
				 <td colspan="2"><input class="hidef" id="marble_dblpencil" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
        
        
          <tr>
				 <td>Single Pencil:</td>
				 <td colspan="2"><input class="hidef" id="marble_singlepencil" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr>
         
          <tr>
				 <td>Double Chamfer:</td>
				 <td colspan="2"><input class="hidef" id="marble_dblchamfer" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr>
          <tr>
				 <td>Single Chamfer:</td>
				 <td colspan="2"><input class="hidef" id="marble_singlechamfer" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr> 
         
          <tr>
				 <td>Cove:</td>
				 <td colspan="2"><input class="hidef" id="marble_cove" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr>  
         
                   <tr>
				 <td>Half Bull Nose:</td>
				 <td colspan="2"><input class="hidef" id="marble_halfbullnose" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr>  
         
          <tr>
				 <td>20 on 20 Birds Bak:</td>
				 <td colspan="2"><input class="hidef" id="marble_20birdsbak" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr>  

          <tr>
				 <td>20 on 20 Flat:</td>
				 <td colspan="2"><input class="hidef" id="marble_20flat" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr>  

          <tr>
				 <td>Irish Waterfall:</td>
				 <td colspan="2"><input class="hidef" id="marble_irishwaterfall" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr>  

          <tr>
				 <td>Mitred Edge:</td>
				 <td colspan="2"><input class="hidef" id="marble_mitrededge" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr>  
         
          <tr>
				 <td>Ogee:</td>
				 <td colspan="2"><input class="hidef" id="marble_ogee" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr>  
         
          <tr>
				 <td>Full Bull Nose:</td>
				 <td colspan="2"><input class="hidef" id="marble_fullbullnose" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr> 
         
          <tr>
				 <td>Dupont Edge:</td>
				 <td colspan="2"><input class="hidef" id="marble_dupontedge" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr>
         
          <tr>
				 <td>Ogee on 20mm Bull Nose :</td>
				 <td colspan="2"><input class="hidef" id="marble_ogee20bullnose" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr>
         
          <tr>
				 <td>Ogee on 30mm Bull Nose :</td>
				 <td colspan="2"><input class="hidef" id="marble_ogee30bullnose" type="text" maxlength="2" value="0" size="4" /></td>
				 </tr>                                                                                           
         
        </table>
        </td>
        </tr>
        
        
        <tr style="display:">
        <td colspan=3 > <!-- Second part -->
        <table border=1 width="100%"> 
         <tr>
				 <td style="width:356px;">Hob Bars :</td>
				 <td colspan="2"><input id="marble_hobbar" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
        
        <tr>
				 <td>Recessed Hob Cut Out :</td>
				 <td colspan="2"><input id="marble_hobcutout" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
        
        
        <tr>
				 <td>Recessed Drainer:</td>
				 <td colspan="2"><input id="marble_recesseddrainer" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>
        
        <tr>
				 <td>Plug Socket Cut Out :</td>
				 <td colspan="2"><input id="marble_socketcutout_plug" type="text" maxlength="2" value="0" size="4" /></td>
				</tr>        
        
        <tr>
				 <td>Chopping Board :</td>
				 <td colspan="2"><input id="marble_choppingboard" type="text" maxlength="2" value="0" size="4" /></td>
				</tr> 
          
         
        <tr>
				 <td>Worktop Cleaning Products :</td>
				 <td colspan="2"><input id="marble_worktopcleaning" type="text" maxlength="2" value="0" size="4" /></td>
				</tr> 
          </table>   
         </td>
        </tr> 
        
                
        
        
        <!-- end by Rj-->
        
       
				<tr>
				 <td>Templating: <input id="marble_templating" type="checkbox"  checked="checked"/></td>
				 <td colspan="2">Fitting: <input id="marble_fitting" type="checkbox" checked="checked" /></td>
				</tr>
				<tr>
				 <td><div class="marble_price">Price: &pound; <span id="marble_price">0</span> </div>
				 	 <div class="marble_price">Price <span style="font-size:9px;">(Inc Templating &amp; Fitting)</span>: &pound; <span id="marble_price_inc_ms">0</span> </div>
					 <div class="marble_price">VAT: &pound; <span id="marble_price_vat">0</span> </div></td>
				 <td><div class="marble_price_total">Total Price: &pound; <span id="marble_price_total">0</span> </div></td>
				 <td><input id="marble_get_quote" type="submit" value="Calculate Quote" />
				</tr>
				<tr>
				 <td colspan="3">Enquiry Details:</td>
				</tr>
				<tr>
				 <td>Customer name:</td>
				 <td colspan="2"><input id="marble_name" type="text" /></td>
				 </tr>
				<tr>
				 <td>Customer contact number:</td>
				 <td colspan="2"><input id="marble_phone" type="text" /></td>
				 </tr>
				<tr>
				 <td>Customer email address:</td>
				 <td colspan="2"><input id="marble_email_1" type="email" /></td>
				 </tr>
				<tr>
				 <td>Confirm email address:</td>
				 <td colspan="2"><input id="marble_email_2" type="email" /></td>
				 </tr>
				<tr>
				 <td>Fitting location:</td>
				 <td colspan="2"><input id="marble_address" type="text" /></td>
				 </tr>
				<tr>
				 <td>Helpful information:</td>
				 <td colspan="2"><textarea id="marble_info" rows="4" cols="20" /></textarea></td>
				</tr>
				<?php
				 $captcha = new ReallySimpleCaptcha();
				 $captcha->cleanup();
				 $word = $captcha->generate_random_word();
				 $prefix = mt_rand();
				 $img = $captcha->generate_image($prefix, $word);
				 //echo "$prefix, $word, $img, ".$captcha->tmp_dir.' '.WP_PLUGIN_URL;
				?>
				<tr>
				 <td>
				  <p>Please Enter the Code:</p>
				  <img src="<?php echo WP_PLUGIN_URL.'/really-simple-captcha/tmp/'.$img; ?>" /> 
				  <input id="marble_captcha" type="text" name="<?php echo $prefix; ?>" />
				 </td>
				 <td>
				 <input id="marble_submit" type="submit" value="Submit" />
				 </td>
				 <td><div id="marble_confirm"></div></td>
				</table>
				</div>
				<script type="text/javascript">
  
			
				var product;
				var prices;
				var info=[];
				info.wtl=[];
				info.wtr=[];
				var countwt;
				info.usl=[];
				info.usr=[];
				var countus;
				function marble_send_email(data){
				 data.action='send_email';
				 jQuery.ajax({
				  type:'POST',
				  url:'<?php echo get_template_directory_uri().'/ajax.php';?>',
				  data: data,
				  success:function(ret){
				   jQuery("#marble_confirm").empty().append(ret);
				  },
				  dataType:'json',
				  async:false
				 });
				}
				function marble_get_prices(id,thickness,style){
				 jQuery.ajax({
				  type:'POST',
				  url:'<?php echo get_template_directory_uri().'/ajax.php';?>',
				  data:{
					'action':'prices',
					'id':id,
					'thickness':thickness,
					'style':style},
				  success:function(data){
					prices=data;
					//alert("AJAX "+prices.price);
				   },
				  dataType:'json',
				  async:false
				 });
				}
				function marble_get_product(val){
				 jQuery.post(
				  '<?php echo get_template_directory_uri().'/ajax.php';?>',
				  {
				   'action':'product',
				   'id':val
				  },
				  function(data){
				   //store data in global variable
				   product=data;
				   text='<img width="130" height="130" src="http://www.themarblestore.co.uk/product_img/' + data.image +'">';
				   //set the image
				   jQuery("#marble_image").empty().append(text);
				   //set the thickness menu
				   obj=jQuery("#marble_db_thickness").empty();
				   for(var i = 0; i < data.thickness_value.length; i++){
					obj.append('<option value='+data.thickness_id[i]+'>'+data.thickness_value[i]+'</option>');
				   }
				   //set the sink mounting style menu -- only polished/unpolished!!!!
				   //obj=jQuery("#marble_db_style").empty();
				   //for(var i in data.finishing_id){
				   // obj.append('<option value='+data.finishing_id[i]+'>'+data.finishing_value[i]+'</option>');
				   //}
				  },
				   'json'
				 );
				}
				function marble_get_products(val){
				 jQuery.post(
				  '<?php echo get_template_directory_uri().'/ajax.php';?>',
				  {
				   'action':'products',
				   'brand':val
				  },
				  function(response){
				   jQuery("#marble_db_product").empty().append(response);
				   val = jQuery(".marble_selected_product").val();
				   marble_get_product(val);
				  }
				 );
				}
				(function($){
				 $(document).ready(function(){
				  $.post(
				   '<?php echo get_template_directory_uri().'/ajax.php';?>',
				   { 'action':'brandnames'},
				   function(response){
					$("#marble_db_brandname").append(response);
					val = $(".marble_selected_brand").val();
					marble_get_products(val);
				   }
				  );
				  $("#marble_db_brandname").change(function(){
				   val = $(this).val();
				   marble_get_products(val);
				  });
				  $("#marble_db_product").change(function(){
				   val = $(this).val();
				   marble_get_product(val);
				  });
				  $("#marble_wpp").click(function(){
				   $('#marble_wpl').append('<input name="wps_l[]" type="text" maxlength="6" value="0" />');
				   $('#marble_wpr').append('<input name="wps_d[]" type="text" maxlength="6" value="0" />');
				  });
				  $("#marble_upp").click(function(){
				   $('#marble_upl').append('<input name="ups_l[]" type="text" maxlength="6" value="0" />');
				   $('#marble_upr').append('<input name="ups_d[]" type="text" maxlength="6" value="0" />');
				  });
				  $("#marble_wpm").click(function(){
				   if($('#marble_wpl input').size()<2)
					return;
				   $('#marble_wpl input:last-child').remove();
				   $('#marble_wpr input:last-child').remove();
				  });
				  $("#marble_upm").click(function(){
				   if($('#marble_upl input').size()<2)
					return;
				   $('#marble_upl input:last-child').remove();
				   $('#marble_upr input:last-child').remove();
				  });
				  //Set auto fields
				  $(".marble_wprl input").live("keyup", function(){
				  	var subwktoplg = 0;
				  	$.each($("input[name='wps_l[]']"), function(index, value) {  
        
						  subwktoplg +=Math.floor($(this).val());
					  });
					  $.each($("input[name='wps_d[]']"), function(index, value) {  
        
						  subwktoplg +=Math.floor($(this).val());
					  });
					  $("#marble_polishedarea").val(subwktoplg);
					  $("#marble_dblpencil").val(subwktoplg);
				  });
				  //calculate the price
				  $("#marble_get_quote").click(function(){
				   // worktop area
				   rows=$('#marble_wpl input').size();
				   pr=[];pl=[];wt_area=0;
				   $('#marble_wpl').children('input').each(function(i){pl[i]=$(this).val();});
				   $('#marble_wpr').children('input').each(function(i){pr[i]=$(this).val();});
				   countwl=0;
				   for(i=0;i<rows;i++){
					area=pr[i]*pl[i];
					if(area>0){
					 info.wtl[countwl]=pl[i];
					 info.wtr[countwl]=pr[i];
					 countwl++;
					}
					wt_area+=area;
				   }
				   // Upstands/splashback area
				   rows=$('#marble_upl input').size();
				   pr=[];pl=[];us_area=0;
				   $('#marble_upl').children('input').each(function(i){pl[i]=$(this).val();});
				   $('#marble_upr').children('input').each(function(i){pr[i]=$(this).val();});
				   countus=0;
				   for(i=0;i<rows;i++){
					area=pr[i]*pl[i];
					if(area>0){
					 info.usl[countus]=pl[i];
					 info.usr[countus]=pr[i];
					 countus++;
					}
					us_area+=area;
				   }
          var wps_l_array = [];  
          var wps_d_array = [];  
          $.each($("input[name='wps_l[]']"), function(index, value) {  
         
              wps_l_array.push($(this).val());
          });
          $.each($("input[name='wps_d[]']"), function(index, value) {  
        
              wps_d_array.push($(this).val());
          });
          var wps_total=0;
          for(k=0; k<wps_l_array.length; k++){
             
             wps_total = wps_total + wps_l_array[k]*wps_d_array[k];
          }
          //for ups_
          var ups_l_array = [];  
          var ups_d_array = [];  
          $.each($("input[name='ups_l[]']"), function(index, value) {  
         
              ups_l_array.push($(this).val());
          });
          $.each($("input[name='ups_d[]']"), function(index, value) {  
        
              ups_d_array.push($(this).val());
          });
          var ups_total=0;
          for(k=0; k<ups_l_array.length; k++){
             
             ups_total = ups_total + ups_l_array[k]*ups_d_array[k];
          }
         
         
           
				   thickness=$("#marble_db_thickness").val();
				   info.thickness=thickness;
				   sink=$("#marble_sink").val();
				   info.sink=sink;
				   style=$("#marble_db_style").val();
				   info.style=style;
				   grooves=$("#marble_grooves").val();
				   info.grooves=grooves;
				   hob=$("#marble_hob").val();
				   info.hob=hob;
				   tab=$("#marble_tab").val();
				   info.tab=tab;
				   plug=$("#marble_plug").val();
				   info.plug=plug;
				   fitting=0;
				   if($("#marble_fitting").is(":checked")){
					fitting=1;
				   }
				   info.fitting=fitting;
				   templating=0;
				   if($("#marble_templating").is(":checked")){
					templating=1;
				   }
           // added
           polishedarea = $("#marble_polishedarea").val();
           info.polishedarea=polishedarea;
           
           polishedsink = $("#marble_polishedsink").val();
           info.polishedsink=polishedsink;
           
           curves = $("#marble_curves").val();
           info.curves=curves;
           
           angles = $("#marble_angles").val();
           info.angles=angles;
           
           hobbar = $("#marble_hobbar").val();
           info.hobbar=hobbar;
           
           hobcutout = $("#marble_hobcutout").val();
           info.hobcutout=hobcutout;
           
           recesseddrainer = $("#marble_recesseddrainer").val();
           info.recesseddrainer=recesseddrainer;
           
           socketcutout_plug = $("#marble_socketcutout_plug").val();
           info.socketcutout_plug=socketcutout_plug;
           
            choppingboard = $("#marble_choppingboard").val();
           info.choppingboard=choppingboard;
           
           worktopcleaning = $("#marble_worktopcleaning").val();
           info.worktopcleaning=worktopcleaning;
           
           /** Next **/
            dblpencil = $("#marble_dblpencil").val();
           info.dblpencil=dblpencil;
           
            
            singlepencil = $("#marble_singlepencil").val();
           info.singlepencil=singlepencil;
           
            dblchamfer = $("#marble_dblchamfer").val();
           info.dblchamfer=dblchamfer;
            
            singlechamfer = $("#marble_singlechamfer").val();
           info.singlechamfer=singlechamfer;
           
            cove = $("#marble_cove").val();
            info.cove=cove;
            
            halfbullnose = $("#marble_halfbullnose").val();
            info.halfbullnose=halfbullnose;
            
            
            a20birdsbak = $("#marble_20birdsbak").val();
            info.a20birdsbak=a20birdsbak;
           
            a20flat = $("#marble_20flat").val();
            info.a20flat=a20flat;
            
            irishwaterfall = $("#marble_irishwaterfall").val();
            info.irishwaterfall=irishwaterfall;
            
            mitrededge = $("#marble_mitrededge").val();
            info.mitrededge=mitrededge;
            
            ogee = $("#marble_ogee").val();
            info.ogee=ogee;
            
            fullbullnose = $("#marble_fullbullnose").val();
            info.fullbullnose=fullbullnose;
            
            dupontedge = $("#marble_dupontedge").val();
            info.dupontedge=dupontedge;
            
            ogee20bullnose = $("#marble_ogee20bullnose").val();
            info.ogee20bullnose=ogee20bullnose;  
                      
            ogee30bullnose = $("#marble_ogee30bullnose").val();
            info.ogee30bullnose=ogee30bullnose;            
           
       
     
            //price = prices.polishedsink*polishedsink+prices.curves*curves+prices.angles*angles;
           // price = prices.hobbar*hobbar+prices.hobcutout*hobcutout+prices.recesseddrainer*recesseddrainer+prices.plug*socketcutout_plug+prices.choppingboard*choppingboard+prices.worktopcleaning*worktopcleaning;
           // end
           
				   info.templating=templating;
				   id=product.price;
				   info.id=id;
				   //get price ajax
				   marble_get_prices(id, thickness, style);
				 //alert(wt_area*prices.price);  //price=(wt_area*prices.price)+plug*prices.plug+sink*prices.style+grooves*prices.grooves+hob*prices.hob+tab*prices.tab;
				   /*price=(wt_area*prices.price+us_area*prices.splashback)/1000000+sink*prices.style+grooves*prices.grooves+hob*prices.hob+tab*prices.tab+plug*prices.plug+templating*prices.templating+fitting*prices.fitting+prices.polishedsink*polishedsink+prices.curves*curves+prices.angles*angles+prices.hobbar*hobbar+prices.hobcutout*hobcutout+prices.recesseddrainer*recesseddrainer+prices.plug*socketcutout_plug+prices.choppingboard*choppingboard+prices.worktopcleaning*worktopcleaning+ prices.dblpencil*dblpencil+prices.singlepencil*singlepencil+prices.dblchamfer*dblchamfer+prices.singlechamfer*singlechamfer+prices.cove*cove+prices.halfbullnose*halfbullnose+prices.a20flat*a20flat+prices.irishwaterfall*irishwaterfall+prices.mitrededge*mitrededge+prices.ogee*ogee+prices.fullbullnose*fullbullnose+prices.dupontedge*dupontedge+prices.ogee20bullnose*ogee20bullnose+prices.ogee30bullnose*ogee30bullnose+wps_total*150+ups_total*200;*/
				   //POLISH_UNITE_PRICE = 20
           		price=	(wt_area*prices.price+us_area*prices.splashback)
						+sink*prices.style
						+grooves*prices.grooves
						+hob*prices.hob
						+tab*prices.tab
						+plug*prices.plug
						+20*polishedarea
						+prices.polishedsink*polishedsink
						+prices.curves*curves
						+prices.angles*angles
						+prices.hobbar*hobbar
						+prices.hobcutout*hobcutout
						+prices.recesseddrainer*recesseddrainer
						+prices.plug*socketcutout_plug
						+prices.choppingboard*choppingboard
						+prices.worktopcleaning*worktopcleaning
						+prices.dblpencil*dblpencil
						+prices.singlepencil*singlepencil
						+prices.dblchamfer*dblchamfer
						+prices.singlechamfer*singlechamfer
						+prices.cove*cove
						+prices.halfbullnose*halfbullnose
						+prices.a20flat*a20flat
						+prices.irishwaterfall*irishwaterfall
						+prices.mitrededge*mitrededge
						+prices.ogee*ogee
						+prices.fullbullnose*fullbullnose
						+prices.dupontedge*dupontedge
						+prices.ogee20bullnose*ogee20bullnose
						+prices.ogee30bullnose*ogee30bullnose;
          
				   info.price=Math.floor(price);
				   info.vat=Math.floor(price*prices.vat/100);
				   info.total=Math.floor(price*(1.0 + prices.vat/100));
				   $("#marble_price").text(info.price);
				   //Include Templating & Fitting 
				   price = price+fitting*prices.fitting+templating*prices.templating;
				   info.price=Math.floor(price);
				   $("#marble_price_inc_ms").text(info.price); // Including mandatory services
				   $("#marble_price_inc_ms").formatCurrency();
				   $("#marble_price").formatCurrency();
				   $("#marble_price_vat").text(info.vat);
				   $("#marble_price_vat").formatCurrency();
				   $("#marble_price_total").text(info.total);
				   $("#marble_price_total").formatCurrency();
				  });
				  $("#marble_submit").click(function(){
				   email1=$("#marble_email_1");
				   email2=$("#marble_email_2");
				   if(email1.val().length===0||email1.val()!==email2.val()){
					email1.css('border-color','red');
					email2.css('border-color','red');
					$("#marble_confirm").empty().append('Check the e-mail address');
					return;
				   } else {
					email1.css('border-color','inherit');
					email2.css('border-color','inherit');
				   }
				   var send_data={};
				   captcha = $("#marble_captcha");
				   send_data.captcha_prefix=captcha.attr("name");
				   send_data.captcha_value=captcha.val();
				   send_data.name=$("#marble_name").val();
				   send_data.phone=$("#marble_phone").val();
				   send_data.email=email1.val();
				   send_data.address=$("#marble_address").val();
				   send_data.info=$("#marble_info").val();
				   send_data.thickness=$("#marble_db_thickness option:selected").text();
				   send_data.sink=info.sink;
				   send_data.style=$("#marble_db_style option:selected").text();
				   send_data.grooves=info.grooves;
				   send_data.hob=info.hob;
				   send_data.tab=info.tab;
				   send_data.plug=info.plug;
				   send_data.fitting=info.fitting;
				   send_data.templating=info.templating;
				   send_data.product=$("#marble_db_product option:selected").text();
				   send_data.brand=$("#marble_db_brandname option:selected").text();
				   send_data.price=info.price;
				   send_data.vat=info.vat;
				   send_data.total=info.total;
				   send_data.wtl={};
				   send_data.wtr={};
				   send_data.usl={};
				   send_data.usr={};
				   for(i=0;i<countwl;i++){
					send_data.wtl[i]=info.wtl[i];
					send_data.wtr[i]=info.wtr[i];
				   }
				   for(i=0;i<countus;i++){
					send_data.usl[i]=info.usl[i];
					send_data.usr[i]=info.usr[i];
				   }
				   marble_send_email(send_data);
				   $("#marble_captcha").val('');
				  });
				 });
				})(jQuery);
        
        

   
 
				</script>
        <script>
           jQuery('.showhide').click(
                function(){
                 if(jQuery("#showhidediv").hasClass('hide')){
                 
                    jQuery("#showhidediv").show();
                    jQuery("#showhidediv").removeClass('hide');
                     jQuery(this).val('Click here to hide possible edge details');
                    
                 }else{
                 
                   jQuery("#showhidediv").hide();
                   jQuery("#showhidediv").addClass('hide');
                   jQuery(this).val('Click here for choice of edge detail');
                 }
                }
           );
        </script>
				<?php
								the_content(__('Read more','avia_framework')); 
								
								//check if this is the contact form page, if so display the form
								if(avia_get_option('email_page') == $post->ID) get_template_part( 'includes/contact-form' );
							
								 ?>	
												
							   
      </section><!-- **Primary Section** -->
        
<?php if($show_sidebar): ?>
	  <!-- **Secondary Section ** -->
      <section id="secondary" class="<?php echo $sidebar_class; ?>">
<?php 	get_sidebar();?>      
      </section><!-- **Secondary Section - End** -->
<?php endif; ?>
<?php

$number = 1234.56;

// english notation (default)
$english_format_number = number_format($number);
// 1,235

// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56

$number = 1234.5678;

// english notation without thousands seperator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57

?>

<?php #Page Top Code Section
	  $mytheme_integration = $mytheme_options['integration'];
	  if(isset($mytheme_integration['enable-single-page-bottom-code']))	echo stripslashes($mytheme_integration['single-page-bottom-code']);
	  
	  get_footer();?>

Open in new window

0
Comment
Question by:petewinter
  • 3
  • 2
  • 2
8 Comments
 
LVL 24

Assisted Solution

by:mankowitz
mankowitz earned 250 total points
Comment Utility
In this part,

				   pr=[];pl=[];wt_area=0;
				   $('#marble_wpl').children('input').each(function(i){pl[i]=$(this).val();});
				   $('#marble_wpr').children('input').each(function(i){pr[i]=$(this).val();});
				   countwl=0;
				   for(i=0;i<rows;i++){
					area=pr[i]*pl[i];

Open in new window


Try changing it to

				   pr=[];pl=[];wt_area=0;
				   $('#marble_wpl').children('input').each(function(i){pl[i]=$(this).val()/1000;});
				   $('#marble_wpr').children('input').each(function(i){pr[i]=$(this).val()/1000;});
				   countwl=0;
				   for(i=0;i<rows;i++){
					area=pr[i]*pl[i];

Open in new window

0
 

Author Comment

by:petewinter
Comment Utility
mankowitz - Thanks for the reply, but that didn't change anything. Check the same link.
0
 
LVL 24

Expert Comment

by:mankowitz
Comment Utility
Can you post a rendered copy of the page? Perhaps that will help me.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:petewinter
Comment Utility
0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 250 total points
Comment Utility
mankowitz was correct with the recommended change but thre is more to the script than those lines.

If you look in your price calculation there are two other amounts that come into play

+20*polishedarea; // Defaults to 2000 so 40,000 there
prices.dblpencil*dblpencil; // price 25 dblpencil 2000 so 50,000 there

Area is calculated as 1 and price for wortop area is 250

That gives 90,250

The culprit seems to be the polished area and dblpencil - they are both set to subwktoplg here

$(".marble_wprl input").live("keyup", function(){
  var subwktoplg = 0;
  $.each($("input[name='wps_l[]']"), function(index, value) {  
    subwktoplg +=Math.floor($(this).val());
  });
  $.each($("input[name='wps_d[]']"), function(index, value) {  
    subwktoplg +=Math.floor($(this).val());
  });
  $("#marble_polishedarea").val(subwktoplg);
  $("#marble_dblpencil").val(subwktoplg);
});

Open in new window


So you need to add the \1000 to this code to

$(".marble_wprl input").live("keyup", function(){
  var subwktoplg = 0;
  $.each($("input[name='wps_l[]']"), function(index, value) {  
    subwktoplg +=Math.floor($(this).val())/1000;
  });
  $.each($("input[name='wps_d[]']"), function(index, value) {  
    subwktoplg +=Math.floor($(this).val())/1000;
  });
  $("#marble_polishedarea").val(subwktoplg);
  $("#marble_dblpencil").val(subwktoplg);
});

Open in new window


You will need to go through all the code and check all the places that a .val() is being used. Refer back to what field that is refering to and then add the /1000
0
 

Author Closing Comment

by:petewinter
Comment Utility
That's great. Many thanks
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
You are welcome - thanks for the points.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn how to dynamically set the form action using jQuery.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now