<?xml version="1.0" encoding="utf-8"?>
 
<modification>
  <name>Login With Whatsapp OTP 3.0.X</name>
  <code>login_whatsapp_OTP</code>
  <version>3.0</version>
  <author>dyisol</author>
  <link>http://www.dyisol.com></link>

  <!-- Admin panel menu setting -->
  
  <file path="admin/view/template/common/header.twig">
    <operation>
      <search><![CDATA[<link type="text/css" href="view/stylesheet/stylesheet.css" rel="stylesheet" media="screen" />]]></search>
		<add position="after"><![CDATA[
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/css/intlTelInput.css"/>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/intlTelInput.min.js"></script>
		]]>
		</add>
    </operation>
  </file>
  
  <file path="admin/model/customer/customer.php">
		<operation>
		  <search><![CDATA[	$this->db->query("UPDATE " . DB_PREFIX . "customer SET customer_group_id = '" . (int)$data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : json_encode(array())) . "', newsletter = '" . (int)$data['newsletter'] . "', status = '" . (int)$data['status'] . "', safe = '" . (int)$data['safe'] . "' WHERE customer_id = '" . (int)$customer_id . "'");
]]></search>
			<add position="replace"><![CDATA[
			$this->db->query("UPDATE " . DB_PREFIX . "customer SET customer_group_id = '" . (int)$data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', wa = '" . $this->db->escape($data['whatsapp']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : json_encode(array())) . "', newsletter = '" . (int)$data['newsletter'] . "', status = '" . (int)$data['status'] . "', safe = '" . (int)$data['safe'] . "' WHERE customer_id = '" . (int)$customer_id . "'");

			]]>
			</add>
		</operation>
	</file>
	
	<file path="admin/model/customer/customer.php">
		<operation>
		  <search><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "customer SET customer_group_id = '" . (int)$data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : json_encode(array())) . "', newsletter = '" . (int)$data['newsletter'] . "', salt = '" . $this->db->escape($salt = token(9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "', status = '" . (int)$data['status'] . "', safe = '" . (int)$data['safe'] . "', date_added = NOW()");
]]></search>
			<add position="replace"><![CDATA[
			$this->db->query("INSERT INTO " . DB_PREFIX . "customer SET customer_group_id = '" . (int)$data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', wa = '" . $this->db->escape($data['whatsapp']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : json_encode(array())) . "', newsletter = '" . (int)$data['newsletter'] . "', salt = '" . $this->db->escape($salt = token(9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "', status = '" . (int)$data['status'] . "', safe = '" . (int)$data['safe'] . "', date_added = NOW()");

			]]>
			</add>
		</operation>
	</file>
  
  <file path="admin/language/en-gb/customer/customer.php">
	<operation>
		<search><![CDATA[$_['entry_date_added']          = 'Date Added';]]>
		</search>
		<add position="after"><![CDATA[
			$_['entry_whatsapp_phone']      = 'Whatsapp Number';		
		]]>
		</add>
    </operation>
  </file>
  
  <file path="admin/view/template/customer/customer_form.twig">
	<operation>
		<search><![CDATA[<div class="text-danger">{{ error_telephone }}</div>]]>
		</search>
		<add position="after" offset="2"><![CDATA[
			<div class="form-group required">
			<label class="col-sm-2 control-label" for="input-whatsapp-telephone">{{ entry_whatsapp_phone }}</label>
			<div class="col-sm-10">
				<input type="tel" name="whatsapp_phone" value="{{ whatsapp_phone }}" id="input-wa-number" class="form-control" />
				<input type="hidden" name="whatsapp" />
				<span id="valid-msg" class="hide" style="color:green;">✓ Valid</span>
				<span id="error-msg" class="hide" style="color:red;"></span>
			  {% if error_whatsapp %}
			  <div class="text-danger">{{ error_whatsapp }}</div>
			  {% endif %} </div>
			</div>
		]]>
		</add>
    </operation>
  </file>
  
  <file path="admin/controller/customer/customer.php">
	<operation>
		<search><![CDATA[if (isset($this->request->post['telephone'])) {]]>
		</search>
		<add position="before"><![CDATA[
			if (isset($this->request->post['whatsapp_phone'])) {
				$data['whatsapp_phone'] = $this->request->post['whatsapp_phone'];
			} elseif (!empty($customer_info)) {
				$data['whatsapp_phone'] = $customer_info['wa'];
			} else {
				$data['whatsapp_phone'] = '';
			}
		]]>
		</add>
    </operation>
  </file>
  
  <file path="admin/view/template/customer/customer_form.twig">
	<operation>
		<search><![CDATA[{{ footer }}]]>
		</search>
		<add position="before"><![CDATA[
			<script>

			var input = document.querySelector("#input-wa-number"),
			errorMsg = document.querySelector("#error-msg"),
			validMsg = document.querySelector("#valid-msg");

			// Error messages based on the code returned from getValidationError
			var errorMap = [ "Invalid number", "Invalid country code", "Too short", "Too long", "Invalid number"];

			// Initialise plugin
			var phone_number = window.intlTelInput(input, {
				initialCountry: "in",  // ? Default country set to India
				separateDialCode: true, // optional: shows +91 separately
				utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js",
			});
			var reset = function() {
				input.classList.remove("error");
				errorMsg.innerHTML = "";
				errorMsg.classList.add("hide");
				validMsg.classList.add("hide");
			};

			// Validate on blur event
			input.addEventListener('blur', function() {
				reset();
				if(input.value.trim()){
					if(phone_number.isValidNumber()){
						validMsg.classList.remove("hide");
					}else{
						input.classList.add("error");
						var errorCode = phone_number.getValidationError();
						errorMsg.innerHTML = errorMap[errorCode];
						errorMsg.classList.remove("hide");
					}
				}
				var full_number = phone_number.getNumber(intlTelInputUtils.numberFormat.E164);
				$("input[name='whatsapp'").val(full_number);
			});

			// Reset on keyup/change event
			input.addEventListener('change', reset);
			input.addEventListener('keyup', reset);
		</script>
		]]>
		</add>
    </operation>
  </file>
  
  <!-- Catalog  -->
  
  <file path="catalog/view/theme/*/template/common/header.twig">
    <operation>
      <search><![CDATA[</head>]]></search>
		<add position="before"><![CDATA[
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/css/intlTelInput.css"/>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/intlTelInput.min.js"></script>
		]]>
		</add>
    </operation>
  </file>
  
  <file path="catalog/view/theme/*/template/account/login.twig">
    <operation>
      <search><![CDATA[{{ footer }}]]></search>
		<add position="before"><![CDATA[
			<style>

			.center {
				position: fixed;
				top: 50%;
				left: 50%;
				transform: translate(-50%, -50%);
			}

			body .block-otp {
				margin-top: 170px;
				width: 500px;
				padding: 0 20px 0;
				background: #fff;
				box-shadow: 0 0 5px rgba(0,0,0,0.5);
				text-align: left;
			}

			.otp{
			  display:inline-block;
			  width:60px;
			  height:60px;
			  text-align:center;
			  
			}

			#loginpmyInput{
				
			   display:none;
			}
			input[class="otp"]
			{
				font-size:36px;
			}

			.flex-parent {
			  display: flex;
			}

			.jc-center {
			  justify-content: center;
			}

			button.margin-right {
			  margin-right: 20px;
			}


			body .block-otp .tt_popup_login {
				height: 36px;
				border-bottom: 3px solid #ea3a3c;
				background-color: #242424;
				margin: 0 -20px;
			}
			body .block-otp .tt_popup_login strong {
				line-height: 37px;
				display: inline-block;
				padding-left: 55px;
				text-transform: uppercase;
				font-size: 133.33%;
				color: #fff;
				background-image: url(../images/icon-login-popup.png);
				background-repeat: no-repeat;
				background-position: 10px center;
				position: relative;
				padding-right: 10px;
				top: -4px;
				background-color: #ea3a3c;
				font-weight: 600;
			}
			body .block-otp .tt_popup_login strong:before {
				content: "";
				display: inline-block;
				position: absolute;
				right: -20px;
				top: 0;
				width: 0;
				height: 0;
				border-right: 20px solid transparent;
				border-bottom: 37px solid #ea3a3c;
			}
			body .block-otp .otp-content {
				padding-top: 20px;
				padding-bottom: 20px;
				font-weight: normal;
			}
			body .block-otp .otp-content .col-reg {
				width: 100%;
				min-height: 188px;
				text-align:center;
			}
			body .block-otp .otp-content .col-reg.registered-account {
				padding-right: 30px;
				
			}
			body .block-otp .otp-content {
				padding-top: 20px;
				padding-bottom: 20px;
				font-weight: normal;
			}

			.btnverify{
				border-bottom-left-radius: 5px !important;
				border-top-left-radius: 5px;
				border-bottom-right-radius: 0px;
				border-top-right-radius: 0px;
			}
			@media only screen and (max-width: 768px){

			body .block-otp {
				margin-top: 170px;
				width: 320px;
				padding: 0 20px 0;
				background: #fff;
				box-shadow: 0 0 5px rgba(0,0,0,0.5);
				text-align: center;
				margin-left: auto;
				margin-right: auto;
			}

			.otp{
			  display: none;
			}

			#loginpmyInput{
				
				display:block;
				text-align: center;
				width: 100%;
				font-size:26px;
			}

		}
		</style>

		<script>
			$(document).ready(function() {
				$('#btn_wa_login_verify').prop('disabled', true);
			});
			
			var input = document.querySelector("#input-wa-number"),
			errorMsg = document.querySelector("#error-msg"),
			validMsg = document.querySelector("#valid-msg");

			// Error messages based on the code returned from getValidationError
			var errorMap = [ "Invalid number", "Invalid country code", "Too short", "Too long", "Invalid number"];

			// Initialise plugin
			var phone_number = window.intlTelInput(input, {
				initialCountry: "in",  // ? Default country set to India
				separateDialCode: true, // optional: shows +91 separately
				utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js",
			});

			var reset = function() {
				input.classList.remove("error");
				errorMsg.innerHTML = "";
				errorMsg.classList.add("hide");
				validMsg.classList.add("hide");
			};

			// Validate on blur event
			input.addEventListener('blur', function() {
				reset();
				if(input.value.trim()){
					if(phone_number.isValidNumber()){
						validMsg.classList.remove("hide");
						$('#btn_wa_login_verify').prop('disabled', false);
					}else{
						input.classList.add("error");
						var errorCode = phone_number.getValidationError();
						errorMsg.innerHTML = errorMap[errorCode];
						errorMsg.classList.remove("hide");
					}
				}
				var full_number = phone_number.getNumber(intlTelInputUtils.numberFormat.E164);
				$("input[name='int_number'").val(full_number);
			});

			// Reset on keyup/change event
			input.addEventListener('change', reset);
			input.addEventListener('keyup', reset);
		   
		</script>

		<script>
		var counter = 1;


		$("#wa_login").hide();

		$(document).ready(function(){

			$(".otp").keyup(function () {
				if (this.value.length == this.maxLength) {
					$(this).next('.otp').focus(); 
				}
			});
			
			$("#btn_wa_login").on("click", function(){
				$("#wa_login").show();
			});
			
			$('#otp').on('shown.bs.modal', function() {
				$('#otp1').focus();   
			});
			
			$(document).delegate('#btn_wa_login_verify', 'click', function() {
			
				var wa_number = $("#input-wa-number").val();
				//process();
				if (wa_number == ''){
					$(".error").html('<span style="color:red">Please Enter the Whatsapp Number.</span>');
				}else{
					$.ajax({
						url: 'index.php?route=extension/module/login_wa_otp/checkNum_sendOTP',
						type: 'post',
						data: $('input[name=\'wa_number\'], input[name=\'int_number\']'),
						dataType: 'json',
						beforeSend: function() {
							$("#loader").show();
						},
						complete: function() {
							$("#loader").hide();
							
						},
						success: function(json) {
							if (json['error']) {
								$('.error').html('<div class="text-danger errordiv">'+ json['error'] + '</div>');
							}
							if (json['success']) {
								loginpcountdown();
								$('#otp').modal('show');
								//alert(json['otpcode']);
								
							}
						}
					});
				}
			});
			
			$("#confirm").click(function(e) {
				e.preventDefault();
				if($(window).width() <= 768)
				{
					
					if ($('#loginpmyInput').val() == ''){
						$("#otp_error").fadeIn(0).html('Please Enter OTP').fadeOut(5000);    
						//$("#overlay").fadeOut(300);
					}else{
						loginpdoneTyping();    
					}
					
				   
				} else {
			
					var result = $('#otp1').val() + $('#otp2').val() + $('#otp3').val() + $('#otp4').val() + $('#otp5').val() + $('#otp6').val();
					$('#loginpmyInput').val(result);   
					if ($('#loginpmyInput').val() == ''){
						$("#otp_error").fadeIn(0).html('Please Enter OTP').fadeOut(5000);  
						//$("#overlay").fadeOut(300);
					}else{
						loginpdoneTyping();    
					}
					
				}    
			});
			
			function loginpdoneTyping () {
			
				$.ajax({
					url: 'index.php?route=extension/module/login_wa_otp/addotp',
					type: 'post',
					data: $('input[name=\'otp\'], input[name=\'wa_number\']'),
					dataType: 'json',
					success: function(json) {
						if (json['error']) {
							//$("#overlay").fadeOut(300);
							$("#otp_error").fadeIn(0).html(json['error']).fadeOut(5000);
						}
						if (json['success']) {
							$("#reverify").removeClass("btn btn-danger").addClass("btn btn-success");
							 setTimeout(function(){
								$("#overlay").fadeOut(500);
							  },500);
							 $('#otp').modal('hide');
							 if(json['redirect']){
								location=json['redirect'];
							}
						}
					}
				});
				
			}
			
			function loginpcountdown() {
				var seconds = 5;
				function tick() {
					//var counter = document.getElementById("recounter");
					seconds--;
					rem_time = (seconds < 10 ? "0" : "") + String(seconds);
					$("#recounter").html(rem_time);
					if( seconds > 0 ) {
						setTimeout(tick, 1000);
					} 
					if( seconds == 0 ) {
						$("#recounter").html("");
						$("#resend").css("display","block");
					} 
				}
				tick();
			}
			
			$('#resend').on('click', function() {
				resendotp();
			});
			
			function resendotp(){
			
				var phone = $("#input-wa-number").val(); 
				if (counter > 2 && phone == getCookie('phone') ){
					$("#otp_error").fadeIn(0).html('{{ error_otp_multiple_attempt }}').fadeOut(8000);  
				}else {
					
					$.ajax({
						url: 'index.php?route=extension/module/login_wa_otp/resendotp',
						type: 'post',
						data: $('input[name=\'wa_number\'], input[name=\'int_number\']'),
						dataType: 'json',
						beforeSend: function() {
							$("#loader").show();
						},
						complete: function() {
							$("#loader").hide();
							
						},
						success: function(json) {

							if (json['success']) {
							
								$("#resend").css("display","none");
								$("#otp_resend").fadeIn(0).html(json['success']).fadeOut(5000);
								
								loginpcountdown();
								counter++;
								if (counter > 2){
									var cookie_phone = $("#input-wa-number").val(); 
									var now = new Date();
									now.setTime(now.getTime() + 1 * 3600 * 1000);
									document.cookie = 'phone=' + cookie_phone + '; expires=' + now.toUTCString() + '; path=/';
								}
							}
						}
					});
				}
			}
			
			
			function setCookie(cname, cvalue) {
				const d = new Date();
				d.setTime(d.getTime() + 1 * 60 * 1000);
				let expires = "expires="+ d.toUTCString();
				document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
			}
			
			function getCookie(cname) {
				let name = cname + "=";
				let decodedCookie = decodeURIComponent(document.cookie);
				let ca = decodedCookie.split(';');
				for(let i = 0; i <ca.length; i++) {
					let c = ca[i];
					while (c.charAt(0) == ' ') {
						c = c.substring(1);
					}
					if (c.indexOf(name) == 0) {
						return c.substring(name.length, c.length);
					}
				} 
				return "";
			}
			
			
		});

		</script>
		]]>
		</add>
    </operation>
  </file>
  
  <file path="catalog/view/theme/*/template/account/login.twig">
    <operation>
      <search><![CDATA[<button type="submit" class="btn btn-primary" data-loading-text="<span>{{ button_login }}</span>"><span>{{ button_login }}</span></button>]]></search>
		<add position="after"><![CDATA[
			<button type="button" id="btn_wa_login" class="btn btn-primary" style="top:3%">Login with OTP</button>
			  
			  <div class="row" id="wa_login" style="margin-top:2%;">
					<div style="display:inline-block;">
						<input type="tel" name="wa_number" id="input-wa-number" class="form-control" />
						<input type="hidden" name="int_number" />
						<span id="valid-msg" class="hide" style="color:green;">✓ Valid</span>
						<span id="error-msg" class="hide" style="color:red;"></span>
					</div>
					<div class="col" style="display:inline-block;">				
						<button type="button" id="btn_wa_login_verify" class="btn btn-primary">Verify</button>
					</div>	
					<div class="error"></div>
					<div class="msg"></div>
			  </div>
				<div class="center">
					<div class="loader">
						<img src="./image/catalog/loader.gif" id="loader" style="display:none;"><br> 
					</div>
				</div> 
				
				<div class="modal fade in" id="otp" tabindex="-1" role="dialog" aria-labelledby="popupotp" aria-hidden="true">
					<div class="modal-dialog block-otp">
						<div class="tt_popup_login"><strong>{{ heading_otptitle }}</strong></div>
						<div id="input-msg" style="padding-top:30px;"> </div>
						<div class="otp-content">
							<div id="input" style="text-align:center;">
								<input name="otp" type="tel"  maxlength="6" id="loginpmyInput" autofocus>
								<div class="otp-content">
										<input id="otp1" name="otp1" class="otp" type="text" maxlength="1"  >
										<input id="otp2" name="otp2" class="otp" type="text" maxlength="1"  >
										<input id="otp3" name="otp3" class="otp" type="text" maxlength="1"  >
										<input id="otp4" name="otp4" class="otp" type="text" maxlength="1"  >
										<input id="otp5" name="otp5" class="otp" type="text" maxlength="1"  > 
										<input id="otp6" name="otp6" class="otp" type="text" maxlength="1" >
								</div>
								<div style="color:red; font-size:15px; font-weight: bold;" id="otp_error"></div>
								<div style="color:red; font-size:15px; font-weight: bold;" id="otp_resend_error"></div>
								<div style="color:green; font-size:15px; font-weight: bold;" id="otp_resend"></div>
							</div>
							
							<div style="text-align:center;margin-bottom:3%;">
								<div style="color:#229dcc;display: inline-block;font-size:14px;" id="recounter"></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<div style="display:inline-block;display:none;font-size:14px;cursor:pointer;" id="resend">
									<a name='resend_code'> <strong> {{ button_resend }} </strong> </a>
								</div>
							</div>
							
						   <div class="flex-parent jc-center">
							  <button type="submit" class="btn btn-secondary magenta" data-dismiss="modal">{{ button_cancel }}</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							  <button type="submit" class="btn btn-primary margin-right" id="confirm">{{ btn_confirm_otp }}</button>
							</div>
							<div style="clear:both;"></div>
						</div>
					</div>
				</div>
		]]>
		</add>
    </operation>
  </file>
  
  <file path="catalog/view/theme/*/template/account/register.twig">
	<operation>
		<search><![CDATA[<div id="error-telephone" class="text-danger invalid-feedback">{{ error_telephone }}</div>]]>
		</search>
		<add position="after" offset="2"><![CDATA[
			<div class="form-group required">
            <label class="col-sm-2 control-label" for="input-whatsapp-telephone">{{ entry_whatsapp_phone }}</label>
            <div class="col-sm-10">
				<input type="tel" name="whatsapp_phone" value="{{ whatsapp_phone }}" id="input-wa-number" class="form-control" />
				<input type="hidden" name="whatsapp" />
				<span id="valid-msg" class="hide" style="color:green;">✓ Valid</span>
				<span id="error-msg" class="hide" style="color:red;"></span>
              {% if error_telephone %}
              <div class="text-danger">{{ error_whatsapp }}</div>
              {% endif %} </div>
          </div>		
		]]>
		</add>
    </operation>
	
  </file>
  
  <file path="catalog/view/theme/*/template/account/register.twig">
	<operation>
		<search><![CDATA[{{ footer }}]]>
		</search>
		<add position="before"><![CDATA[
			<script>

			$(document).ready(function() {
				$('input[type="submit"]').prop('disabled', true);
			});
			var input = document.querySelector("#input-wa-number"),
			errorMsg = document.querySelector("#error-msg"),
			validMsg = document.querySelector("#valid-msg");

			// Error messages based on the code returned from getValidationError
			var errorMap = [ "Invalid number", "Invalid country code", "Too short", "Too long", "Invalid number"];

			// Initialise plugin
			var phone_number = window.intlTelInput(input, {
				initialCountry: "in",  // ? Default country set to India
				separateDialCode: true, // optional: shows +91 separately
				utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js",
			});

			var reset = function() {
				input.classList.remove("error");
				errorMsg.innerHTML = "";
				errorMsg.classList.add("hide");
				validMsg.classList.add("hide");
			};

			// Validate on blur event
			input.addEventListener('blur', function() {
				reset();
				if(input.value.trim()){
					if(phone_number.isValidNumber()){
						validMsg.classList.remove("hide");
						$('input[type="submit"]').prop('disabled', false);
					}else{
						input.classList.add("error");
						var errorCode = phone_number.getValidationError();
						errorMsg.innerHTML = errorMap[errorCode];
						errorMsg.classList.remove("hide");
					}
				}
				var full_number = phone_number.getNumber(intlTelInputUtils.numberFormat.E164);
				$("input[name='whatsapp'").val(full_number);
			});

			// Reset on keyup/change event
			input.addEventListener('change', reset);
			input.addEventListener('keyup', reset);
		   
		</script>
		]]>
		</add>
    </operation>
	
  </file>
  
  <file path="catalog/model/account/customer.php">
	<operation>
		<search><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "customer SET customer_group_id = '" . (int)$customer_group_id . "', store_id = '" . (int)$this->config->get('config_store_id') . "', language_id = '" . (int)$this->config->get('config_language_id') . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']['account']) ? json_encode($data['custom_field']['account']) : '') . "', salt = '" . $this->db->escape($salt = token(9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "', newsletter = '" . (isset($data['newsletter']) ? (int)$data['newsletter'] : 0) . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', status = '" . (int)!$customer_group_info['approval'] . "', date_added = NOW()");
]]>
		</search>
		<add position="replace"><![CDATA[
			$this->db->query("INSERT INTO " . DB_PREFIX . "customer SET customer_group_id = '" . (int)$customer_group_id . "', store_id = '" . (int)$this->config->get('config_store_id') . "', language_id = '" . (int)$this->config->get('config_language_id') . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', wa = '" . $this->db->escape($data['whatsapp']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']['account']) ? json_encode($data['custom_field']['account']) : '') . "', salt = '" . $this->db->escape($salt = token(9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "', newsletter = '" . (isset($data['newsletter']) ? (int)$data['newsletter'] : 0) . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', status = '" . (int)!$customer_group_info['approval'] . "', date_added = NOW()");
		]]>
		</add>
    </operation>
	
	<operation>
		<search><![CDATA[public function getCustomerByToken($token) {]]>
		</search>
		<add position="before"><![CDATA[
			public function getCustomerByWhatsapp($whatsapp) {
				$query = $this->db->query("SELECT customer_id, wa FROM `" . DB_PREFIX . "customer` WHERE telephone = '" . $this->db->escape($whatsapp)."'");

				return $query->row;
			}
		]]>
		</add>
    </operation>
	
  </file>
  
  <file path="catalog/controller/account/login.php">
	<operation>
		<search><![CDATA[$data['action'] = $this->url->link('account/login', '', true);]]>
		</search>
		<add position="before"><![CDATA[
			$data['button_confirm_otp'] = $this->language->get('button_confirm_otp');
		]]>
		</add>
    </operation>
  </file>
  
  <file path="catalog/language/en-gb/account/login.php">
	<operation>
		<search><![CDATA[$_['entry_password']               = 'Password';]]>
		</search>
		<add position="after"><![CDATA[
			$_['btn_confirm_otp'] = 'Confirm';
$_['heading_otptitle'] 		= 'OTP Verification';
$_['button_resend']  		= 'Resend OTP';
		]]>
		</add>
    </operation>
  </file>
  
  <file path="catalog/language/en-gb/account/register.php">
	<operation>
		<search><![CDATA[$_['entry_telephone']      = 'Telephone';]]>
		</search>
		<add position="after"><![CDATA[
$_['entry_whatsapp_phone']      = 'Whatsapp Number';
		]]>
		</add>
    </operation>
  </file>
  
</modification>
