// tamayouz.js jQuery(function ($) { 'use strict'; const section = $('#tamayouz_redemption_section'); const phoneInput = section.find('#tamayouz_phone'); const sendOtpBtn = section.find('#tamayouz_send_otp'); const verifyOtpBtn = section.find('#tamayouz_verify_otp'); const step1 = section.find('.tamayouz_step.step1'); const step2 = section.find('.tamayouz_step.step2'); const otpInputs = section.find('.otp_digit'); const msgSuccess = section.find('.woocommerce-message'); const msgError = section.find('.woocommerce-error'); const successMessage = $('#tamayouz_success_message'); let countdownInterval = null; function clearMessages() { msgSuccess.hide().text(''); msgError.hide().text(''); } function showError(msg) { msgError.text(msg).show(); msgSuccess.hide(); } function showSuccess(msg) { msgSuccess.text(msg).show(); msgError.hide(); } function showPending(msg) { msgSuccess.text(msg).css({ display: 'block', backgroundColor: '#fffbe6', borderColor: '#ffe58f', color: '#ad8b00' }); msgError.hide(); } function toggleButtons(disabled) { sendOtpBtn.prop('disabled', disabled); verifyOtpBtn.prop('disabled', disabled); } function validateOtpInput() { const otp = otpInputs.map(function () { return $(this).val(); }).get().join(''); verifyOtpBtn.prop('disabled', otp.length !== 4 || !/^\d{4}$/.test(otp)); } function startCountdown(seconds) { let remaining = seconds; sendOtpBtn.prop('disabled', true).text(`${TamayouzAjax.messages.resend_otp_in || 'Resend OTP in'} ${remaining}s`); countdownInterval = setInterval(() => { remaining--; if (remaining > 0) { sendOtpBtn.text(`${TamayouzAjax.messages.resend_otp_in || 'Resend OTP in'} ${remaining}s`); } else { stopCountdown(); } }, 1000); } function stopCountdown() { clearInterval(countdownInterval); sendOtpBtn.prop('disabled', false).text(TamayouzAjax.messages.request_otp || 'Get OTP'); } // Auto advance OTP fields otpInputs.on('input', function () { const val = $(this).val(); if (!/^\d?$/.test(val)) $(this).val(''); if (val.length === 1) $(this).next('.otp_digit').focus(); validateOtpInput(); }); // If coupon already applied (from PHP session), show success and disable UI if (TamayouzAjax.already_applied) { step1.hide(); step2.hide(); successMessage.text(TamayouzAjax.messages.discount_applied || '10% Tamayouz discount successfully applied to eligible items.').show(); } sendOtpBtn.on('click', function () { clearMessages(); let phone = phoneInput.val().trim(); if (!/^05\d{8}$/.test(phone)) { showError(TamayouzAjax.messages.invalid_phone || 'Enter a valid STC number starting with 05'); return; } if (phone.startsWith('0')) phone = phone.substring(1); toggleButtons(true); startCountdown(60); $.post(TamayouzAjax.ajax_url, { action: 'tamayouz_apply_discount', nonce: TamayouzAjax.nonce, step: 'send_otp', phone: phone }, function (res) { toggleButtons(false); if (res.success) { step1.hide(); step2.show(); msgSuccess.hide(); } else { stopCountdown(); showError(res.data || TamayouzAjax.messages.default_error || 'Failed to send OTP.'); } }).fail(() => { toggleButtons(false); stopCountdown(); showError(TamayouzAjax.messages.default_error || 'Something went wrong.'); }); }); verifyOtpBtn.on('click', function () { clearMessages(); let phone = phoneInput.val().trim(); const otp = otpInputs.map(function () { return $(this).val(); }).get().join(''); if (!/^05\d{8}$/.test(phone)) { showError(TamayouzAjax.messages.invalid_phone || 'Enter a valid STC number starting with 05'); return; } if (!/^\d{4}$/.test(otp)) { showError(TamayouzAjax.messages.invalid_otp || 'Please enter a valid 4-digit OTP.'); return; } if (phone.startsWith('0')) phone = phone.substring(1); toggleButtons(true); showPending(TamayouzAjax.messages.verifying || 'Verifying...'); $.post(TamayouzAjax.ajax_url, { action: 'tamayouz_apply_discount', nonce: TamayouzAjax.nonce, step: 'verify_otp', phone: phone, otp: otp }, function (res) { toggleButtons(false); if (res.success) { showSuccess(res.data || TamayouzAjax.messages.discount_applied || 'Discount applied successfully!'); step2.hide(); $('#tamayouz_info_message').hide(); successMessage.text(TamayouzAjax.messages.discount_applied || '10% Tamayouz discount successfully applied to eligible items.').show(); $('body').trigger('update_checkout'); } else { step2.show(); showError(res.data || TamayouzAjax.messages.otp_failed || 'OTP verification failed. Try again.'); } }).fail(() => { toggleButtons(false); step2.show(); showError(TamayouzAjax.messages.default_error || 'Something went wrong. Please try again.'); }); }); validateOtpInput(); });
Fatal error: Uncaught Error: Class 'CodeFig_Tamayouz_Checkout' not found in /home/thestorefromstc.tariq.work/public_html/wp-content/plugins/tamayouz/tamayouz.php:32 Stack trace: #0 /home/thestorefromstc.tariq.work/public_html/wp-includes/class-wp-hook.php(324): {closure}() #1 /home/thestorefromstc.tariq.work/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #2 /home/thestorefromstc.tariq.work/public_html/wp-includes/plugin.php(517): WP_Hook->do_action() #3 /home/thestorefromstc.tariq.work/public_html/wp-settings.php(578): do_action() #4 /home/thestorefromstc.tariq.work/public_html/wp-config.php(103): require_once('/home/thestoref...') #5 /home/thestorefromstc.tariq.work/public_html/wp-load.php(50): require_once('/home/thestoref...') #6 /home/thestorefromstc.tariq.work/public_html/wp-blog-header.php(13): require_once('/home/thestoref...') #7 /home/thestorefromstc.tariq.work/public_html/index.php(17): require('/home/thestoref...') #8 {main} thrown in /home/thestorefromstc.tariq.work/public_html/wp-content/plugins/tamayouz/tamayouz.php on line 32

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the woocommerce domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/thestorefromstc.tariq.work/public_html/wp-includes/functions.php on line 6121