PageRenderTime 54ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/upload/catalog/view/theme/default/template/checkout/checkout.tpl

https://bitbucket.org/elena_dyavolova/omf
Smarty Template | 929 lines | 788 code | 141 blank | 0 comment | 106 complexity | feb33b0d62dcb4eec2ead129b88379bb MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
  2. <div id="content"><?php echo $content_top; ?>
  3. <div class="breadcrumb">
  4. <?php foreach ($breadcrumbs as $breadcrumb) { ?>
  5. <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
  6. <?php } ?>
  7. </div>
  8. <h1><?php echo $heading_title; ?></h1>
  9. <div class="checkout">
  10. <div id="checkout">
  11. <div class="checkout-heading"><?php echo $text_checkout_option; ?></div>
  12. <div class="checkout-content"></div>
  13. </div>
  14. <?php if (!$logged) { ?>
  15. <div id="payment-address">
  16. <div class="checkout-heading"><span><?php echo $text_checkout_account; ?></span></div>
  17. <div class="checkout-content"></div>
  18. </div>
  19. <?php } else { ?>
  20. <div id="payment-address">
  21. <div class="checkout-heading"><span><?php echo $text_checkout_payment_address; ?></span></div>
  22. <div class="checkout-content"></div>
  23. </div>
  24. <?php } ?>
  25. <?php if ($shipping_required) { ?>
  26. <div id="shipping-address">
  27. <div class="checkout-heading"><?php echo $text_checkout_shipping_address; ?></div>
  28. <div class="checkout-content"></div>
  29. </div>
  30. <div id="shipping-method">
  31. <div class="checkout-heading"><?php echo $text_checkout_shipping_method; ?></div>
  32. <div class="checkout-content"></div>
  33. </div>
  34. <?php } ?>
  35. <div id="payment-method">
  36. <div class="checkout-heading"><?php echo $text_checkout_payment_method; ?></div>
  37. <div class="checkout-content"></div>
  38. </div>
  39. <div id="confirm">
  40. <div class="checkout-heading"><?php echo $text_checkout_confirm; ?></div>
  41. <div class="checkout-content"></div>
  42. </div>
  43. </div>
  44. <?php echo $content_bottom; ?></div>
  45. <script type="text/javascript"><!--
  46. $('#checkout .checkout-content input[name=\'account\']').live('change', function() {
  47. if ($(this).attr('value') == 'register') {
  48. $('#payment-address .checkout-heading span').html('<?php echo $text_checkout_account; ?>');
  49. } else {
  50. $('#payment-address .checkout-heading span').html('<?php echo $text_checkout_payment_address; ?>');
  51. }
  52. });
  53. $('.checkout-heading a').live('click', function() {
  54. $('.checkout-content').slideUp('slow');
  55. $(this).parent().parent().find('.checkout-content').slideDown('slow');
  56. });
  57. <?php if (!$logged) { ?>
  58. $(document).ready(function() {
  59. $.ajax({
  60. url: 'index.php?route=checkout/login',
  61. dataType: 'html',
  62. success: function(html) {
  63. $('#checkout .checkout-content').html(html);
  64. $('#checkout .checkout-content').slideDown('slow');
  65. },
  66. error: function(xhr, ajaxOptions, thrownError) {
  67. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  68. }
  69. });
  70. });
  71. <?php } else { ?>
  72. $(document).ready(function() {
  73. $.ajax({
  74. url: 'index.php?route=checkout/payment_address',
  75. dataType: 'html',
  76. success: function(html) {
  77. $('#payment-address .checkout-content').html(html);
  78. $('#payment-address .checkout-content').slideDown('slow');
  79. },
  80. error: function(xhr, ajaxOptions, thrownError) {
  81. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  82. }
  83. });
  84. });
  85. <?php } ?>
  86. // Checkout
  87. $('#button-account').live('click', function() {
  88. $.ajax({
  89. url: 'index.php?route=checkout/' + $('input[name=\'account\']:checked').attr('value'),
  90. dataType: 'html',
  91. beforeSend: function() {
  92. $('#button-account').attr('disabled', true);
  93. $('#button-account').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
  94. },
  95. complete: function() {
  96. $('#button-account').attr('disabled', false);
  97. $('.wait').remove();
  98. },
  99. success: function(html) {
  100. $('.warning, .error').remove();
  101. $('#payment-address .checkout-content').html(html);
  102. $('#checkout .checkout-content').slideUp('slow');
  103. $('#payment-address .checkout-content').slideDown('slow');
  104. $('.checkout-heading a').remove();
  105. $('#checkout .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  106. },
  107. error: function(xhr, ajaxOptions, thrownError) {
  108. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  109. }
  110. });
  111. });
  112. // Login
  113. $('#button-login').live('click', function() {
  114. $.ajax({
  115. url: 'index.php?route=checkout/login/validate',
  116. type: 'post',
  117. data: $('#checkout #login :input'),
  118. dataType: 'json',
  119. beforeSend: function() {
  120. $('#button-login').attr('disabled', true);
  121. $('#button-login').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
  122. },
  123. complete: function() {
  124. $('#button-login').attr('disabled', false);
  125. $('.wait').remove();
  126. },
  127. success: function(json) {
  128. $('.warning, .error').remove();
  129. if (json['redirect']) {
  130. location = json['redirect'];
  131. } else if (json['error']) {
  132. $('#checkout .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '</div>');
  133. $('.warning').fadeIn('slow');
  134. }
  135. },
  136. error: function(xhr, ajaxOptions, thrownError) {
  137. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  138. }
  139. });
  140. });
  141. // Register
  142. $('#button-register').live('click', function() {
  143. $.ajax({
  144. url: 'index.php?route=checkout/register/validate',
  145. type: 'post',
  146. data: $('#payment-address input[type=\'text\'], #payment-address input[type=\'password\'], #payment-address input[type=\'checkbox\']:checked, #payment-address input[type=\'radio\']:checked, #payment-address input[type=\'hidden\'], #payment-address select'),
  147. dataType: 'json',
  148. beforeSend: function() {
  149. $('#button-register').attr('disabled', true);
  150. $('#button-register').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
  151. },
  152. complete: function() {
  153. $('#button-register').attr('disabled', false);
  154. $('.wait').remove();
  155. },
  156. success: function(json) {
  157. $('.warning, .error').remove();
  158. if (json['redirect']) {
  159. location = json['redirect'];
  160. } else if (json['error']) {
  161. if (json['error']['warning']) {
  162. $('#payment-address .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
  163. $('.warning').fadeIn('slow');
  164. }
  165. if (json['error']['firstname']) {
  166. $('#payment-address input[name=\'firstname\'] + br').after('<span class="error">' + json['error']['firstname'] + '</span>');
  167. }
  168. if (json['error']['lastname']) {
  169. $('#payment-address input[name=\'lastname\'] + br').after('<span class="error">' + json['error']['lastname'] + '</span>');
  170. }
  171. if (json['error']['email']) {
  172. $('#payment-address input[name=\'email\'] + br').after('<span class="error">' + json['error']['email'] + '</span>');
  173. }
  174. if (json['error']['telephone']) {
  175. $('#payment-address input[name=\'telephone\'] + br').after('<span class="error">' + json['error']['telephone'] + '</span>');
  176. }
  177. if (json['error']['company_id']) {
  178. $('#payment-address input[name=\'company_id\'] + br').after('<span class="error">' + json['error']['company_id'] + '</span>');
  179. }
  180. if (json['error']['tax_id']) {
  181. $('#payment-address input[name=\'tax_id\'] + br').after('<span class="error">' + json['error']['tax_id'] + '</span>');
  182. }
  183. if (json['error']['address_1']) {
  184. $('#payment-address input[name=\'address_1\'] + br').after('<span class="error">' + json['error']['address_1'] + '</span>');
  185. }
  186. if (json['error']['city']) {
  187. $('#payment-address input[name=\'city\'] + br').after('<span class="error">' + json['error']['city'] + '</span>');
  188. }
  189. if (json['error']['postcode']) {
  190. $('#payment-address input[name=\'postcode\'] + br').after('<span class="error">' + json['error']['postcode'] + '</span>');
  191. }
  192. if (json['error']['country']) {
  193. $('#payment-address select[name=\'country_id\'] + br').after('<span class="error">' + json['error']['country'] + '</span>');
  194. }
  195. if (json['error']['zone']) {
  196. $('#payment-address select[name=\'zone_id\'] + br').after('<span class="error">' + json['error']['zone'] + '</span>');
  197. }
  198. if (json['error']['password']) {
  199. $('#payment-address input[name=\'password\'] + br').after('<span class="error">' + json['error']['password'] + '</span>');
  200. }
  201. if (json['error']['confirm']) {
  202. $('#payment-address input[name=\'confirm\'] + br').after('<span class="error">' + json['error']['confirm'] + '</span>');
  203. }
  204. } else {
  205. <?php if ($shipping_required) { ?>
  206. var shipping_address = $('#payment-address input[name=\'shipping_address\']:checked').attr('value');
  207. if (shipping_address) {
  208. $.ajax({
  209. url: 'index.php?route=checkout/shipping_method',
  210. dataType: 'html',
  211. success: function(html) {
  212. $('#shipping-method .checkout-content').html(html);
  213. $('#payment-address .checkout-content').slideUp('slow');
  214. $('#shipping-method .checkout-content').slideDown('slow');
  215. $('#checkout .checkout-heading a').remove();
  216. $('#payment-address .checkout-heading a').remove();
  217. $('#shipping-address .checkout-heading a').remove();
  218. $('#shipping-method .checkout-heading a').remove();
  219. $('#payment-method .checkout-heading a').remove();
  220. $('#shipping-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  221. $('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  222. $.ajax({
  223. url: 'index.php?route=checkout/shipping_address',
  224. dataType: 'html',
  225. success: function(html) {
  226. $('#shipping-address .checkout-content').html(html);
  227. },
  228. error: function(xhr, ajaxOptions, thrownError) {
  229. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  230. }
  231. });
  232. },
  233. error: function(xhr, ajaxOptions, thrownError) {
  234. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  235. }
  236. });
  237. } else {
  238. $.ajax({
  239. url: 'index.php?route=checkout/shipping_address',
  240. dataType: 'html',
  241. success: function(html) {
  242. $('#shipping-address .checkout-content').html(html);
  243. $('#payment-address .checkout-content').slideUp('slow');
  244. $('#shipping-address .checkout-content').slideDown('slow');
  245. $('#checkout .checkout-heading a').remove();
  246. $('#payment-address .checkout-heading a').remove();
  247. $('#shipping-address .checkout-heading a').remove();
  248. $('#shipping-method .checkout-heading a').remove();
  249. $('#payment-method .checkout-heading a').remove();
  250. $('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  251. },
  252. error: function(xhr, ajaxOptions, thrownError) {
  253. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  254. }
  255. });
  256. }
  257. <?php } else { ?>
  258. $.ajax({
  259. url: 'index.php?route=checkout/payment_method',
  260. dataType: 'html',
  261. success: function(html) {
  262. $('#payment-method .checkout-content').html(html);
  263. $('#payment-address .checkout-content').slideUp('slow');
  264. $('#payment-method .checkout-content').slideDown('slow');
  265. $('#checkout .checkout-heading a').remove();
  266. $('#payment-address .checkout-heading a').remove();
  267. $('#payment-method .checkout-heading a').remove();
  268. $('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  269. },
  270. error: function(xhr, ajaxOptions, thrownError) {
  271. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  272. }
  273. });
  274. <?php } ?>
  275. $.ajax({
  276. url: 'index.php?route=checkout/payment_address',
  277. dataType: 'html',
  278. success: function(html) {
  279. $('#payment-address .checkout-content').html(html);
  280. $('#payment-address .checkout-heading span').html('<?php echo $text_checkout_payment_address; ?>');
  281. },
  282. error: function(xhr, ajaxOptions, thrownError) {
  283. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  284. }
  285. });
  286. }
  287. },
  288. error: function(xhr, ajaxOptions, thrownError) {
  289. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  290. }
  291. });
  292. });
  293. // Payment Address
  294. $('#button-payment-address').live('click', function() {
  295. $.ajax({
  296. url: 'index.php?route=checkout/payment_address/validate',
  297. type: 'post',
  298. data: $('#payment-address input[type=\'text\'], #payment-address input[type=\'password\'], #payment-address input[type=\'checkbox\']:checked, #payment-address input[type=\'radio\']:checked, #payment-address input[type=\'hidden\'], #payment-address select'),
  299. dataType: 'json',
  300. beforeSend: function() {
  301. $('#button-payment-address').attr('disabled', true);
  302. $('#button-payment-address').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
  303. },
  304. complete: function() {
  305. $('#button-payment-address').attr('disabled', false);
  306. $('.wait').remove();
  307. },
  308. success: function(json) {
  309. $('.warning, .error').remove();
  310. if (json['redirect']) {
  311. location = json['redirect'];
  312. } else if (json['error']) {
  313. if (json['error']['warning']) {
  314. $('#payment-address .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
  315. $('.warning').fadeIn('slow');
  316. }
  317. if (json['error']['firstname']) {
  318. $('#payment-address input[name=\'firstname\']').after('<span class="error">' + json['error']['firstname'] + '</span>');
  319. }
  320. if (json['error']['lastname']) {
  321. $('#payment-address input[name=\'lastname\']').after('<span class="error">' + json['error']['lastname'] + '</span>');
  322. }
  323. if (json['error']['telephone']) {
  324. $('#payment-address input[name=\'telephone\']').after('<span class="error">' + json['error']['telephone'] + '</span>');
  325. }
  326. if (json['error']['company_id']) {
  327. $('#payment-address input[name=\'company_id\']').after('<span class="error">' + json['error']['company_id'] + '</span>');
  328. }
  329. if (json['error']['tax_id']) {
  330. $('#payment-address input[name=\'tax_id\']').after('<span class="error">' + json['error']['tax_id'] + '</span>');
  331. }
  332. if (json['error']['address_1']) {
  333. $('#payment-address input[name=\'address_1\']').after('<span class="error">' + json['error']['address_1'] + '</span>');
  334. }
  335. if (json['error']['city']) {
  336. $('#payment-address input[name=\'city\']').after('<span class="error">' + json['error']['city'] + '</span>');
  337. }
  338. if (json['error']['postcode']) {
  339. $('#payment-address input[name=\'postcode\']').after('<span class="error">' + json['error']['postcode'] + '</span>');
  340. }
  341. if (json['error']['country']) {
  342. $('#payment-address select[name=\'country_id\']').after('<span class="error">' + json['error']['country'] + '</span>');
  343. }
  344. if (json['error']['zone']) {
  345. $('#payment-address select[name=\'zone_id\']').after('<span class="error">' + json['error']['zone'] + '</span>');
  346. }
  347. } else {
  348. <?php if ($shipping_required) { ?>
  349. $.ajax({
  350. url: 'index.php?route=checkout/shipping_address',
  351. dataType: 'html',
  352. success: function(html) {
  353. $('#shipping-address .checkout-content').html(html);
  354. $('#payment-address .checkout-content').slideUp('slow');
  355. $('#shipping-address .checkout-content').slideDown('slow');
  356. $('#payment-address .checkout-heading a').remove();
  357. $('#shipping-address .checkout-heading a').remove();
  358. $('#shipping-method .checkout-heading a').remove();
  359. $('#payment-method .checkout-heading a').remove();
  360. $('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  361. },
  362. error: function(xhr, ajaxOptions, thrownError) {
  363. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  364. }
  365. });
  366. <?php } else { ?>
  367. $.ajax({
  368. url: 'index.php?route=checkout/payment_method',
  369. dataType: 'html',
  370. success: function(html) {
  371. $('#payment-method .checkout-content').html(html);
  372. $('#payment-address .checkout-content').slideUp('slow');
  373. $('#payment-method .checkout-content').slideDown('slow');
  374. $('#payment-address .checkout-heading a').remove();
  375. $('#payment-method .checkout-heading a').remove();
  376. $('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  377. },
  378. error: function(xhr, ajaxOptions, thrownError) {
  379. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  380. }
  381. });
  382. <?php } ?>
  383. $.ajax({
  384. url: 'index.php?route=checkout/payment_address',
  385. dataType: 'html',
  386. success: function(html) {
  387. $('#payment-address .checkout-content').html(html);
  388. },
  389. error: function(xhr, ajaxOptions, thrownError) {
  390. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  391. }
  392. });
  393. }
  394. },
  395. error: function(xhr, ajaxOptions, thrownError) {
  396. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  397. }
  398. });
  399. });
  400. // Shipping Address
  401. $('#button-shipping-address').live('click', function() {
  402. $.ajax({
  403. url: 'index.php?route=checkout/shipping_address/validate',
  404. type: 'post',
  405. data: $('#shipping-address input[type=\'text\'], #shipping-address input[type=\'password\'], #shipping-address input[type=\'checkbox\']:checked, #shipping-address input[type=\'radio\']:checked, #shipping-address select'),
  406. dataType: 'json',
  407. beforeSend: function() {
  408. $('#button-shipping-address').attr('disabled', true);
  409. $('#button-shipping-address').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
  410. },
  411. complete: function() {
  412. $('#button-shipping-address').attr('disabled', false);
  413. $('.wait').remove();
  414. },
  415. success: function(json) {
  416. $('.warning, .error').remove();
  417. if (json['redirect']) {
  418. location = json['redirect'];
  419. } else if (json['error']) {
  420. if (json['error']['warning']) {
  421. $('#shipping-address .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
  422. $('.warning').fadeIn('slow');
  423. }
  424. if (json['error']['firstname']) {
  425. $('#shipping-address input[name=\'firstname\']').after('<span class="error">' + json['error']['firstname'] + '</span>');
  426. }
  427. if (json['error']['lastname']) {
  428. $('#shipping-address input[name=\'lastname\']').after('<span class="error">' + json['error']['lastname'] + '</span>');
  429. }
  430. if (json['error']['email']) {
  431. $('#shipping-address input[name=\'email\']').after('<span class="error">' + json['error']['email'] + '</span>');
  432. }
  433. if (json['error']['telephone']) {
  434. $('#shipping-address input[name=\'telephone\']').after('<span class="error">' + json['error']['telephone'] + '</span>');
  435. }
  436. if (json['error']['address_1']) {
  437. $('#shipping-address input[name=\'address_1\']').after('<span class="error">' + json['error']['address_1'] + '</span>');
  438. }
  439. if (json['error']['city']) {
  440. $('#shipping-address input[name=\'city\']').after('<span class="error">' + json['error']['city'] + '</span>');
  441. }
  442. if (json['error']['postcode']) {
  443. $('#shipping-address input[name=\'postcode\']').after('<span class="error">' + json['error']['postcode'] + '</span>');
  444. }
  445. if (json['error']['country']) {
  446. $('#shipping-address select[name=\'country_id\']').after('<span class="error">' + json['error']['country'] + '</span>');
  447. }
  448. if (json['error']['zone']) {
  449. $('#shipping-address select[name=\'zone_id\']').after('<span class="error">' + json['error']['zone'] + '</span>');
  450. }
  451. } else {
  452. $.ajax({
  453. url: 'index.php?route=checkout/shipping_method',
  454. dataType: 'html',
  455. success: function(html) {
  456. $('#shipping-method .checkout-content').html(html);
  457. $('#shipping-address .checkout-content').slideUp('slow');
  458. $('#shipping-method .checkout-content').slideDown('slow');
  459. $('#shipping-address .checkout-heading a').remove();
  460. $('#shipping-method .checkout-heading a').remove();
  461. $('#payment-method .checkout-heading a').remove();
  462. $('#shipping-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  463. $.ajax({
  464. url: 'index.php?route=checkout/shipping_address',
  465. dataType: 'html',
  466. success: function(html) {
  467. $('#shipping-address .checkout-content').html(html);
  468. },
  469. error: function(xhr, ajaxOptions, thrownError) {
  470. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  471. }
  472. });
  473. },
  474. error: function(xhr, ajaxOptions, thrownError) {
  475. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  476. }
  477. });
  478. $.ajax({
  479. url: 'index.php?route=checkout/payment_address',
  480. dataType: 'html',
  481. success: function(html) {
  482. $('#payment-address .checkout-content').html(html);
  483. },
  484. error: function(xhr, ajaxOptions, thrownError) {
  485. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  486. }
  487. });
  488. }
  489. },
  490. error: function(xhr, ajaxOptions, thrownError) {
  491. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  492. }
  493. });
  494. });
  495. // Guest
  496. $('#button-guest').live('click', function() {
  497. $.ajax({
  498. url: 'index.php?route=checkout/guest/validate',
  499. type: 'post',
  500. data: $('#payment-address input[type=\'text\'], #payment-address input[type=\'checkbox\']:checked, #payment-address input[type=\'radio\']:checked, #payment-address input[type=\'hidden\'], #payment-address select'),
  501. dataType: 'json',
  502. beforeSend: function() {
  503. $('#button-guest').attr('disabled', true);
  504. $('#button-guest').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
  505. },
  506. complete: function() {
  507. $('#button-guest').attr('disabled', false);
  508. $('.wait').remove();
  509. },
  510. success: function(json) {
  511. $('.warning, .error').remove();
  512. if (json['redirect']) {
  513. location = json['redirect'];
  514. } else if (json['error']) {
  515. if (json['error']['warning']) {
  516. $('#payment-address .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
  517. $('.warning').fadeIn('slow');
  518. }
  519. if (json['error']['firstname']) {
  520. $('#payment-address input[name=\'firstname\'] + br').after('<span class="error">' + json['error']['firstname'] + '</span>');
  521. }
  522. if (json['error']['lastname']) {
  523. $('#payment-address input[name=\'lastname\'] + br').after('<span class="error">' + json['error']['lastname'] + '</span>');
  524. }
  525. if (json['error']['email']) {
  526. $('#payment-address input[name=\'email\'] + br').after('<span class="error">' + json['error']['email'] + '</span>');
  527. }
  528. if (json['error']['telephone']) {
  529. $('#payment-address input[name=\'telephone\'] + br').after('<span class="error">' + json['error']['telephone'] + '</span>');
  530. }
  531. if (json['error']['company_id']) {
  532. $('#payment-address input[name=\'company_id\'] + br').after('<span class="error">' + json['error']['company_id'] + '</span>');
  533. }
  534. if (json['error']['tax_id']) {
  535. $('#payment-address input[name=\'tax_id\'] + br').after('<span class="error">' + json['error']['tax_id'] + '</span>');
  536. }
  537. if (json['error']['address_1']) {
  538. $('#payment-address input[name=\'address_1\'] + br').after('<span class="error">' + json['error']['address_1'] + '</span>');
  539. }
  540. if (json['error']['city']) {
  541. $('#payment-address input[name=\'city\'] + br').after('<span class="error">' + json['error']['city'] + '</span>');
  542. }
  543. if (json['error']['postcode']) {
  544. $('#payment-address input[name=\'postcode\'] + br').after('<span class="error">' + json['error']['postcode'] + '</span>');
  545. }
  546. if (json['error']['country']) {
  547. $('#payment-address select[name=\'country_id\'] + br').after('<span class="error">' + json['error']['country'] + '</span>');
  548. }
  549. if (json['error']['zone']) {
  550. $('#payment-address select[name=\'zone_id\'] + br').after('<span class="error">' + json['error']['zone'] + '</span>');
  551. }
  552. } else {
  553. <?php if ($shipping_required) { ?>
  554. var shipping_address = $('#payment-address input[name=\'shipping_address\']:checked').attr('value');
  555. if (shipping_address) {
  556. $.ajax({
  557. url: 'index.php?route=checkout/shipping_method',
  558. dataType: 'html',
  559. success: function(html) {
  560. $('#shipping-method .checkout-content').html(html);
  561. $('#payment-address .checkout-content').slideUp('slow');
  562. $('#shipping-method .checkout-content').slideDown('slow');
  563. $('#payment-address .checkout-heading a').remove();
  564. $('#shipping-address .checkout-heading a').remove();
  565. $('#shipping-method .checkout-heading a').remove();
  566. $('#payment-method .checkout-heading a').remove();
  567. $('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  568. $('#shipping-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  569. $.ajax({
  570. url: 'index.php?route=checkout/guest_shipping',
  571. dataType: 'html',
  572. success: function(html) {
  573. $('#shipping-address .checkout-content').html(html);
  574. },
  575. error: function(xhr, ajaxOptions, thrownError) {
  576. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  577. }
  578. });
  579. },
  580. error: function(xhr, ajaxOptions, thrownError) {
  581. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  582. }
  583. });
  584. } else {
  585. $.ajax({
  586. url: 'index.php?route=checkout/guest_shipping',
  587. dataType: 'html',
  588. success: function(html) {
  589. $('#shipping-address .checkout-content').html(html);
  590. $('#payment-address .checkout-content').slideUp('slow');
  591. $('#shipping-address .checkout-content').slideDown('slow');
  592. $('#payment-address .checkout-heading a').remove();
  593. $('#shipping-address .checkout-heading a').remove();
  594. $('#shipping-method .checkout-heading a').remove();
  595. $('#payment-method .checkout-heading a').remove();
  596. $('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  597. },
  598. error: function(xhr, ajaxOptions, thrownError) {
  599. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  600. }
  601. });
  602. }
  603. <?php } else { ?>
  604. $.ajax({
  605. url: 'index.php?route=checkout/payment_method',
  606. dataType: 'html',
  607. success: function(html) {
  608. $('#payment-method .checkout-content').html(html);
  609. $('#payment-address .checkout-content').slideUp('slow');
  610. $('#payment-method .checkout-content').slideDown('slow');
  611. $('#payment-address .checkout-heading a').remove();
  612. $('#payment-method .checkout-heading a').remove();
  613. $('#payment-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  614. },
  615. error: function(xhr, ajaxOptions, thrownError) {
  616. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  617. }
  618. });
  619. <?php } ?>
  620. }
  621. },
  622. error: function(xhr, ajaxOptions, thrownError) {
  623. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  624. }
  625. });
  626. });
  627. // Guest Shipping
  628. $('#button-guest-shipping').live('click', function() {
  629. $.ajax({
  630. url: 'index.php?route=checkout/guest_shipping/validate',
  631. type: 'post',
  632. data: $('#shipping-address input[type=\'text\'], #shipping-address select'),
  633. dataType: 'json',
  634. beforeSend: function() {
  635. $('#button-guest-shipping').attr('disabled', true);
  636. $('#button-guest-shipping').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
  637. },
  638. complete: function() {
  639. $('#button-guest-shipping').attr('disabled', false);
  640. $('.wait').remove();
  641. },
  642. success: function(json) {
  643. $('.warning, .error').remove();
  644. if (json['redirect']) {
  645. location = json['redirect'];
  646. } else if (json['error']) {
  647. if (json['error']['warning']) {
  648. $('#shipping-address .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
  649. $('.warning').fadeIn('slow');
  650. }
  651. if (json['error']['firstname']) {
  652. $('#shipping-address input[name=\'firstname\']').after('<span class="error">' + json['error']['firstname'] + '</span>');
  653. }
  654. if (json['error']['lastname']) {
  655. $('#shipping-address input[name=\'lastname\']').after('<span class="error">' + json['error']['lastname'] + '</span>');
  656. }
  657. if (json['error']['address_1']) {
  658. $('#shipping-address input[name=\'address_1\']').after('<span class="error">' + json['error']['address_1'] + '</span>');
  659. }
  660. if (json['error']['city']) {
  661. $('#shipping-address input[name=\'city\']').after('<span class="error">' + json['error']['city'] + '</span>');
  662. }
  663. if (json['error']['postcode']) {
  664. $('#shipping-address input[name=\'postcode\']').after('<span class="error">' + json['error']['postcode'] + '</span>');
  665. }
  666. if (json['error']['country']) {
  667. $('#shipping-address select[name=\'country_id\']').after('<span class="error">' + json['error']['country'] + '</span>');
  668. }
  669. if (json['error']['zone']) {
  670. $('#shipping-address select[name=\'zone_id\']').after('<span class="error">' + json['error']['zone'] + '</span>');
  671. }
  672. } else {
  673. $.ajax({
  674. url: 'index.php?route=checkout/shipping_method',
  675. dataType: 'html',
  676. success: function(html) {
  677. $('#shipping-method .checkout-content').html(html);
  678. $('#shipping-address .checkout-content').slideUp('slow');
  679. $('#shipping-method .checkout-content').slideDown('slow');
  680. $('#shipping-address .checkout-heading a').remove();
  681. $('#shipping-method .checkout-heading a').remove();
  682. $('#payment-method .checkout-heading a').remove();
  683. $('#shipping-address .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  684. },
  685. error: function(xhr, ajaxOptions, thrownError) {
  686. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  687. }
  688. });
  689. }
  690. },
  691. error: function(xhr, ajaxOptions, thrownError) {
  692. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  693. }
  694. });
  695. });
  696. $('#button-shipping-method').live('click', function() {
  697. $.ajax({
  698. url: 'index.php?route=checkout/shipping_method/validate',
  699. type: 'post',
  700. data: $('#shipping-method input[type=\'radio\']:checked, #shipping-method textarea'),
  701. dataType: 'json',
  702. beforeSend: function() {
  703. $('#button-shipping-method').attr('disabled', true);
  704. $('#button-shipping-method').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
  705. },
  706. complete: function() {
  707. $('#button-shipping-method').attr('disabled', false);
  708. $('.wait').remove();
  709. },
  710. success: function(json) {
  711. $('.warning, .error').remove();
  712. if (json['redirect']) {
  713. location = json['redirect'];
  714. } else if (json['error']) {
  715. if (json['error']['warning']) {
  716. $('#shipping-method .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
  717. $('.warning').fadeIn('slow');
  718. }
  719. } else {
  720. $.ajax({
  721. url: 'index.php?route=checkout/payment_method',
  722. dataType: 'html',
  723. success: function(html) {
  724. $('#payment-method .checkout-content').html(html);
  725. $('#shipping-method .checkout-content').slideUp('slow');
  726. $('#payment-method .checkout-content').slideDown('slow');
  727. $('#shipping-method .checkout-heading a').remove();
  728. $('#payment-method .checkout-heading a').remove();
  729. $('#shipping-method .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  730. },
  731. error: function(xhr, ajaxOptions, thrownError) {
  732. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  733. }
  734. });
  735. }
  736. },
  737. error: function(xhr, ajaxOptions, thrownError) {
  738. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  739. }
  740. });
  741. });
  742. $('#button-payment-method').live('click', function() {
  743. $.ajax({
  744. url: 'index.php?route=checkout/payment_method/validate',
  745. type: 'post',
  746. data: $('#payment-method input[type=\'radio\']:checked, #payment-method input[type=\'checkbox\']:checked, #payment-method textarea'),
  747. dataType: 'json',
  748. beforeSend: function() {
  749. $('#button-payment-method').attr('disabled', true);
  750. $('#button-payment-method').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
  751. },
  752. complete: function() {
  753. $('#button-payment-method').attr('disabled', false);
  754. $('.wait').remove();
  755. },
  756. success: function(json) {
  757. $('.warning, .error').remove();
  758. if (json['redirect']) {
  759. location = json['redirect'];
  760. } else if (json['error']) {
  761. if (json['error']['warning']) {
  762. $('#payment-method .checkout-content').prepend('<div class="warning" style="display: none;">' + json['error']['warning'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
  763. $('.warning').fadeIn('slow');
  764. }
  765. } else {
  766. $.ajax({
  767. url: 'index.php?route=checkout/confirm',
  768. dataType: 'html',
  769. success: function(html) {
  770. $('#confirm .checkout-content').html(html);
  771. $('#payment-method .checkout-content').slideUp('slow');
  772. $('#confirm .checkout-content').slideDown('slow');
  773. $('#payment-method .checkout-heading a').remove();
  774. $('#payment-method .checkout-heading').append('<a><?php echo $text_modify; ?></a>');
  775. },
  776. error: function(xhr, ajaxOptions, thrownError) {
  777. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  778. }
  779. });
  780. }
  781. },
  782. error: function(xhr, ajaxOptions, thrownError) {
  783. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  784. }
  785. });
  786. });
  787. //--></script>
  788. <?php echo $footer; ?>