shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

shipping_address.twig (16848B)


      1 <form class="form-horizontal">
      2   {% if addresses %}
      3   <div class="radio">
      4     <label>
      5       <input type="radio" name="shipping_address" value="existing" checked="checked" />
      6       {{ text_address_existing }}</label>
      7   </div>
      8   <div id="shipping-existing">
      9     <select name="address_id" class="form-control">
     10      {% for address in addresses %}
     11       {% if address.address_id == address_id %}
     12       <option value="{{ address.address_id }}" selected="selected">{{ address.firstname }} {{ address.lastname }}, {{ address.address_1 }}, {{ address.city }}, {{ address.zone }}, {{ address.country }}</option>
     13       {% else %}
     14       <option value="{{ address.address_id }}">{{ address.firstname }} {{ address.lastname }}, {{ address.address_1 }}, {{ address.city }}, {{ address.zone }}, {{ address.country }}</option>
     15       {% endif %}
     16       {% endfor %}
     17     </select>
     18   </div>
     19   <div class="radio">
     20     <label>
     21       <input type="radio" name="shipping_address" value="new" />
     22       {{ text_address_new }}</label>
     23   </div>
     24   {% endif %}
     25   <br />
     26   <div id="shipping-new" style="display: {% if addresses %}none{% else %}block{% endif %};">
     27     <div class="form-group required">
     28       <label class="col-sm-2 control-label" for="input-shipping-firstname">{{ entry_firstname }}</label>
     29       <div class="col-sm-10">
     30         <input type="text" name="firstname" value="" placeholder="{{ entry_firstname }}" id="input-shipping-firstname" class="form-control" />
     31       </div>
     32     </div>
     33     <div class="form-group required">
     34       <label class="col-sm-2 control-label" for="input-shipping-lastname">{{ entry_lastname }}</label>
     35       <div class="col-sm-10">
     36         <input type="text" name="lastname" value="" placeholder="{{ entry_lastname }}" id="input-shipping-lastname" class="form-control" />
     37       </div>
     38     </div>
     39     <div class="form-group">
     40       <label class="col-sm-2 control-label" for="input-shipping-company">{{ entry_company }}</label>
     41       <div class="col-sm-10">
     42         <input type="text" name="company" value="" placeholder="{{ entry_company }}" id="input-shipping-company" class="form-control" />
     43       </div>
     44     </div>
     45     <div class="form-group required">
     46       <label class="col-sm-2 control-label" for="input-shipping-address-1">{{ entry_address_1 }}</label>
     47       <div class="col-sm-10">
     48         <input type="text" name="address_1" value="" placeholder="{{ entry_address_1 }}" id="input-shipping-address-1" class="form-control" />
     49       </div>
     50     </div>
     51     <div class="form-group">
     52       <label class="col-sm-2 control-label" for="input-shipping-address-2">{{ entry_address_2 }}</label>
     53       <div class="col-sm-10">
     54         <input type="text" name="address_2" value="" placeholder="{{ entry_address_2 }}" id="input-shipping-address-2" class="form-control" />
     55       </div>
     56     </div>
     57     <div class="form-group required">
     58       <label class="col-sm-2 control-label" for="input-shipping-city">{{ entry_city }}</label>
     59       <div class="col-sm-10">
     60         <input type="text" name="city" value="" placeholder="{{ entry_city }}" id="input-shipping-city" class="form-control" />
     61       </div>
     62     </div>
     63     <div class="form-group required">
     64       <label class="col-sm-2 control-label" for="input-shipping-postcode">{{ entry_postcode }}</label>
     65       <div class="col-sm-10">
     66         <input type="text" name="postcode" value="{{ postcode }}" placeholder="{{ entry_postcode }}" id="input-shipping-postcode" class="form-control" />
     67       </div>
     68     </div>
     69     <div class="form-group required">
     70       <label class="col-sm-2 control-label" for="input-shipping-country">{{ entry_country }}</label>
     71       <div class="col-sm-10">
     72         <select name="country_id" id="input-shipping-country" class="form-control">
     73           <option value="">{{ text_select }}</option>
     74           {% for country in countries %}
     75           {% if country.country_id == country_id %}
     76           <option value="{{ country.country_id }}" selected="selected">{{ country.name }}</option>
     77           {% else %}
     78           <option value="{{ country.country_id }}">{{ country.name }}</option>
     79            {% endif %}
     80            {% endfor %}
     81         </select>
     82       </div>
     83     </div>
     84     <div class="form-group required">
     85       <label class="col-sm-2 control-label" for="input-shipping-zone">{{ entry_zone }}</label>
     86       <div class="col-sm-10">
     87         <select name="zone_id" id="input-shipping-zone" class="form-control">
     88         </select>
     89       </div>
     90     </div>
     91    {% for custom_field in custom_fields %}
     92     {% if custom_field.type == 'select' %}
     93     <div class="form-group{% if custom_field.required %} required {% endif %} custom-field" data-sort="{{ custom_field.sort_order }}">
     94       <label class="col-sm-2 control-label" for="input-shipping-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
     95       <div class="col-sm-10">
     96         <select name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" class="form-control">
     97           <option value="">{{ text_select }}</option>
     98           {% for custom_field_value in custom_field.custom_field_value %}
     99           <option value="{{ custom_field_value.custom_field_value_id }}">{{ custom_field_value.name }}</option>
    100           {% endfor %}
    101         </select>
    102       </div>
    103     </div>
    104     {% endif %}
    105     {% if custom_field.type == 'radio' %}
    106     <div class="form-group{% if custom_field.required %} required {% endif %} custom-field" data-sort="{{ custom_field.sort_order }}">
    107       <label class="col-sm-2 control-label">{{ custom_field.name }}</label>
    108       <div class="col-sm-10">
    109         <div id="input-shipping-custom-field{{ custom_field.custom_field_id }}">
    110           {% for custom_field_value in custom_field.custom_field_value %}
    111           <div class="radio">
    112             <label>
    113               <input type="radio" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" />
    114               {{ custom_field_value.name }}</label>
    115           </div>
    116           {% endfor %}
    117         </div>
    118       </div>
    119     </div>
    120     {% endif %}
    121     {% if custom_field.type == 'checkbox' %}
    122     <div class="form-group{% if custom_field.required %} required {% endif %} custom-field" data-sort="{{ custom_field.sort_order }}">
    123       <label class="col-sm-2 control-label">{{ custom_field.name }}</label>
    124       <div class="col-sm-10">
    125         <div id="input-shipping-custom-field{{ custom_field.custom_field_id }}">
    126           {% for custom_field_value in custom_field.custom_field_value %}
    127           <div class="checkbox">
    128             <label>
    129               <input type="checkbox" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" />
    130               {{ custom_field_value.name }}</label>
    131           </div>
    132           {% endfor %}
    133         </div>
    134       </div>
    135     </div>
    136     {% endif %}
    137     {% if custom_field.type == 'text' %}
    138     <div class="form-group{% if custom_field.required %} required {% endif %} custom-field" data-sort="{{ custom_field.sort_order }}">
    139       <label class="col-sm-2 control-label" for="input-shipping-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
    140       <div class="col-sm-10">
    141         <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field.value }}" placeholder="{{ custom_field.name }}" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
    142       </div>
    143     </div>
    144     {% endif %}
    145     {% if custom_field.type == 'textarea' %}
    146     <div class="form-group{% if custom_field.required %} required {% endif %} custom-field" data-sort="{{ custom_field.sort_order }}">
    147       <label class="col-sm-2 control-label" for="input-shipping-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
    148       <div class="col-sm-10">
    149         <textarea name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" rows="5" placeholder="{{ custom_field.name }}" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" class="form-control">{{ custom_field.value }}</textarea>
    150       </div>
    151     </div>
    152     {% endif %}
    153     {% if custom_field.type == 'file' %}
    154     <div class="form-group{% if custom_field.required %} required {% endif %} custom-field" data-sort="{{ custom_field.sort_order }}">
    155       <label class="col-sm-2 control-label">{{ custom_field.name }}</label>
    156       <div class="col-sm-10">
    157         <button type="button" id="button-shipping-custom-field{{ custom_field.custom_field_id }}" data-loading-text="{{ text_loading }}" class="btn btn-default"><i class="fa fa-upload"></i> {{ button_upload }}</button>
    158         <input type="hidden" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" />
    159       </div>
    160     </div>
    161     {% endif %}
    162     {% if custom_field.type == 'date' %}
    163     <div class="form-group{% if custom_field.required %} required {% endif %} custom-field" data-sort="{{ custom_field.sort_order }}">
    164       <label class="col-sm-2 control-label" for="input-shipping-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
    165       <div class="col-sm-10">
    166         <div class="input-group date">
    167           <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
    168           <span class="input-group-btn">
    169           <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
    170           </span></div>
    171       </div>
    172     </div>
    173     {% endif %}
    174     {% if custom_field.type == 'time' %}
    175     <div class="form-group{% if custom_field.required %} required {% endif %} custom-field" data-sort="{{ custom_field.sort_order }}">
    176       <label class="col-sm-2 control-label" for="input-shipping-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
    177       <div class="col-sm-10">
    178         <div class="input-group time">
    179           <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="HH:mm" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
    180           <span class="input-group-btn">
    181           <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
    182           </span></div>
    183       </div>
    184     </div>
    185     {% endif %}
    186     {% if custom_field.type == 'time' %}
    187     <div class="form-group{% if custom_field.required %} required {% endif %} custom-field" data-sort="{{ custom_field.sort_order }}">
    188       <label class="col-sm-2 control-label" for="input-shipping-custom-field{{ custom_field.custom_field_id }}">{{ custom_field.name }}</label>
    189       <div class="col-sm-10">
    190         <div class="input-group datetime">
    191           <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD HH:mm" id="input-shipping-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
    192           <span class="input-group-btn">
    193           <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
    194           </span></div>
    195       </div>
    196     </div>
    197     {% endif %}
    198     {% endfor %}
    199   </div>
    200   <div class="buttons clearfix">
    201     <div class="pull-right">
    202       <input type="button" value="{{ button_continue }}" id="button-shipping-address" data-loading-text="{{ text_loading }}" class="btn btn-primary" />
    203     </div>
    204   </div>
    205 </form>
    206 <script type="text/javascript"><!--
    207 $('input[name=\'shipping_address\']').on('change', function() {
    208 	if (this.value == 'new') {
    209 		$('#shipping-existing').hide();
    210 		$('#shipping-new').show();
    211 	} else {
    212 		$('#shipping-existing').show();
    213 		$('#shipping-new').hide();
    214 	}
    215 });
    216 //--></script>
    217 <script type="text/javascript"><!--
    218 $('#collapse-shipping-address .form-group[data-sort]').detach().each(function() {
    219 	if ($(this).attr('data-sort') >= 0 && $(this).attr('data-sort') <= $('#collapse-shipping-address .form-group').length-2) {
    220 		$('#collapse-shipping-address .form-group').eq(parseInt($(this).attr('data-sort'))+2).before(this);
    221 	}
    222 
    223 	if ($(this).attr('data-sort') > $('#collapse-shipping-address .form-group').length-2) {
    224 		$('#collapse-shipping-address .form-group:last').after(this);
    225 	}
    226 
    227 	if ($(this).attr('data-sort') == $('#collapse-shipping-address .form-group').length-2) {
    228 		$('#collapse-shipping-address .form-group:last').after(this);
    229 	}
    230 
    231 	if ($(this).attr('data-sort') < -$('#collapse-shipping-address .form-group').length-2) {
    232 		$('#collapse-shipping-address .form-group:first').before(this);
    233 	}
    234 });
    235 //--></script>
    236 <script type="text/javascript"><!--
    237 $('#collapse-shipping-address button[id^=\'button-shipping-custom-field\']').on('click', function() {
    238 	var element = this;
    239 
    240 	$('#form-upload').remove();
    241 
    242 	$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');
    243 
    244 	$('#form-upload input[name=\'file\']').trigger('click');
    245 
    246 	if (typeof timer != 'undefined') {
    247     	clearInterval(timer);
    248 	}
    249 
    250 	timer = setInterval(function() {
    251 		if ($('#form-upload input[name=\'file\']').val() != '') {
    252 			clearInterval(timer);
    253 
    254 			$.ajax({
    255 				url: 'index.php?route=tool/upload',
    256 				type: 'post',
    257 				dataType: 'json',
    258 				data: new FormData($('#form-upload')[0]),
    259 				cache: false,
    260 				contentType: false,
    261 				processData: false,
    262 				beforeSend: function() {
    263 					$(element).button('loading');
    264 				},
    265 				complete: function() {
    266 					$(element).button('reset');
    267 				},
    268 				success: function(json) {
    269 					$(element).parent().find('.text-danger').remove();
    270 
    271 					if (json['error']) {
    272 						$(element).parent().find('input[name^=\'custom_field\']').after('<div class="text-danger">' + json['error'] + '</div>');
    273 					}
    274 
    275 					if (json['success']) {
    276 						alert(json['success']);
    277 
    278 						$(element).parent().find('input[name^=\'custom_field\']').val(json['code']);
    279 					}
    280 				},
    281 				error: function(xhr, ajaxOptions, thrownError) {
    282 					alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
    283 				}
    284 			});
    285 		}
    286 	}, 500);
    287 });
    288 //--></script>
    289 <script type="text/javascript"><!--
    290 $('.date').datetimepicker({
    291 	language: '{{ datepicker }}',
    292 	pickTime: false
    293 });
    294 
    295 $('.time').datetimepicker({
    296 	language: '{{ datepicker }}',
    297 	pickDate: false
    298 });
    299 
    300 $('.datetime').datetimepicker({
    301 	language: '{{ datepicker }}',
    302 	pickDate: true,
    303 	pickTime: true
    304 });
    305 //--></script>
    306 <script type="text/javascript"><!--
    307 $('#collapse-shipping-address select[name=\'country_id\']').on('change', function() {
    308 	$.ajax({
    309 		url: 'index.php?route=checkout/checkout/country&country_id=' + this.value,
    310 		dataType: 'json',
    311 		beforeSend: function() {
    312 			$('#collapse-shipping-address select[name=\'country_id\']').prop('disabled', true);
    313 		},
    314 		complete: function() {
    315 			$('#collapse-shipping-address select[name=\'country_id\']').prop('disabled', false);
    316 		},
    317 		success: function(json) {
    318 			if (json['postcode_required'] == '1') {
    319 				$('#collapse-shipping-address input[name=\'postcode\']').parent().parent().addClass('required');
    320 			} else {
    321 				$('#collapse-shipping-address input[name=\'postcode\']').parent().parent().removeClass('required');
    322 			}
    323 
    324 			html = '<option value="">{{ text_select }}</option>';
    325 
    326 			if (json['zone'] && json['zone'] != '') {
    327 				for (i = 0; i < json['zone'].length; i++) {
    328 					html += '<option value="' + json['zone'][i]['zone_id'] + '"';
    329 
    330 					if (json['zone'][i]['zone_id'] == '{{ zone_id }}') {
    331 						html += ' selected="selected"';
    332 					}
    333 
    334 					html += '>' + json['zone'][i]['name'] + '</option>';
    335 				}
    336 			} else {
    337 				html += '<option value="0" selected="selected">{{ text_none }}</option>';
    338 			}
    339 
    340 			$('#collapse-shipping-address select[name=\'zone_id\']').html(html);
    341 		},
    342 		error: function(xhr, ajaxOptions, thrownError) {
    343 			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
    344 		}
    345 	});
    346 });
    347 
    348 $('#collapse-shipping-address select[name=\'country_id\']').trigger('change');
    349 //--></script>