-
Notifications
You must be signed in to change notification settings - Fork 7
/
order-address-multishipping.tpl
executable file
·187 lines (163 loc) · 6.77 KB
/
order-address-multishipping.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
{*
*
*
*}
{if $opc}
{assign var="back_order_page" value="order-opc.php"}
{else}
{assign var="back_order_page" value="order.php"}
{/if}
{* Will be deleted for 1.5 version and more *}
{if !isset($formatedAddressFieldsValuesList)}
{$ignoreList.0 = "id_address"}
{$ignoreList.1 = "id_country"}
{$ignoreList.2 = "id_state"}
{$ignoreList.3 = "id_customer"}
{$ignoreList.4 = "id_manufacturer"}
{$ignoreList.5 = "id_supplier"}
{$ignoreList.6 = "date_add"}
{$ignoreList.7 = "date_upd"}
{$ignoreList.8 = "active"}
{$ignoreList.9 = "deleted"}
{* PrestaShop 1.4.0.17 compatibility *}
{if isset($addresses)}
{foreach from=$addresses key=k item=address}
{counter start=0 skip=1 assign=address_key_number}
{$id_address = $address.id_address}
{foreach from=$address key=address_key item=address_content}
{if !in_array($address_key, $ignoreList)}
{$formatedAddressFieldsValuesList.$id_address.ordered_fields.$address_key_number = $address_key}
{$formatedAddressFieldsValuesList.$id_address.formated_fields_values.$address_key = $address_content}
{counter}
{/if}
{/foreach}
{/foreach}
{/if}
{/if}
<script>
{if !$opc}
var orderProcess = 'order',
currencySign = '{$currencySign|html_entity_decode:2:"UTF-8"}',
currencyRate = '{$currencyRate|floatval}',
currencyFormat = '{$currencyFormat|intval}',
currencyBlank = '{$currencyBlank|intval}',
txtProduct = "{l s='product' js=1}",
txtProducts = "{l s='products' js=1}",
txtSelectAnAddressFirst = "{l s='Please start by selecting an address' js=1}";
{/if}
var formatedAddressFieldsValuesList = new Array();
{foreach from=$formatedAddressFieldsValuesList key=id_address item=type}
formatedAddressFieldsValuesList[{$id_address}] =
{
'ordered_fields':[
{foreach from=$type.ordered_fields key=num_field item=field_name name=inv_loop}
{if !$smarty.foreach.inv_loop.first},{/if}"{$field_name}"
{/foreach}
],
'formated_fields_values':{
{foreach from=$type.formated_fields_values key=pattern_name item=field_name name=inv_loop}
{if !$smarty.foreach.inv_loop.first},{/if}"{$pattern_name}":"{$field_name}"
{/foreach}
}
}
{/foreach}
function getAddressesTitles() {
return {
'invoice': "{l s='Your billing address'}",
'delivery': "{l s='Your delivery address'}"
};
}
function buildAddressBlock(id_address, address_type, dest_comp) {
var adr_titles_vals = getAddressesTitles(),
li_content = formatedAddressFieldsValuesList[id_address]['formated_fields_values'],
ordered_fields_name = ['title'];
ordered_fields_name = ordered_fields_name.concat(formatedAddressFieldsValuesList[id_address]['ordered_fields']);
ordered_fields_name = ordered_fields_name.concat(['update']);
dest_comp.html('');
li_content['title'] = adr_titles_vals[address_type];
li_content['update'] = '<a href="{$link->getPageLink('address', true, NULL, "id_address")}'+id_address+'&back=order?step=1{if $back}&mod={$back}{/if}" title="{l s='Update' js=1}">{l s='Update' js=1}</a>';
appendAddressList(dest_comp, li_content, ordered_fields_name);
}
function appendAddressList(dest_comp, values, fields_name) {
for (var item in fields_name) {
var name = fields_name[item],
value = getFieldValue(name, values);
if (value != "") {
var new_li = document.createElement('li');
new_li.className = 'address_'+ name;
new_li.innerHTML = getFieldValue(name, values);
dest_comp.append(new_li);
}
}
}
function getFieldValue(field_name, values) {
var reg=new RegExp("[ ]+", "g"),
items = field_name.split(reg),
vals = new Array();
for (var field_item in items)
vals.push(values[items[field_item]]);
return vals.join(" ");
}
</script>
{if !$opc}
{capture name=path}{l s='Addresses'}{/capture}
{include file="$tpl_dir./breadcrumb.tpl"}
{/if}
{if !$opc}
<h1>{l s='Addresses'}</h1>
{else}
<h2><span>1</span> {l s='Addresses'}</h2>
{/if}
{if !$opc}
{assign var='current_step' value='address'}
{include file="$tpl_dir./order-steps.tpl"}
{include file="$tpl_dir./errors.tpl"}
{include file="$tpl_dir./order-address-multishipping-products.tpl"}
<form action="{$link->getPageLink('order', true, NULL, 'multi-shipping=1')}" method="post">
{else}
<div id="opc_account" class="opc-main-block">
<div id="opc_account-overlay" class="opc-overlay" style="display: none;"></div>
{/if}
<div class="addresses clearfix">
<input type="hidden" name="id_address_delivery" id="id_address_delivery" value="{$cart->id_address_delivery}" onchange="updateAddressesDisplay();{if $opc}updateAddressSelection();{/if}">
<p id="address_invoice_form" class="select" {if $cart->id_address_invoice == $cart->id_address_delivery}style="display: none;"{/if}>
{if $addresses|@count >= 1}
<label for="id_address_invoice" class="strong">{l s='Choose a billing address:'}</label>
<select name="id_address_invoice" id="id_address_invoice" class="address_select" onchange="updateAddressesDisplay();{if $opc}updateAddressSelection();{/if}">
{section loop=$addresses step=-1 name=address}
<option value="{$addresses[address].id_address|intval}" {if $addresses[address].id_address == $cart->id_address_invoice && $cart->id_address_delivery != $cart->id_address_invoice}selected="selected"{/if}>{$addresses[address].alias|escape:'htmlall':'UTF-8'}</option>
{/section}
</select>
{else}
<a href="{$link->getPageLink('address', true, NULL, "back={$back_order_page}?step=1{'&multi-shipping=1'|urlencode}{if $back}&mod={$back}{/if}")}" title="{l s='Add'}" class="button_large">{l s='Add a new address'}</a>
{/if}
</p>
<div class="clearfix">
<ul class="address alternate_item {if $cart->isVirtualCart()}full_width{/if}" id="address_invoice">
</ul>
</div>
<p class="address_add submit">
<a href="{$link->getPageLink('address', true, NULL, "back={$back_order_page}?step=1{'&multi-shipping=1'|urlencode}{if $back}&mod={$back|urlencode}{/if}")}" title="{l s='Add'}" class="button_large">» {l s='Add a new address'}</a>
</p>
{if !$opc}
<div id="ordermsg" class="clearfix">
<p class="txt">{l s='If you would like to add a comment about your order, please write it below.'}</p>
<p class="textarea"><textarea name="message">{if isset($oldMessage)}{$oldMessage}{/if}</textarea></p>
</div>
{/if}
</div>
{if !$opc}
<p class="cart_navigation submit">
<input type="hidden" class="hidden" name="step" value="2">
<input type="hidden" name="back" value="{$back}">
{if $back}
<a href="{$link->getPageLink('order', true, NULL, "step=0&back={$back}")}" title="{l s='Previous'}" class="button">{l s='Previous'}</a>
{else}
<a href="{$link->getPageLink('order', true, NULL, "step=0")}" title="{l s='Previous'}" class="button">{l s='Previous'}</a>
{/if}
<input type="submit" name="processAddress" value="{l s='Next'} »" class="exclusive">
</p>
</form>
{else}
</div>
{/if}