Developer forum

Forum » Ecommerce - Standard features » Custom order field opdateres ikke ved updateCart()

Custom order field opdateres ikke ved updateCart()

Jacob Bertelsen
Reply
A custom field in my shop, which is a checkbox, seems not to toggle when updating cart.

<!--@If(nzLeaveOrderAtHouse.Clean=="yes")--><div class="basketCol1"><input type="checkbox" name="nzLeaveOrderAtHouse" id="nzLeaveOrderAtHouse" onclick="updateCart();" checked /><!--@nzLeaveOrderAtHouse.Clean--></div><!--@EndIf-->
                    
<!--@If(nzLeaveOrderAtHouse.Clean=="no")--><div class="basketCol1"><input type="checkbox" name="nzLeaveOrderAtHouse" id="nzLeaveOrderAtHouse" onclick="updateCart();" /><!--@nzLeaveOrderAtHouse.Clean--></div><!--@EndIf-->
Until I check the box the first time, the value of @nzLeaveOrderAtHouse.Clean is "no" . When I trigger updateCart() , the page reloads and the value is "yes" , and my checkbox is checked, as the @If-condition for this is met. The problem is visible, when I want to un-check the checked checkbox. updatecart() is triggered, but the checkbox remains checked, and the value remains "yes" . Any of you got the same problem? Or any of you got a workaround?

Replies

 
Jacob Bertelsen
Reply

delivery_checked.jpg
 
Jacob Bertelsen
Reply

delivery_unchecked.jpg
 
Vladimir
Reply
Hi Jacob!
You may try something like:
<input name="nzLeaveOrderAtHouse" id="nzLeaveOrderAtHouse" type="hidden" value="<!--@nzLeaveOrderAtHouse.Clean-->" /> 

<!--@If(nzLeaveOrderAtHouse.Clean=="yes")-->
	 <div class="basketCol1">
		<input type="checkbox" onclick="CheckLeaveOrderAtHouse();" checked /><!--@nzLeaveOrderAtHouse.Clean-->
	 </div>
<!--@EndIf-->
<!--@If(nzLeaveOrderAtHouse.Clean=="no")-->
	<div class="basketCol1">
		<input type="checkbox" onclick="CheckLeaveOrderAtHouse();" />
	<!--@nzLeaveOrderAtHouse.Clean-->
</div>
<!--@EndIf-->

 function CheckLeaveOrderAtHouse(myCheckBox){
  var myTxt = document.getElementById('nzLeaveOrderAtHouse');
  if (myTxt){
   if (myCheckBox.checked)
    myTxt.value = 'checked';
   else
    myTxt.value = '';
  }
  updateCart();
 }
Best regards,
Vladimir


 

You must be logged in to post in the forum