Hide Shipping Address with JQueryTools
Posted: Fri Jul 23, 2010 7:15 pm
				
				For the orders module Billing template, it's handy to hide the Shipping Address form unless the User wants to change it.  I use JQueryTools to achieve this:
1. In the Orders Billing template, wrap a div around the Shipping Address section and give it an id, like so:
Then I call JQueryTools with the following content block:
			1. In the Orders Billing template, wrap a div around the Shipping Address section and give it an id, like so:
Code: Select all
<div id="shippingaddress">
  <!-- shipping address section goes here /-->
</div>
Code: Select all
{JQueryTools action='incjs' include=''}
{literal}
<__script__ type="text/javascript">
//on page load
$(document).ready(function() {
	// Hide Shipping Address by Default then inject checkbox
	$("#shippingaddress").hide().before('<p><strong>Shipping Address is same as Billing:</strong><input id="copyaddress" type="checkbox" name="same_as_billing" checked=checked /></p>');
	// toggle #shippingaddress form when the checkbox is checked or unchecked
    $("#copyaddress").click(function () {
		$("#shippingaddress").toggle();
	});
});
</__script>  
{/literal}