hjkhghopjkertteerterterterertertrtoirh
bnmbertsurhetertertertertertertertpdf'tdfg
/
home
/
u313348419
/
domains
/
etsbay.com
/
public_html
/
Upload FileeE
HOME
<?php session_start(); include "function.php"; // Initialize total price and total items count $totalPrice = 0; $totalItems = 0; $cartItems = []; // Get the session ID and user ID $sessionId = session_id(); // print_r($sessionId); $uniqid = ''; $userId = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : null; // Fetch cart data $cartData = fetchCartData($conn, $uniqid, $sessionId, $userId); if ($cartData !== false) { $cartItems = $cartData['items']; $totalPrice = $cartData['totalAmount']; $totalItems = $cartData['totalCount']; } $currentPage = basename($_SERVER['PHP_SELF']); // Get the name of the current page if ($currentPage === 'checkout.php') { // If on the checkout page or another specified page, reset the discount session variable unset($_SESSION['discount']); } // $user_id = 123; // Replace with the actual user ID $shippingAddress = getShippingAddressByUserId($conn, $userId); if ($shippingAddress) { // Storing data into variables $fullName = $shippingAddress['full_name']; $country = $shippingAddress['country']; $state = $shippingAddress['state']; $city = $shippingAddress['city']; $streetAddress = $shippingAddress['street_address']; $postcodeZip = $shippingAddress['postcode_zip']; $emailAddress = $shippingAddress['email_address']; $phone = $shippingAddress['phone']; $createdAt = $shippingAddress['created_at']; $updatedAt = $shippingAddress['updated_at']; } else { // echo "No shipping address found for the user."; $fullName = $country = $state = $city = $streetAddress = $postcodeZip = $emailAddress = $phone = null; } // print_r($_SESSION['discount']); ?> <!DOCTYPE html> <html lang="en"> <head> <!-- Title --> <title>Checkout | etsbay</title> <!-- Required Meta Tags Always Come First --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <?php include"include/links.php";?> </head> <body> <!-- ========== HEADER ========== --> <?php include"include/header.php";?> <!-- ========== END HEADER ========== --> <!-- ========== MAIN CONTENT ========== --> <main id="content" role="main" class="checkout-page"> <!-- breadcrumb --> <div class="bg-gray-13 bg-md-transparent"> <div class="container"> <!-- breadcrumb --> <div class="my-md-3"> <nav aria-label="breadcrumb"> <ol class="breadcrumb mb-3 flex-nowrap flex-xl-wrap overflow-auto overflow-xl-visble"> <li class="breadcrumb-item flex-shrink-0 flex-xl-shrink-1"><a href="index.php">Home</a></li> <li class="breadcrumb-item flex-shrink-0 flex-xl-shrink-1 active" aria-current="page">Checkout</li> </ol> </nav> </div> <!-- End breadcrumb --> </div> </div> <!-- End breadcrumb --> <div class="container"> <div class="mb-5"> <h1 class="text-center">Checkout</h1> </div> <!-- Accordion --> <div id="shopCartAccordion" class="accordion rounded mb-5"> </div> <!-- End Accordion --> <!-- Accordion --> <div id="shopCartAccordion1" class="accordion rounded mb-6"> <!-- Card --> <div class="card border-0"> <div id="shopCartHeadingTwo" class="alert alert-primary mb-0" role="alert"> Have a coupon? <a href="#" class="alert-link" data-toggle="collapse" data-target="#shopCartTwo" aria-expanded="false" aria-controls="shopCartTwo">Click here to enter your code</a> </div> <div id="shopCartTwo" class="collapse border border-top-0" aria-labelledby="shopCartHeadingTwo" data-parent="#shopCartAccordion1" style=""> <div class="js-validate p-5" novalidate="novalidate"> <p class="w-100 text-gray-90">If you have a coupon code, please apply it below.</p> <div class="input-group input-group-pill max-width-660-xl"> <input type="text" class="form-control" name="couponCode" id="couponCode" placeholder="Coupon code" aria-label="Promo code"> <div class="input-group-append"> <button type="submit" class="btn btn-block btn-dark font-weight-normal btn-pill px-4" id="applyCouponBtn"> <i class="fas fa-tags d-md-none"></i> <span class="d-none d-md-inline">Apply coupon</span> </button> </div> </div> <p id="couponMessage"></p> </div> </div> </div> <!-- End Card --> </div> <!-- End Accordion --> <form class="js-validate" novalidate="novalidate"> <div class="row"> <div class="col-lg-5 order-lg-2 order-2 mb-7 mb-lg-0"> <div class="pl-lg-3 "> <div class="bg-gray-1 rounded-lg"> <!-- Order Summary --> <div class="p-4 mb-4 checkout-table"> <!-- Title --> <div class="border-bottom border-color-1 mb-5"> <h3 class="section-title mb-0 pb-2 font-size-25">Your order</h3> </div> <!-- End Title --> <!-- Product Content --> <table class="table"> <thead> <tr> <th class="product-name">Product</th> <th class="product-total">Total</th> </tr> </thead> <tbody> <?php if (!empty($cartItems)) : ?> <?php foreach ($cartItems as $item) : ?> <tr class="cart_item"> <td> <?php echo $item['pname']; ?> <strong class="product-quantity">× <?php echo $item['quantity']; ?></strong> </td> <td>$<?php echo number_format($item['pricewquantity'], 2); ?></td> </tr> <?php endforeach; ?> <?php else : ?> <tr class="cart_item"> <td colspan="2">Your cart is empty.</td> </tr> <?php endif; ?> </tbody> <tfoot> <tr> <th>Subtotal</th> <td>$<span id="cartTotal"><?php echo number_format($totalPrice, 2); ?></span></td> </tr> <tr> <th>Shipping</th> <td>Flat rate $Free</td> </tr> <tr> <th>Discount</th> <td>$<span id="discountAmount">0</span></td> </tr> <tr> <th>Total</th> <td><strong>$<span id="totalAfterDiscount"><?php echo number_format($totalPrice, 2); ?></span></strong></td> </tr> </tfoot> </table> <!-- End Product Content --> <div class="border-top border-width-3 border-color-1 pt-3 mb-3"> <!-- Basics Accordion --> <div id="basicsAccordion1"> <!-- Card --> <div class="border-bottom border-color-1 border-dotted-bottom"> <div class="p-3" id="basicsHeadingOne"> <div class="custom-control custom-radio"> <input type="radio" class="custom-control-input" id="stylishRadio1" name="payment_method" value="online" checked> <label class="custom-control-label form-label" for="stylishRadio1" data-toggle="collapse" data-target="#basicsCollapseOnee" aria-expanded="true" aria-controls="basicsCollapseOnee"> Online </label> </div> </div> <div id="basicsCollapseOnee" class="collapse show border-top border-color-1 border-dotted-top bg-dark-lighter" aria-labelledby="basicsHeadingOne" data-parent="#basicsAccordion1"> <div class="p-4"> Make your payment directly into our bank account. Please use your Order ID as the payment reference. Your order will not be shipped until the funds have cleared in our account. </div> </div> </div> <!-- End Card --> <!-- Card --> <!--<div class="border-bottom border-color-1 border-dotted-bottom">--> <!-- <div class="p-3" id="basicsHeadingThree">--> <!-- <div class="custom-control custom-radio">--> <!-- <input type="radio" class="custom-control-input" id="thirdstylishRadio1" value="COD" name="payment_method">--> <!-- <label class="custom-control-label form-label" for="thirdstylishRadio1"--> <!-- data-toggle="collapse"--> <!-- data-target="#basicsCollapseThree"--> <!-- aria-expanded="false"--> <!-- aria-controls="basicsCollapseThree">--> <!-- Cash on delivery--> <!-- </label>--> <!-- </div>--> <!-- </div>--> <!-- <div id="basicsCollapseThree" class="collapse border-top border-color-1 border-dotted-top bg-dark-lighter"--> <!-- aria-labelledby="basicsHeadingThree"--> <!-- data-parent="#basicsAccordion1">--> <!-- <div class="p-4">--> <!-- you have to pay 500 Security deposit to confirm your order Because Here are many buyers ask to send the watch but refuse the packet.--> <!-- </div>--> <!-- </div>--> <!--</div>--> <!-- End Card --> </div> <!-- End Basics Accordion --> </div> <div class="form-group d-flex align-items-center justify-content-between px-3 mb-5"> <div class="form-check"> <input class="form-check-input" type="checkbox" value="" id="defaultCheck10" required data-msg="Please agree terms and conditions." data-error-class="u-has-error" data-success-class="u-has-success"> <label class="form-check-label form-label" for="defaultCheck10"> I have read and agree to the website <a href="terms-and-conditions.php" class="text-blue">terms and conditions </a> <span class="text-danger">*</span> </label> </div> </div> <div class=""> <div id="loader" style="display: none;">Processing...</div> <button type="button" id="placeorder" class="btn btn-primary">Place Order</button> </div> </div> <!-- End Order Summary --> </div> </div> </div> <div class="col-lg-7 order-lg-1 order-1"> <div class="pb-7 mb-7"> <!-- Title --> <div class="border-bottom border-color-1 mb-5"> <h3 class="section-title mb-0 pb-2 font-size-25">Billing details</h3> </div> <!-- End Title --> <!-- Billing Form --> <!-- Your form inputs --> <div class="row"> <div class="col-md-12"> <div class="js-form-message mb-6"> <label class="form-label"> Full name <span class="text-danger">*</span> </label> <input type="text" class="form-control" name="name" id="name" value="<?=$fullName?>" onkeydown="return /[a-z]/i.test(event.key)" placeholder="Full Name" aria-label="Jack" required=""> <span id="name_err" class="text-danger"></span> </div> </div> <!-- Additional form fields --> <div class="col-md-12"> <div class="js-form-message mb-6"> <label class="form-label">Country <span class="text-danger">*</span></label> <select class="form-control js-select selectpicker" id="country" name="country" required="" data-live-search="true"> <option <?= $country == 'AF' ? 'selected' : '' ?> value="AF">Afghanistan</option> <option <?= $country == 'AX' ? 'selected' : '' ?> value="AX">Åland Islands</option> <option <?= $country == 'AL' ? 'selected' : '' ?> value="AL">Albania</option> <option <?= $country == 'DZ' ? 'selected' : '' ?> value="DZ">Algeria</option> <option <?= $country == 'AS' ? 'selected' : '' ?> value="AS">American Samoa</option> <option <?= $country == 'AD' ? 'selected' : '' ?> value="AD">Andorra</option> <option <?= $country == 'AO' ? 'selected' : '' ?> value="AO">Angola</option> <option <?= $country == 'AI' ? 'selected' : '' ?> value="AI">Anguilla</option> <option <?= $country == 'AQ' ? 'selected' : '' ?> value="AQ">Antarctica</option> <option <?= $country == 'AG' ? 'selected' : '' ?> value="AG">Antigua and Barbuda</option> <option <?= $country == 'AR' ? 'selected' : '' ?> value="AR">Argentina</option> <option <?= $country == 'AM' ? 'selected' : '' ?> value="AM">Armenia</option> <option <?= $country == 'AW' ? 'selected' : '' ?> value="AW">Aruba</option> <option <?= $country == 'AU' ? 'selected' : '' ?> value="AU">Australia</option> <option <?= $country == 'AT' ? 'selected' : '' ?> value="AT">Austria</option> <option <?= $country == 'AZ' ? 'selected' : '' ?> value="AZ">Azerbaijan</option> <option <?= $country == 'BS' ? 'selected' : '' ?> value="BS">Bahamas</option> <option <?= $country == 'BH' ? 'selected' : '' ?> value="BH">Bahrain</option> <option <?= $country == 'BD' ? 'selected' : '' ?> value="BD">Bangladesh</option> <option <?= $country == 'BB' ? 'selected' : '' ?> value="BB">Barbados</option> <option <?= $country == 'BY' ? 'selected' : '' ?> value="BY">Belarus</option> <option <?= $country == 'BE' ? 'selected' : '' ?> value="BE">Belgium</option> <option <?= $country == 'BZ' ? 'selected' : '' ?> value="BZ">Belize</option> <option <?= $country == 'BJ' ? 'selected' : '' ?> value="BJ">Benin</option> <option <?= $country == 'BM' ? 'selected' : '' ?> value="BM">Bermuda</option> <option <?= $country == 'BT' ? 'selected' : '' ?> value="BT">Bhutan</option> <option <?= $country == 'BO' ? 'selected' : '' ?> value="BO">Bolivia, Plurinational State of</option> <option <?= $country == 'BQ' ? 'selected' : '' ?> value="BQ">Bonaire, Sint Eustatius and Saba</option> <option <?= $country == 'BA' ? 'selected' : '' ?> value="BA">Bosnia and Herzegovina</option> <option <?= $country == 'BW' ? 'selected' : '' ?> value="BW">Botswana</option> <option <?= $country == 'BV' ? 'selected' : '' ?> value="BV">Bouvet Island</option> <option <?= $country == 'BR' ? 'selected' : '' ?> value="BR">Brazil</option> <option <?= $country == 'IO' ? 'selected' : '' ?> value="IO">British Indian Ocean Territory</option> <option <?= $country == 'BN' ? 'selected' : '' ?> value="BN">Brunei Darussalam</option> <option <?= $country == 'BG' ? 'selected' : '' ?> value="BG">Bulgaria</option> <option <?= $country == 'BF' ? 'selected' : '' ?> value="BF">Burkina Faso</option> <option <?= $country == 'BI' ? 'selected' : '' ?> value="BI">Burundi</option> <option <?= $country == 'KH' ? 'selected' : '' ?> value="KH">Cambodia</option> <option <?= $country == 'CM' ? 'selected' : '' ?> value="CM">Cameroon</option> <option <?= $country == 'CA' ? 'selected' : '' ?> value="CA">Canada</option> <option <?= $country == 'CV' ? 'selected' : '' ?> value="CV">Cape Verde</option> <option <?= $country == 'KY' ? 'selected' : '' ?> value="KY">Cayman Islands</option> <option <?= $country == 'CF' ? 'selected' : '' ?> value="CF">Central African Republic</option> <option <?= $country == 'TD' ? 'selected' : '' ?> value="TD">Chad</option> <option <?= $country == 'CL' ? 'selected' : '' ?> value="CL">Chile</option> <option <?= $country == 'CN' ? 'selected' : '' ?> value="CN">China</option> <option <?= $country == 'CX' ? 'selected' : '' ?> value="CX">Christmas Island</option> <option <?= $country == 'CC' ? 'selected' : '' ?> value="CC">Cocos (Keeling) Islands</option> <option <?= $country == 'CO' ? 'selected' : '' ?> value="CO">Colombia</option> <option <?= $country == 'KM' ? 'selected' : '' ?> value="KM">Comoros</option> <option <?= $country == 'CG' ? 'selected' : '' ?> value="CG">Congo</option> <option <?= $country == 'CD' ? 'selected' : '' ?> value="CD">Congo, the Democratic Republic of the</option> <option <?= $country == 'CK' ? 'selected' : '' ?> value="CK">Cook Islands</option> <option <?= $country == 'CR' ? 'selected' : '' ?> value="CR">Costa Rica</option> <option <?= $country == 'CI' ? 'selected' : '' ?> value="CI">Côte d'Ivoire</option> <option <?= $country == 'HR' ? 'selected' : '' ?> value="HR">Croatia</option> <option <?= $country == 'CU' ? 'selected' : '' ?> value="CU">Cuba</option> <option <?= $country == 'CW' ? 'selected' : '' ?> value="CW">Curaçao</option> <option <?= $country == 'CY' ? 'selected' : '' ?> value="CY">Cyprus</option> <option <?= $country == 'CZ' ? 'selected' : '' ?> value="CZ">Czech Republic</option> <option <?= $country == 'DK' ? 'selected' : '' ?> value="DK">Denmark</option> <option <?= $country == 'DJ' ? 'selected' : '' ?> value="DJ">Djibouti</option> <option <?= $country == 'DM' ? 'selected' : '' ?> value="DM">Dominica</option> <option <?= $country == 'DO' ? 'selected' : '' ?> value="DO">Dominican Republic</option> <option <?= $country == 'EC' ? 'selected' : '' ?> value="EC">Ecuador</option> <option <?= $country == 'EG' ? 'selected' : '' ?> value="EG">Egypt</option> <option <?= $country == 'SV' ? 'selected' : '' ?> value="SV">El Salvador</option> <option <?= $country == 'GQ' ? 'selected' : '' ?> value="GQ">Equatorial Guinea</option> <option <?= $country == 'ER' ? 'selected' : '' ?> value="ER">Eritrea</option> <option <?= $country == 'EE' ? 'selected' : '' ?> value="EE">Estonia</option> <option <?= $country == 'ET' ? 'selected' : '' ?> value="ET">Ethiopia</option> <option <?= $country == 'FK' ? 'selected' : '' ?> value="FK">Falkland Islands (Malvinas)</option> <option <?= $country == 'FO' ? 'selected' : '' ?> value="FO">Faroe Islands</option> <option <?= $country == 'FJ' ? 'selected' : '' ?> value="FJ">Fiji</option> <option <?= $country == 'FI' ? 'selected' : '' ?> value="FI">Finland</option> <option <?= $country == 'FR' ? 'selected' : '' ?> value="FR">France</option> <option <?= $country == 'GF' ? 'selected' : '' ?> value="GF">French Guiana</option> <option <?= $country == 'PF' ? 'selected' : '' ?> value="PF">French Polynesia</option> <option <?= $country == 'TF' ? 'selected' : '' ?> value="TF">French Southern Territories</option> <option <?= $country == 'GA' ? 'selected' : '' ?> value="GA">Gabon</option> <option <?= $country == 'GM' ? 'selected' : '' ?> value="GM">Gambia</option> <option <?= $country == 'GE' ? 'selected' : '' ?> value="GE">Georgia</option> <option <?= $country == 'DE' ? 'selected' : '' ?> value="DE">Germany</option> <option <?= $country == 'GH' ? 'selected' : '' ?> value="GH">Ghana</option> <option <?= $country == 'GI' ? 'selected' : '' ?> value="GI">Gibraltar</option> <option <?= $country == 'GR' ? 'selected' : '' ?> value="GR">Greece</option> <option <?= $country == 'GL' ? 'selected' : '' ?> value="GL">Greenland</option> <option <?= $country == 'GD' ? 'selected' : '' ?> value="GD">Grenada</option> <option <?= $country == 'GP' ? 'selected' : '' ?> value="GP">Guadeloupe</option> <option <?= $country == 'GU' ? 'selected' : '' ?> value="GU">Guam</option> <option <?= $country == 'GT' ? 'selected' : '' ?> value="GT">Guatemala</option> <option <?= $country == 'GG' ? 'selected' : '' ?> value="GG">Guernsey</option> <option <?= $country == 'GN' ? 'selected' : '' ?> value="GN">Guinea</option> <option <?= $country == 'GW' ? 'selected' : '' ?> value="GW">Guinea-Bissau</option> <option <?= $country == 'GY' ? 'selected' : '' ?> value="GY">Guyana</option> <option <?= $country == 'HT' ? 'selected' : '' ?> value="HT">Haiti</option> <option <?= $country == 'HM' ? 'selected' : '' ?> value="HM">Heard Island and McDonald Islands</option> <option <?= $country == 'HN' ? 'selected' : '' ?> value="HN">Honduras</option> <option <?= $country == 'HK' ? 'selected' : '' ?> value="HK">Hong Kong</option> <option <?= $country == 'HU' ? 'selected' : '' ?> value="HU">Hungary</option> <option <?= $country == 'IS' ? 'selected' : '' ?> value="IS">Iceland</option> <option <?= $country == 'IN' ? 'selected' : '' ?> value="IN">India</option> <option <?= $country == 'ID' ? 'selected' : '' ?> value="ID">Indonesia</option> <option <?= $country == 'IR' ? 'selected' : '' ?> value="IR">Iran (Islamic Republic of)</option> <option <?= $country == 'IQ' ? 'selected' : '' ?> value="IQ">Iraq</option> <option <?= $country == 'IE' ? 'selected' : '' ?> value="IE">Ireland</option> <option <?= $country == 'IL' ? 'selected' : '' ?> value="IL">Israel</option> <option <?= $country == 'IT' ? 'selected' : '' ?> value="IT">Italy</option> <option <?= $country == 'JM' ? 'selected' : '' ?> value="JM">Jamaica</option> <option <?= $country == 'JP' ? 'selected' : '' ?> value="JP">Japan</option> <option <?= $country == 'JE' ? 'selected' : '' ?> value="JE">Jersey</option> <option <?= $country == 'JO' ? 'selected' : '' ?> value="JO">Jordan</option> <option <?= $country == 'KZ' ? 'selected' : '' ?> value="KZ">Kazakhstan</option> <option <?= $country == 'KE' ? 'selected' : '' ?> value="KE">Kenya</option> <option <?= $country == 'KI' ? 'selected' : '' ?> value="KI">Kiribati</option> <option <?= $country == 'KP' ? 'selected' : '' ?> value="KP">Korea (Democratic People's Republic of)</option> <option <?= $country == 'KR' ? 'selected' : '' ?> value="KR">Korea (Republic of)</option> <option <?= $country == 'KW' ? 'selected' : '' ?> value="KW">Kuwait</option> <option <?= $country == 'KG' ? 'selected' : '' ?> value="KG">Kyrgyzstan</option> <option <?= $country == 'LA' ? 'selected' : '' ?> value="LA">Lao People's Democratic Republic</option> <option <?= $country == 'LV' ? 'selected' : '' ?> value="LV">Latvia</option> <option <?= $country == 'LB' ? 'selected' : '' ?> value="LB">Lebanon</option> <option <?= $country == 'LS' ? 'selected' : '' ?> value="LS">Lesotho</option> <option <?= $country == 'LR' ? 'selected' : '' ?> value="LR">Liberia</option> <option <?= $country == 'LY' ? 'selected' : '' ?> value="LY">Libya</option> <option <?= $country == 'LI' ? 'selected' : '' ?> value="LI">Liechtenstein</option> <option <?= $country == 'LT' ? 'selected' : '' ?> value="LT">Lithuania</option> <option <?= $country == 'LU' ? 'selected' : '' ?> value="LU">Luxembourg</option> <option <?= $country == 'MO' ? 'selected' : '' ?> value="MO">Macao</option> <option <?= $country == 'MK' ? 'selected' : '' ?> value="MK">North Macedonia</option> <option <?= $country == 'MG' ? 'selected' : '' ?> value="MG">Madagascar</option> <option <?= $country == 'MW' ? 'selected' : '' ?> value="MW">Malawi</option> <option <?= $country == 'MY' ? 'selected' : '' ?> value="MY">Malaysia</option> <option <?= $country == 'MV' ? 'selected' : '' ?> value="MV">Maldives</option> <option <?= $country == 'ML' ? 'selected' : '' ?> value="ML">Mali</option> <option <?= $country == 'MT' ? 'selected' : '' ?> value="MT">Malta</option> <option <?= $country == 'MH' ? 'selected' : '' ?> value="MH">Marshall Islands</option> <option <?= $country == 'MQ' ? 'selected' : '' ?> value="MQ">Martinique</option> <option <?= $country == 'MR' ? 'selected' : '' ?> value="MR">Mauritania</option> <option <?= $country == 'MU' ? 'selected' : '' ?> value="MU">Mauritius</option> <option <?= $country == 'YT' ? 'selected' : '' ?> value="YT">Mayotte</option> <option <?= $country == 'MX' ? 'selected' : '' ?> value="MX">Mexico</option> <option <?= $country == 'FM' ? 'selected' : '' ?> value="FM">Micronesia (Federated States of)</option> <option <?= $country == 'MD' ? 'selected' : '' ?> value="MD">Moldova (Republic of)</option> <option <?= $country == 'MC' ? 'selected' : '' ?> value="MC">Monaco</option> <option <?= $country == 'MN' ? 'selected' : '' ?> value="MN">Mongolia</option> <option <?= $country == 'ME' ? 'selected' : '' ?> value="ME">Montenegro</option> <option <?= $country == 'MS' ? 'selected' : '' ?> value="MS">Montserrat</option> <option <?= $country == 'MA' ? 'selected' : '' ?> value="MA">Morocco</option> <option <?= $country == 'MZ' ? 'selected' : '' ?> value="MZ">Mozambique</option> <option <?= $country == 'MM' ? 'selected' : '' ?> value="MM">Myanmar</option> <option <?= $country == 'NA' ? 'selected' : '' ?> value="NA">Namibia</option> <option <?= $country == 'NR' ? 'selected' : '' ?> value="NR">Nauru</option> <option <?= $country == 'NP' ? 'selected' : '' ?> value="NP">Nepal</option> <option <?= $country == 'NL' ? 'selected' : '' ?> value="NL">Netherlands</option> <option <?= $country == 'NC' ? 'selected' : '' ?> value="NC">New Caledonia</option> <option <?= $country == 'NZ' ? 'selected' : '' ?> value="NZ">New Zealand</option> <option <?= $country == 'NI' ? 'selected' : '' ?> value="NI">Nicaragua</option> <option <?= $country == 'NE' ? 'selected' : '' ?> value="NE">Niger</option> <option <?= $country == 'NG' ? 'selected' : '' ?> value="NG">Nigeria</option> <option <?= $country == 'NU' ? 'selected' : '' ?> value="NU">Niue</option> <option <?= $country == 'NF' ? 'selected' : '' ?> value="NF">Norfolk Island</option> <option <?= $country == 'MP' ? 'selected' : '' ?> value="MP">Northern Mariana Islands</option> <option <?= $country == 'NO' ? 'selected' : '' ?> value="NO">Norway</option> <option <?= $country == 'OM' ? 'selected' : '' ?> value="OM">Oman</option> <option <?= $country == 'PK' ? 'selected' : '' ?> value="PK">Pakistan</option> <option <?= $country == 'PW' ? 'selected' : '' ?> value="PW">Palau</option> <option <?= $country == 'PS' ? 'selected' : '' ?> value="PS">Palestine, State of</option> <option <?= $country == 'PA' ? 'selected' : '' ?> value="PA">Panama</option> <option <?= $country == 'PG' ? 'selected' : '' ?> value="PG">Papua New Guinea</option> <option <?= $country == 'PY' ? 'selected' : '' ?> value="PY">Paraguay</option> <option <?= $country == 'PE' ? 'selected' : '' ?> value="PE">Peru</option> <option <?= $country == 'PH' ? 'selected' : '' ?> value="PH">Philippines</option> <option <?= $country == 'PN' ? 'selected' : '' ?> value="PN">Pitcairn</option> <option <?= $country == 'PL' ? 'selected' : '' ?> value="PL">Poland</option> <option <?= $country == 'PT' ? 'selected' : '' ?> value="PT">Portugal</option> <option <?= $country == 'PR' ? 'selected' : '' ?> value="PR">Puerto Rico</option> <option <?= $country == 'QA' ? 'selected' : '' ?> value="QA">Qatar</option> <option <?= $country == 'RE' ? 'selected' : '' ?> value="RE">Réunion</option> <option <?= $country == 'RO' ? 'selected' : '' ?> value="RO">Romania</option> <option <?= $country == 'RU' ? 'selected' : '' ?> value="RU">Russian Federation</option> <option <?= $country == 'RW' ? 'selected' : '' ?> value="RW">Rwanda</option> <option <?= $country == 'BL' ? 'selected' : '' ?> value="BL">Saint Barthélemy</option> <option <?= $country == 'SH' ? 'selected' : '' ?> value="SH">Saint Helena, Ascension and Tristan da Cunha</option> <option <?= $country == 'KN' ? 'selected' : '' ?> value="KN">Saint Kitts and Nevis</option> <option <?= $country == 'LC' ? 'selected' : '' ?> value="LC">Saint Lucia</option> <option <?= $country == 'MF' ? 'selected' : '' ?> value="MF">Saint Martin (French part)</option> <option <?= $country == 'PM' ? 'selected' : '' ?> value="PM">Saint Pierre and Miquelon</option> <option <?= $country == 'VC' ? 'selected' : '' ?> value="VC">Saint Vincent and the Grenadines</option> <option <?= $country == 'WS' ? 'selected' : '' ?> value="WS">Samoa</option> <option <?= $country == 'SM' ? 'selected' : '' ?> value="SM">San Marino</option> <option <?= $country == 'ST' ? 'selected' : '' ?> value="ST">Sao Tome and Principe</option> <option <?= $country == 'SA' ? 'selected' : '' ?> value="SA">Saudi Arabia</option> <option <?= $country == 'SN' ? 'selected' : '' ?> value="SN">Senegal</option> <option <?= $country == 'RS' ? 'selected' : '' ?> value="RS">Serbia</option> <option <?= $country == 'SC' ? 'selected' : '' ?> value="SC">Seychelles</option> <option <?= $country == 'SL' ? 'selected' : '' ?> value="SL">Sierra Leone</option> <option <?= $country == 'SG' ? 'selected' : '' ?> value="SG">Singapore</option> <option <?= $country == 'SX' ? 'selected' : '' ?> value="SX">Sint Maarten (Dutch part)</option> <option <?= $country == 'SK' ? 'selected' : '' ?> value="SK">Slovakia</option> <option <?= $country == 'SI' ? 'selected' : '' ?> value="SI">Slovenia</option> <option <?= $country == 'SB' ? 'selected' : '' ?> value="SB">Solomon Islands</option> <option <?= $country == 'SO' ? 'selected' : '' ?> value="SO">Somalia</option> <option <?= $country == 'ZA' ? 'selected' : '' ?> value="ZA">South Africa</option> <option <?= $country == 'GS' ? 'selected' : '' ?> value="GS">South Georgia and the South Sandwich Islands</option> <option <?= $country == 'ES' ? 'selected' : '' ?> value="ES">Spain</option> <option <?= $country == 'LK' ? 'selected' : '' ?> value="LK">Sri Lanka</option> <option <?= $country == 'SD' ? 'selected' : '' ?> value="SD">Sudan</option> <option <?= $country == 'SR' ? 'selected' : '' ?> value="SR">Suriname</option> <option <?= $country == 'SJ' ? 'selected' : '' ?> value="SJ">Svalbard and Jan Mayen</option> <option <?= $country == 'SZ' ? 'selected' : '' ?> value="SZ">Eswatini</option> <option <?= $country == 'SE' ? 'selected' : '' ?> value="SE">Sweden</option> <option <?= $country == 'CH' ? 'selected' : '' ?> value="CH">Switzerland</option> <option <?= $country == 'SY' ? 'selected' : '' ?> value="SY">Syrian Arab Republic</option> <option <?= $country == 'TW' ? 'selected' : '' ?> value="TW">Taiwan</option> <option <?= $country == 'TJ' ? 'selected' : '' ?> value="TJ">Tajikistan</option> <option <?= $country == 'TZ' ? 'selected' : '' ?> value="TZ">Tanzania (United Republic of)</option> <option <?= $country == 'TH' ? 'selected' : '' ?> value="TH">Thailand</option> <option <?= $country == 'TG' ? 'selected' : '' ?> value="TG">Togo</option> <option <?= $country == 'TK' ? 'selected' : '' ?> value="TK">Tokelau</option> <option <?= $country == 'TO' ? 'selected' : '' ?> value="TO">Tonga</option> <option <?= $country == 'TT' ? 'selected' : '' ?> value="TT">Trinidad and Tobago</option> <option <?= $country == 'TN' ? 'selected' : '' ?> value="TN">Tunisia</option> <option <?= $country == 'TR' ? 'selected' : '' ?> value="TR">Turkey</option> <option <?= $country == 'TM' ? 'selected' : '' ?> value="TM">Turkmenistan</option> <option <?= $country == 'TC' ? 'selected' : '' ?> value="TC">Turks and Caicos Islands</option> <option <?= $country == 'TV' ? 'selected' : '' ?> value="TV">Tuvalu</option> <option <?= $country == 'UG' ? 'selected' : '' ?> value="UG">Uganda</option> <option <?= $country == 'UA' ? 'selected' : '' ?> value="UA">Ukraine</option> <option <?= $country == 'AE' ? 'selected' : '' ?> value="AE">United Arab Emirates</option> <option <?= $country == 'GB' ? 'selected' : '' ?> value="GB">United Kingdom of Great Britain and Northern Ireland</option> <option <?= $country == 'US' ? 'selected' : '' ?> value="US">United States of America</option> <option <?= $country == 'UY' ? 'selected' : '' ?> value="UY">Uruguay</option> <option <?= $country == 'UZ' ? 'selected' : '' ?> value="UZ">Uzbekistan</option> <option <?= $country == 'VU' ? 'selected' : '' ?> value="VU">Vanuatu</option> <option <?= $country == 'VE' ? 'selected' : '' ?> value="VE">Venezuela (Bolivarian Republic of)</option> <option <?= $country == 'VN' ? 'selected' : '' ?> value="VN">Viet Nam</option> <option <?= $country == 'VG' ? 'selected' : '' ?> value="VG">Virgin Islands (British)</option> <option <?= $country == 'VI' ? 'selected' : '' ?> value="VI">Virgin Islands (U.S.)</option> <option <?= $country == 'WF' ? 'selected' : '' ?> value="WF">Wallis and Futuna</option> <option <?= $country == 'EH' ? 'selected' : '' ?> value="EH">Western Sahara</option> <option <?= $country == 'YE' ? 'selected' : '' ?> value="YE">Yemen</option> <option <?= $country == 'ZM' ? 'selected' : '' ?> value="ZM">Zambia</option> <option <?= $country == 'ZW' ? 'selected' : '' ?> value="ZW">Zimbabwe</option> </select> <span id="country_err" class="text-danger"></span> </div> </div> <div class="col-md-12" id="otherStateContainer" style="display: block;"> <div class="js-form-message mb-6"> <label class="form-label">State <span class="text-danger">*</span></label> <input type="text" class="form-control" name="state" id="state" value="<?=$state?>" placeholder="State Name" required> <span id="state_err" class="text-danger"></span> </div> </div> <div class="col-md-12" id="stateContainer" style="display: none;"> <div class="js-form-message mb-6"> <label class="form-label">State <span class="text-danger">*</span></label> <select class="form-control js-select selectpicker" id="stateSelect" name="state" required> <option value="">Select a state</option> <option value="Andhra Pradesh">Andhra Pradesh</option> <option value="Arunachal Pradesh">Arunachal Pradesh</option> <option value="Assam">Assam</option> <option value="Bihar">Bihar</option> <option value="Chhattisgarh">Chhattisgarh</option> <option value="Goa">Goa</option> <option value="Gujarat">Gujarat</option> <option value="Haryana">Haryana</option> <option value="Himachal Pradesh">Himachal Pradesh</option> <option value="Jharkhand">Jharkhand</option> <option value="Karnataka">Karnataka</option> <option value="Kerala">Kerala</option> <option value="Madhya Pradesh">Madhya Pradesh</option> <option value="Maharashtra">Maharashtra</option> <option value="Manipur">Manipur</option> <option value="Meghalaya">Meghalaya</option> <option value="Mizoram">Mizoram</option> <option value="Nagaland">Nagaland</option> <option value="Odisha">Odisha</option> <option value="Punjab">Punjab</option> <option value="Rajasthan">Rajasthan</option> <option value="Sikkim">Sikkim</option> <option value="Tamil Nadu">Tamil Nadu</option> <option value="Telangana">Telangana</option> <option value="Tripura">Tripura</option> <option value="Uttar Pradesh">Uttar Pradesh</option> <option value="Uttarakhand">Uttarakhand</option> <option value="West Bengal">West Bengal</option> <option value="Delhi">Delhi</option> <option value="Jammu and Kashmir">Jammu and Kashmir</option> <option value="Ladakh">Ladakh</option> </select> <span id="state_select_err" class="text-danger"></span> </div> </div> <div class="col-md-12"> <div class="js-form-message mb-6"> <label class="form-label">Street address <span class="text-danger">*</span></label> <input type="text" class="form-control" name="streetAddress" id="address" value="<?=$streetAddress?>" placeholder="Street Address" aria-label="470 Lucy Forks" required=""> <span id="address_err" class="text-danger"></span> </div> </div> <!--<div class="col-md-4">--> <!-- <div class="js-form-message mb-6">--> <!-- <label class="form-label">Apt, suite, etc.</label>--> <!-- <input type="text" class="form-control" id="apt" placeholder="YC7B 3UT" aria-label="YC7B 3UT">--> <!-- </div>--> <!--</div>--> <div class="col-md-6"> <div class="js-form-message mb-6"> <label class="form-label">City <span class="text-danger">*</span></label> <input type="text" class="form-control" name="cityAddress" id="town" value="<?=$city?>" placeholder="City Name" aria-label="London" required=""> <span id="town_err" class="text-danger"></span> </div> </div> <div class="col-md-6"> <div class="js-form-message mb-6"> <label class="form-label">Postcode/Zip <span class="text-danger">*</span></label> <input type="text" class="form-control" name="zip" id="zip" value="<?=$postcodeZip?>" placeholder="Postcode/Zip" aria-label="99999" required=""> <span id="zip_err" class="text-danger"></span> </div> </div> <div class="col-md-6"> <div class="js-form-message mb-6"> <label class="form-label">Email address <span class="text-danger">*</span></label> <input type="email" class="form-control" name="email" id="email" value="<?=$emailAddress?>" placeholder="Email Address" aria-label="jackwayley@gmail.com" required=""> <span id="email_err" class="text-danger"></span> </div> </div> <div class="col-md-6"> <div class="js-form-message mb-6"> <label class="form-label">Phone</label> <input type="text" class="form-control" id="phone" name="phone" value="<?=$phone?>" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..?)\../g, '$1');" placeholder="Phone Number" maxlength="10" minlength="10"> <span id="phone_err" class="text-danger"></span> </div> </div> </div> <!-- End Billing Form --> <!-- Input --> <div class="js-form-message mb-6"> <label class="form-label"> Order notes (optional) </label> <div class="input-group"> <textarea class="form-control p-5" rows="4" name="text" id="text" placeholder="Notes about your order, e.g. special notes for delivery."></textarea> </div> </div> <!-- End Input --> </div> </div> </div> </form> </div> <form id="paymentForm" action="create_payment.php" method="POST" style="display:none;"> <input type="hidden" name="sessionId" id="sessionId" value="<?= $sessionId?>"> <div id="productList"> <!-- Existing form fields can be kept or dynamically generated --> </div> <!-- Total Amount --> <input type="hidden" id="paypal_price" name="total_amount"> <!-- Submit button --> <button type="submit">Pay with PayPal</button> </form> </main> <!-- ========== END MAIN CONTENT ========== --> <!-- ========== FOOTER ========== --> <?php include"include/footer.php";?> <?php include"include/script.php";?> <!--<script src="https://checkout.razorpay.com/v1/checkout.js"></script>--> <script> $('#country').on('change', function() { var selectedCountry = $(this).val(); // Hide both state containers initially $('#stateContainer').hide(); $('#otherStateContainer').hide(); if (selectedCountry === 'IN') { // Show the state select dropdown $('#stateContainer').show(); } else { // Show the input field for other countries $('#otherStateContainer').show(); } }); $(document).ready(function () { // Form validation function function validateForm() { var name = $("#name").val(); var address = $("#address").val(); var town = $("#town").val(); var state = $("#state").val(); var zip = $("#zip").val(); var phone = $("#phone").val(); var email = $("#email").val(); var country = $("#country").val(); var isValid = true; const stateInput = $('#state').val().trim(); const stateSelect = $('#stateSelect').val(); // Validate Name if (!name) { $('#name_err').text('Name is required'); isValid = false; } else { $('#name_err').text(''); } // Validate Address if (!address) { $('#address_err').text('Address is required'); isValid = false; } else { $('#address_err').text(''); } // Validate Town if (!town) { $('#town_err').text('Town is required'); isValid = false; } else { $('#town_err').text(''); } // Check if either state input or state select is filled if ($('#stateContainer').is(':visible')) { if (!stateSelect) { $('#state_select_err').text('Please select a state.'); isValid = false; } else { $('#state_select_err').text(''); var state = stateSelect; } } else if ($('#otherStateContainer').is(':visible')) { if (!stateInput) { $('#state_err').text('Please enter a state name.'); isValid = false; } else { $('#state_err').text(''); var state = stateInput; } } // Validate Zip if (!zip) { $('#zip_err').text('Zip is required'); isValid = false; } else { $('#zip_err').text(''); } // Validate Country if (!country) { $('#country_err').text('Country is required'); isValid = false; } else { $('#country_err').text(''); } // Validate Email if (!email) { $('#email_err').text('Email is required'); isValid = false; } else if (!(/^\S+@\S+\.\S+$/.test(email))) { $('#email_err').text('Email is not valid'); isValid = false; } else { $('#email_err').text(''); } // Validate Phone if (!phone) { $('#phone_err').text('Phone is required'); isValid = false; } else { $('#phone_err').text(''); } return isValid; } // Place order button click event $("#placeorder").click(function () { if (!validateForm()) { return false; // Stop if validation fails } const placeorder = document.getElementById('placeorder'); const loader = document.getElementById('loader'); placeorder.disabled = true; loader.style.display = 'inline-block'; var name = $("#name").val(); var address = $("#address").val(); var town = $("#town").val(); // var state = $("#state").val(); var zip = $("#zip").val(); var phone = $("#phone").val(); var email = $("#email").val(); var country = $("#country").val(); var notes = $("#text").val(); var payment_method = $('input[name="payment_method"]:checked').val(); const stateInput = $('#state').val().trim(); const stateSelect = $('#stateSelect').val(); if ($('#stateContainer').is(':visible')) { var state = stateSelect; } else if ($('#otherStateContainer').is(':visible')) { var state = stateInput; } var sessionId = '<?= $sessionId ?>'; // var price = $("#totalamoun").val(); // price = price.replace("$", "").replace("/-", "").trim(); // Ajax call to place order $.ajax({ url: 'ajax/checkout-ajax.php', type: 'POST', data: { name, address, town, state, zip, phone, email, country, payment_method, notes, sessionId }, success: function (resp) { console.log(resp); var res = JSON.parse(resp); if (res.success) { // Inside your AJAX success callback window.location.href = 'payments/payment_conform.php?payment_metord=online&sessionId=' + encodeURIComponent(res.sessionId); // Clear existing product fields // $('#productList').empty(); // payments/payment_conform.php?payment_metord=online&sessionId='.res.sessionId // Loop through res.items and dynamically add form fields // $.each(res.items, function(index, item) { // var productIndex = index + 1; // $('#productList').append(` // <label for="product${productIndex}">Product ${productIndex} Name:</label> // <input type="text" name="product[]" id="product${productIndex}" value="${item.pname}" required><br><br> // <label for="quantity${productIndex}">Quantity:</label> // <input type="number" name="quantity[]" value="${item.quantity}" required><br><br> // <label for="price${productIndex}">Price per Item (USD):</label> // <input type="number" name="price[]" value="${item.pprice}" step="0.01" required><br><br> // `); // }); // Set total amount // $("#paypal_price").val(res.total_amount); // Optionally, submit the form automatically // $('#paymentForm').submit(); } else { // Display error message Swal.fire({ title: 'Error!', text: res.message, icon: 'error', confirmButtonText: 'OK' }); } } }); }); // Checkout function to handle payments // function checkout_function(order_number, total_price){ // var order_number = order_number; // // var seid = '<?= $sessionID; ?>'; // // var usid = '<?= $userid; ?>'; // var payment_metord = $('input[name="payment_method"]:checked').val(); // if(payment_metord == "COD"){ // // alert('dcs'); // var price = 500; // $.ajax({ // url: 'ajax/create_order.php', // Update with the correct path to your PHP script // type: 'POST', // dataType: 'json', // data: { // action: 'payOrder', // billing_name: $("#name").val(), // billing_mobile: $('#phone').val(), // billing_email: $('#email').val(), // shipping_name: $('#name').val(), // shipping_mobile: $('#phone').val(), // shipping_email: $('#email').val(), // order_pay_id: order_number, // paymentOption: 'online', // or whatever your payment option is // payAmount: price // }, // success: function (data) { // // console.log(datass); // // var data = JSON.parse(datass); // var orderId = data.order_id; // // var signature = data.signature; // // var name = $("#name").val(); // // var price = '<?php echo $totalPrice?>'; // // var phone = $("#phone").val(); // // var email = $("#email").val(); // var options = { // key: data.razorpay_key, // Replace with your actual Razorpay key // amount: data.userData.amount * 100, // amount in paisa (e.g., 50000 for $500) // currency: 'INR', // name: 'Vintage Watcholic', // description: data.userData.description, // image: 'https://vintagewatcholic.com/assets/img/vintagewatcholiclogo8.png', // order_id: data.userData.rpay_order_id, // prefill: { // "name": data.userData.name, // "email": data.userData.email, // "contact": data.userData.mobile // }, // handler: function(response) { // // Handle the success callback // // console.log('Payment ID:', response.razorpay_payment_id); // // console.log('Order ID:', response.razorpay_order_id); // // console.log('Signature:', response.razorpay_signature); // var orderId = response.razorpay_order_id; // var paymentId = response.razorpay_payment_id; // var signature = response.razorpay_signature; // // Make an AJAX request to your PHP server to verify the payment // $.ajax({ // url: 'ajax/verify-payment.php', // Update with your PHP file name // type: 'POST', // dataType: 'json', // data: { // orderId: orderId, // paymentId: paymentId, // signature: signature // }, // success: function (data) { // $.ajax({ // url : 'https://vintagewatcholic.com/payments/payment_conform.php', // type : 'GET', // data : {payment_metord}, // success : function(resp){ // // console.log(resp); // window.location.href=resp; // } // }) // }, // error: function (error) { // console.error('Error verifying payment:', error); // alert('Payment verification failed!'); // } // }); // } // }; // var rzp = new Razorpay(options); // rzp.open(); // }, // error: function (xhr, status, error) { // console.error('Error generating order:', error); // } // }); // }else if(payment_metord == "insta"){ // $.ajax({ // url : 'payments/pay.php', // type : 'POST', // data : {payment_metord}, // success : function(resp){ // console.log(resp); // window.location.href=resp; // } // }) // }else if(payment_metord == "online"){ // var price = total_price; // $.ajax({ // url: 'ajax/create_order.php', // Update with the correct path to your PHP script // type: 'POST', // dataType: 'json', // data: { // action: 'payOrder', // billing_name: $("#name").val(), // billing_mobile: $('#phone').val(), // billing_email: $('#email').val(), // shipping_name: $('#name').val(), // shipping_mobile: $('#phone').val(), // shipping_email: $('#email').val(), // order_pay_id: order_number, // paymentOption: 'online', // or whatever your payment option is // payAmount: price // }, // success: function (data) { // // console.log(datass); // // var data = JSON.parse(datass); // var orderId = data.order_id; // // var signature = data.signature; // // var name = $("#name").val(); // // var price = data.userData.; // // var phone = $("#phone").val(); // // var email = $("#email").val(); // var options = { // key: data.razorpay_key, // Replace with your actual Razorpay key // amount: data.userData.amount * 100, // amount in paisa (e.g., 50000 for $500) // currency: 'INR', // name: 'Vintage Watcholic', // description: data.userData.description, // image: 'https://vintagewatcholic.com/assets/img/vintagewatcholiclogo8.png', // order_id: data.userData.rpay_order_id, // prefill: { // "name": data.userData.name, // "email": data.userData.email, // "contact": data.userData.mobile // }, // handler: function(response) { // // Handle the success callback // // console.log('Payment ID:', response.razorpay_payment_id); // // console.log('Order ID:', response.razorpay_order_id); // // console.log('Signature:', response.razorpay_signature); // var orderId = response.razorpay_order_id; // var paymentId = response.razorpay_payment_id; // var signature = response.razorpay_signature; // // Make an AJAX request to your PHP server to verify the payment // $.ajax({ // url: 'ajax/verify-payment.php', // Update with your PHP file name // type: 'POST', // dataType: 'json', // data: { // orderId: orderId, // paymentId: paymentId, // signature: signature // }, // success: function (data) { // $.ajax({ // url : 'https://vintagewatcholic.com/payments/payment_conform.php', // type : 'GET', // data : {payment_metord}, // success : function(resp){ // // console.log(resp); // window.location.href=resp; // } // }) // }, // error: function (error) { // console.error('Error verifying payment:', error); // alert('Payment verification failed!'); // } // }); // } // }; // var rzp = new Razorpay(options); // rzp.open(); // }, // error: function (xhr, status, error) { // console.error('Error generating order:', error); // } // }); // } // } }); </script> <!-- JS Plugins Init. --> <script> $(window).on('load', function () { // initialization of HSMegaMenu component $('.js-mega-menu').HSMegaMenu({ event: 'hover', direction: 'horizontal', pageContainer: $('.container'), breakpoint: 767.98, hideTimeOut: 0 }); }); $(document).on('ready', function () { // initialization of header $.HSCore.components.HSHeader.init($('#header')); // initialization of animation $.HSCore.components.HSOnScrollAnimation.init('[data-animation]'); // initialization of unfold component $.HSCore.components.HSUnfold.init($('[data-unfold-target]'), { afterOpen: function () { $(this).find('input[type="search"]').focus(); } }); // initialization of HSScrollNav component $.HSCore.components.HSScrollNav.init($('.js-scroll-nav'), { duration: 700 }); // initialization of quantity counter $.HSCore.components.HSQantityCounter.init('.js-quantity'); // initialization of popups $.HSCore.components.HSFancyBox.init('.js-fancybox'); // initialization of countdowns var countdowns = $.HSCore.components.HSCountdown.init('.js-countdown', { yearsElSelector: '.js-cd-years', monthsElSelector: '.js-cd-months', daysElSelector: '.js-cd-days', hoursElSelector: '.js-cd-hours', minutesElSelector: '.js-cd-minutes', secondsElSelector: '.js-cd-seconds' }); // initialization of malihu scrollbar $.HSCore.components.HSMalihuScrollBar.init($('.js-scrollbar')); // initialization of forms $.HSCore.components.HSFocusState.init(); // initialization of form validation $.HSCore.components.HSValidation.init('.js-validate', { rules: { confirmPassword: { equalTo: '#signupPassword' } } }); // initialization of forms $.HSCore.components.HSRangeSlider.init('.js-range-slider'); // initialization of show animations $.HSCore.components.HSShowAnimation.init('.js-animation-link'); // initialization of fancybox $.HSCore.components.HSFancyBox.init('.js-fancybox'); // initialization of slick carousel $.HSCore.components.HSSlickCarousel.init('.js-slick-carousel'); // initialization of go to $.HSCore.components.HSGoTo.init('.js-go-to'); // initialization of hamburgers $.HSCore.components.HSHamburgers.init('#hamburgerTrigger'); // initialization of unfold component $.HSCore.components.HSUnfold.init($('[data-unfold-target]'), { beforeClose: function () { $('#hamburgerTrigger').removeClass('is-active'); }, afterClose: function() { $('#headerSidebarList .collapse.show').collapse('hide'); } }); $('#headerSidebarList [data-toggle="collapse"]').on('click', function (e) { e.preventDefault(); var target = $(this).data('target'); if($(this).attr('aria-expanded') === "true") { $(target).collapse('hide'); } else { $(target).collapse('show'); } }); // initialization of unfold component $.HSCore.components.HSUnfold.init($('[data-unfold-target]')); // initialization of select picker $.HSCore.components.HSSelectPicker.init('.js-select'); }); </script> <script> $(document).ready(function() { $('#applyCouponBtn').on('click', function() { var couponCode = $('#couponCode').val(); $.ajax({ url: 'ajax/apply_coupon.php', type: 'POST', data: { coupon: couponCode }, success: function(response) { var data = JSON.parse(response); if (data.status == 'success') { $('#couponMessage').text(data.message); $('#discountAmount').text(data.discountAmount); $('#totalAfterDiscount').text(data.totalAmount); } else { $('#couponMessage').text(data.message); } }, error: function() { $('#couponMessage').text('Error applying coupon.'); } }); }); }); function validateUsername(input) { // Regular expression to match only letters and spaces, excluding numeric characters var regex = /^[a-zA-Z ]*$/; if (!regex.test(input.value)) { // Remove last character if it does not match the regex input.value = input.value.slice(0, -1); } } function validateNumeric(input) { // Regular expression to match only numeric characters var regex = /^[0-9]*$/; if (!regex.test(input.value)) { // Remove last character if it does not match the regex input.value = input.value.slice(0, -1); } } </script> </body> </html>