updated checkout flow
This commit is contained in:
@@ -1,18 +1,23 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Traits\CaptchaTrait;
|
||||
use App\User;
|
||||
use Validator;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Models\user\UserModel;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CustomAuthController extends Controller {
|
||||
class CustomAuthController extends Controller
|
||||
{
|
||||
use CaptchaTrait;
|
||||
|
||||
public function authenticate(Request $request){
|
||||
public function authenticate(Request $request)
|
||||
{
|
||||
|
||||
$post = $request->all();
|
||||
$email = $post['email'];
|
||||
@@ -54,12 +59,15 @@ class CustomAuthController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function postRegister(Request $request){
|
||||
public function postRegister(Request $request)
|
||||
{
|
||||
$post = $request->all();
|
||||
|
||||
$userModel = new UserModel;
|
||||
$post['captcha'] = $this->captchaCheck();
|
||||
|
||||
$validator = Validator::make($post, [
|
||||
$validator = Validator::make(
|
||||
$post,
|
||||
[
|
||||
'username' => 'unique:user_logins',
|
||||
'email' => 'unique:user_logins',
|
||||
'g-recaptcha-response' => 'required',
|
||||
@@ -68,11 +76,11 @@ class CustomAuthController extends Controller {
|
||||
[
|
||||
'g-recaptcha-response.required' => 'Captcha is required',
|
||||
'captcha.min' => 'Wrong captcha, please try again.'
|
||||
]);
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
if ($validator->fails())
|
||||
{
|
||||
if ($validator->fails()) {
|
||||
$errors = "";
|
||||
foreach ($validator->errors()->all() as $error) {
|
||||
$errors .= "<li>" . $error . "</li>";
|
||||
@@ -91,19 +99,34 @@ class CustomAuthController extends Controller {
|
||||
));
|
||||
}
|
||||
|
||||
User::create([
|
||||
'name' => $post['name'],
|
||||
'username' => $post['username'],
|
||||
$user = User::create([
|
||||
'name' => $post['firstname'] . ' ' . $post['lastname'],
|
||||
'username' => $post['email'],
|
||||
'email' => $post['email'],
|
||||
'password' => bcrypt($post['password']),
|
||||
'role' => 'user'
|
||||
]);
|
||||
|
||||
$data = array(
|
||||
'UserId' => $user->id,
|
||||
'Fullname' => $post['firstname'] . ' ' . $post['lastname'],
|
||||
'ContactNumber' => $post['mobilenumber'],
|
||||
// 'OtherNotes' => $post['othernotes'],
|
||||
'Address' => $post['address'],
|
||||
'Address2' => $post['address2'],
|
||||
'State' => $post['state'],
|
||||
'City' => $post['city'],
|
||||
'ZipCode' => $post['zipcode'],
|
||||
'CountryCode' => $post['countryCode'],
|
||||
'Country' => $post['country']
|
||||
);
|
||||
$userModel->insertAddressBook($data);
|
||||
|
||||
Auth::attempt(['email' => $post['email'], 'password' => $post['password']]);
|
||||
|
||||
return response()->json(array(
|
||||
'success' => true
|
||||
'success' => true,
|
||||
'redirect' => $post['redirect']
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\paypal;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
// use Paypal;
|
||||
use Netshell\Paypal\Facades\Paypal;
|
||||
@@ -18,6 +18,7 @@ use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
// use Mail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use PayPal\Exception\PayPalConnectionException;
|
||||
|
||||
|
||||
class PaypalController extends Controller
|
||||
@@ -28,30 +29,42 @@ class PaypalController extends Controller
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$paypal_env = "live";
|
||||
$paypal_apiUrl = 'https://api.paypal.com'; // default
|
||||
|
||||
if ($paypal_env == 'live') {
|
||||
$paypal_apiUrl = 'https://api.paypal.com';
|
||||
} else {
|
||||
$paypal_apiUrl = 'https://api.sandbox.paypal.com';
|
||||
}
|
||||
|
||||
$this->_apiContext = PayPal::ApiContext(
|
||||
config('services.paypal.client_id'),
|
||||
config('services.paypal.secret')
|
||||
config('services.paypal_' . $paypal_env . '.client_id'),
|
||||
config('services.paypal_' . $paypal_env . '.secret')
|
||||
|
||||
// config('services.paypal_live.client_id'),
|
||||
// config('services.paypal_live.secret')
|
||||
);
|
||||
|
||||
|
||||
// $this->_apiContext->setConfig(array(
|
||||
// 'mode' => 'sandbox',
|
||||
// 'service.EndPoint' => 'https://api.sandbox.paypal.com',
|
||||
// 'http.ConnectionTimeOut' => 30,
|
||||
// 'log.LogEnabled' => true,
|
||||
// 'log.FileName' => storage_path('logs/paypal.log'),
|
||||
// 'log.LogLevel' => 'FINE'
|
||||
// ));
|
||||
|
||||
// live
|
||||
$this->_apiContext->setConfig(array(
|
||||
'mode' => 'live',
|
||||
'service.EndPoint' => 'https://api.paypal.com',
|
||||
'mode' => $paypal_env,
|
||||
'service.EndPoint' => $paypal_apiUrl,
|
||||
'http.ConnectionTimeOut' => 30,
|
||||
'log.LogEnabled' => true,
|
||||
'log.FileName' => storage_path('logs/paypal.log'),
|
||||
'log.LogLevel' => 'FINE'
|
||||
));
|
||||
|
||||
// live
|
||||
// $this->_apiContext->setConfig(array(
|
||||
// 'mode' => 'sandbox',
|
||||
// 'service.EndPoint' => 'https://api.paypal.com',
|
||||
// 'http.ConnectionTimeOut' => 30,
|
||||
// 'log.LogEnabled' => true,
|
||||
// 'log.FileName' => storage_path('logs/paypal.log'),
|
||||
// 'log.LogLevel' => 'FINE'
|
||||
// ));
|
||||
}
|
||||
|
||||
|
||||
@@ -63,14 +76,52 @@ class PaypalController extends Controller
|
||||
|
||||
public function getCheckout(Request $request)
|
||||
{
|
||||
$UserModel = new UserModel;
|
||||
|
||||
if (Auth::guest()) {
|
||||
|
||||
$message = 'Please <a href="' . url('auth/login') . '">Sign in</a> to your account to proceed.';
|
||||
Session::flash('msg', $message);
|
||||
return Redirect::back();
|
||||
}
|
||||
|
||||
$userId = Auth::user()->id;
|
||||
$array_address_book = $UserModel->selectAddresBook('UserId', $userId);
|
||||
|
||||
if (count($array_address_book) <= 0) {
|
||||
$message = 'Please complete your shipping address. <a href="user/address-book/create"> <strong> <u>click here</u> </strong></a>.';
|
||||
Session::flash('cartkeyError', $message);
|
||||
return Redirect::back();
|
||||
}
|
||||
|
||||
$shipping_address_url = "user/address-book/edit/" . $array_address_book[0]->Id;
|
||||
|
||||
if (
|
||||
count($array_address_book) <= 0 ||
|
||||
$array_address_book[0]->Fullname == null ||
|
||||
$array_address_book[0]->ContactNumber == null ||
|
||||
$array_address_book[0]->Address == null ||
|
||||
$array_address_book[0]->State == null ||
|
||||
$array_address_book[0]->City == null ||
|
||||
$array_address_book[0]->ZipCode == null
|
||||
|
||||
) {
|
||||
$message = 'Please complete your shipping address. <a href="' . url($shipping_address_url) . '"> <strong> <u>click here</u> </strong></a>.';
|
||||
Session::flash('cartkeyError', $message);
|
||||
return Redirect::back();
|
||||
}
|
||||
|
||||
// $shippingAddress = [
|
||||
// "recipient_name" => $array_address_book[0]->Fullname,
|
||||
// "line1" => $array_address_book[0]->Address,
|
||||
// "line2" => "",
|
||||
// "city" => $array_address_book[0]->City,
|
||||
// "country_code" => $array_address_book[0]->CountryCode,
|
||||
// "postal_code" => $array_address_book[0]->ZipCode,
|
||||
// "state" => $array_address_book[0]->State,
|
||||
// "phone" => $array_address_book[0]->ContactNumber
|
||||
// ];
|
||||
|
||||
|
||||
// $request->session()->forget('cartkey');
|
||||
if (!$request->session()->has('cartkey')) {
|
||||
$message = 'Your cart is empty';
|
||||
@@ -81,81 +132,56 @@ class PaypalController extends Controller
|
||||
$payer = PayPal::Payer();
|
||||
$payer->setPaymentMethod('paypal');
|
||||
|
||||
// $inputFields = Paypal::InputFields();
|
||||
// $inputFields->setAllowNote(true)
|
||||
// ->setNoShipping(1)
|
||||
// ->setAddressOverride(0);
|
||||
// $webProfile = Paypal::WebProfile();
|
||||
// $webProfile->setName("YeowZa! T-Shirt Shop" . uniqid())
|
||||
// // ->setPresentation($presentation)
|
||||
// ->setInputFields($inputFields);
|
||||
|
||||
// $shipping = PayPal::ShippingAddress();
|
||||
// $shipping->setRecipientName($array_address_book[0]->Fullname);
|
||||
// $shipping->setLine1($array_address_book[0]->Address);
|
||||
// $shipping->setCity($array_address_book[0]->City);
|
||||
// $shipping->setCountryCode($array_address_book[0]->CountryCode);
|
||||
// $shipping->setPostalCode($array_address_book[0]->ZipCode);
|
||||
// $shipping->setState($array_address_book[0]->State);
|
||||
// $shipping->setPhone($array_address_book[0]->ContactNumber);
|
||||
|
||||
// $payerInfo = Paypal::PayerInfo();
|
||||
// $payerInfo->setShippingAddress($shipping);
|
||||
// $payer->setPayerInfo($payerInfo);
|
||||
|
||||
$m = new TeamStoreModel;
|
||||
$paypal_model = new PayPalModel;
|
||||
$last_id = $paypal_model->getLastIdPaymentDetails();
|
||||
$invoice_num = str_pad($last_id[0]->Id, 4, '0', STR_PAD_LEFT);
|
||||
// var_dump(count($last_id));
|
||||
if (count($last_id) > 0) {
|
||||
$lastId = $last_id[0]->Id + 1;
|
||||
} else {
|
||||
$lastId = 1;
|
||||
}
|
||||
$invoice_num = str_pad($lastId, 6, '0', STR_PAD_LEFT);
|
||||
// var_dump($invoice_num);
|
||||
$cartKey = $request->session()->get('cartkey');
|
||||
|
||||
$items = $m->myCart($cartKey);
|
||||
|
||||
$getSubtotal = $m->getSubtotal($cartKey);
|
||||
|
||||
$grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey);
|
||||
$store_array = $m->selectTeamStore('Id', $grouped_item[0]->StoreId);
|
||||
|
||||
$getSmallItemQty = 0;
|
||||
$getBulkyItemQty = 0;
|
||||
$getMaskItemQty = 0;
|
||||
$getDGSItemQty = 0;
|
||||
$shippingFee = 0;
|
||||
|
||||
$shippingFee = $this->getShippingFee($cartKey);
|
||||
|
||||
foreach ($items as $item) {
|
||||
if ($item->VoucherId != null) {
|
||||
$voucherIds[] = $item->VoucherId;
|
||||
$voucher = $m->selectVoucherWhereIn($voucherIds);
|
||||
$item_id = $item->Id;
|
||||
$totalValue = $voucher[0]->VoucherValue;
|
||||
if ($voucher[0]->VoucherType == "Percentage") {
|
||||
$getPercentageValue = $totalValue / 100;
|
||||
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
|
||||
$data = array(
|
||||
'Price' => round($getDiscountValue * -1, 2)
|
||||
);
|
||||
|
||||
$m->updateVoucherValueInCart($data, $item_id);
|
||||
} else {
|
||||
$voucherData = array(
|
||||
'totalValue' => $totalValue,
|
||||
'type' => 'Flat'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if($item->ShippingCostId == 1){
|
||||
$getSmallItemQty += $item->Quantity;
|
||||
}else if($item->ShippingCostId == 2){
|
||||
$getBulkyItemQty += $item->Quantity;
|
||||
}else if($item->ShippingCostId == 3){
|
||||
$getMaskItemQty += $item->Quantity;
|
||||
}else if($item->ShippingCostId == 4){
|
||||
$getDGSItemQty += $item->Quantity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$getSmallItemQty = ceil($getSmallItemQty / 3) * 8;
|
||||
$getBulkyItemQty = ceil($getBulkyItemQty / 1) * 8;
|
||||
$getMaskItemQty = ceil($getMaskItemQty / 25) * 8;
|
||||
$getMaskItemQty = ceil($getMaskItemQty / 4) * 5;
|
||||
$shippingFee = $getSmallItemQty + $getBulkyItemQty + $getMaskItemQty + $getDGSItemQty;
|
||||
// var_dump($shippingFee);
|
||||
$tax = $this->getTax($cartKey)['tax'];
|
||||
$order_grandtotal = $this->getTax($cartKey)['order_grandtotal'];
|
||||
|
||||
$order_items = array();
|
||||
$updated_items = $m->myCart($cartKey);
|
||||
$updated_getSubtotal = $m->getSubtotal($cartKey);
|
||||
|
||||
// $order_subtotal = $updated_getSubtotal[0]->Subtotal;
|
||||
$order_grandtotal = $updated_getSubtotal[0]->Subtotal;
|
||||
|
||||
if ($grouped_item[0]->StoreId == 76 || $grouped_item[0]->StoreId == 78 || $grouped_item[0]->StoreId == 111 || $grouped_item[0]->StoreId == 131 || $grouped_item[0]->StoreId == 30 || $grouped_item[0]->StoreId == 141 || $grouped_item[0]->StoreId == 162 || $grouped_item[0]->StoreId == 185) {
|
||||
$tax_value = 0;
|
||||
} else {
|
||||
$tax_value = 0.10;
|
||||
}
|
||||
|
||||
$tax = $order_grandtotal * $tax_value;
|
||||
|
||||
foreach ($updated_items as $key => $item) {
|
||||
|
||||
@@ -172,6 +198,29 @@ class PaypalController extends Controller
|
||||
|
||||
$item_list = PayPal::ItemList();
|
||||
$item_list->setItems($order_items);
|
||||
|
||||
$payment = PayPal::Payment();
|
||||
|
||||
// var_dump(array($transaction));
|
||||
if ($array_address_book[0]->CountryCode == "CA") {
|
||||
|
||||
$shipping = PayPal::ShippingAddress();
|
||||
$shipping->setRecipientName($array_address_book[0]->Fullname);
|
||||
$shipping->setLine1($array_address_book[0]->Address);
|
||||
$shipping->setLine2($array_address_book[0]->Address2);
|
||||
$shipping->setCity($array_address_book[0]->City);
|
||||
$shipping->setCountryCode($array_address_book[0]->CountryCode);
|
||||
$shipping->setPostalCode($array_address_book[0]->ZipCode);
|
||||
$shipping->setState($array_address_book[0]->State);
|
||||
$shipping->setPhone($array_address_book[0]->ContactNumber);
|
||||
$item_list->setShippingAddress($shipping);
|
||||
|
||||
$payment->setExperienceProfileId($this->createWebProfile());
|
||||
}
|
||||
|
||||
|
||||
// var_dump($item_list);
|
||||
|
||||
$amount_details = PayPal::Details();
|
||||
$amount_details->setSubtotal($order_grandtotal);
|
||||
$amount_details->setTax($tax);
|
||||
@@ -192,9 +241,10 @@ class PaypalController extends Controller
|
||||
$redirectUrls = PayPal::RedirectUrls();
|
||||
$redirectUrls->setReturnUrl(route('getDone'));
|
||||
$redirectUrls->setCancelUrl(route('getCancel'));
|
||||
// var_dump($shippingAddress)
|
||||
|
||||
|
||||
|
||||
$payment = PayPal::Payment();
|
||||
$payment->setIntent('sale');
|
||||
$payment->setPayer($payer);
|
||||
$payment->setRedirectUrls($redirectUrls);
|
||||
@@ -233,33 +283,151 @@ class PaypalController extends Controller
|
||||
|
||||
}
|
||||
|
||||
public function getShippingFee($cartKey)
|
||||
{
|
||||
|
||||
$m = new TeamStoreModel;
|
||||
$UserModel = new UserModel;
|
||||
$userId = 0;
|
||||
if (!Auth::guest()) {
|
||||
$userId = Auth::user()->id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$items = $m->myCart($cartKey); // item from cart_tmp
|
||||
$getSubtotal = $m->getSubtotal($cartKey);
|
||||
$getSmallItemQty = 0;
|
||||
$getBulkyItemQty = 0;
|
||||
$getMaskItemQty = 0;
|
||||
$getDGSItemQty = 0;
|
||||
$shippingFee = 0;
|
||||
$CAShippingfee = 0;
|
||||
|
||||
|
||||
foreach ($items as $item) {
|
||||
if ($item->VoucherId != null) {
|
||||
$voucherIds[] = $item->VoucherId;
|
||||
$voucher = $m->selectVoucherWhereIn($voucherIds);
|
||||
$item_id = $item->Id;
|
||||
$totalValue = $voucher[0]->VoucherValue;
|
||||
if ($voucher[0]->VoucherType == "Percentage") {
|
||||
$getPercentageValue = $totalValue / 100;
|
||||
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
|
||||
$data = array(
|
||||
'Price' => round($getDiscountValue * -1, 2)
|
||||
);
|
||||
|
||||
$m->updateVoucherValueInCart($data, $item_id);
|
||||
} else {
|
||||
$voucherData = array(
|
||||
'totalValue' => $totalValue,
|
||||
'type' => 'Flat'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($item->ShippingCostId == 1) {
|
||||
$getSmallItemQty += $item->Quantity;
|
||||
} else if ($item->ShippingCostId == 2) {
|
||||
$getBulkyItemQty += $item->Quantity;
|
||||
} else if ($item->ShippingCostId == 3) {
|
||||
$getMaskItemQty += $item->Quantity;
|
||||
} else if ($item->ShippingCostId == 4) {
|
||||
$getDGSItemQty += $item->Quantity;
|
||||
}
|
||||
|
||||
$CAShippingfee += $item->Quantity; // for canada
|
||||
}
|
||||
|
||||
$array_address_book = $UserModel->selectAddresBook('UserId', $userId);
|
||||
$countryCode = "";
|
||||
if (count($array_address_book) > 0) {
|
||||
$countryCode = $array_address_book[0]->CountryCode;
|
||||
$CAShippingfee = ceil($CAShippingfee / 2) * 30;
|
||||
}
|
||||
|
||||
$getSmallItemQty = ceil($getSmallItemQty / 3) * 8;
|
||||
$getBulkyItemQty = ceil($getBulkyItemQty / 1) * 8;
|
||||
$getMaskItemQty = ceil($getMaskItemQty / 25) * 8;
|
||||
$getDGSItemQty = ceil($getDGSItemQty / 4) * 5;
|
||||
$shippingFee = $getSmallItemQty + $getBulkyItemQty + $getMaskItemQty + $getDGSItemQty;
|
||||
|
||||
if ($countryCode == "CA") {
|
||||
$shippingFee = $CAShippingfee;
|
||||
}
|
||||
|
||||
return $shippingFee;
|
||||
}
|
||||
|
||||
public function getTax($cartKey)
|
||||
{
|
||||
$m = new TeamStoreModel;
|
||||
$updated_getSubtotal = $m->getSubtotal($cartKey);
|
||||
$grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey);
|
||||
|
||||
if (count($grouped_item) <= 0) {
|
||||
$tax_value = 0;
|
||||
} else {
|
||||
if ($grouped_item[0]->StoreId == 76 || $grouped_item[0]->StoreId == 78 || $grouped_item[0]->StoreId == 111 || $grouped_item[0]->StoreId == 131 || $grouped_item[0]->StoreId == 30 || $grouped_item[0]->StoreId == 141 || $grouped_item[0]->StoreId == 162 || $grouped_item[0]->StoreId == 185 || $grouped_item[0]->StoreId == 244) {
|
||||
$tax_value = 0;
|
||||
} else {
|
||||
$tax_value = 0.10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$order_grandtotal = $updated_getSubtotal[0]->Subtotal;
|
||||
|
||||
|
||||
|
||||
$tax = $order_grandtotal * $tax_value;
|
||||
|
||||
return [
|
||||
'tax' => $tax,
|
||||
'order_grandtotal' => $order_grandtotal,
|
||||
];
|
||||
}
|
||||
|
||||
public function getDone(Request $request)
|
||||
{
|
||||
|
||||
$paypal_model = new PayPalModel;
|
||||
$m = new TeamStoreModel;
|
||||
$cartKey = $request->session()->get('cartkey');
|
||||
$userId = Auth::user()->id;
|
||||
$user_email = Auth::user()->email;
|
||||
|
||||
|
||||
$checkCartKey = $paypal_model->checkCartKey($cartKey);
|
||||
|
||||
if (count($checkCartKey) > 0) {
|
||||
$message = 'You already paid for this order. Please check your Order Page. <a href="user/orders"> <strong> <u>click here</u> </strong></a>.';
|
||||
Session::put('cartkeyError', $message);
|
||||
return Redirect::route('cart');
|
||||
}
|
||||
|
||||
$id = $request->get('paymentId');
|
||||
$token = $request->get('token');
|
||||
$payer_id = $request->get('PayerID');
|
||||
|
||||
|
||||
try {
|
||||
$payment = PayPal::getById($id, $this->_apiContext);
|
||||
|
||||
$paymentExecution = PayPal::PaymentExecution();
|
||||
|
||||
$paymentExecution->setPayerId($payer_id);
|
||||
$executePayment = $payment->execute($paymentExecution, $this->_apiContext);
|
||||
|
||||
// print_r($executePayment);
|
||||
// if ($executePayment->getState() == 'approved') {
|
||||
|
||||
// /** it's all right **/
|
||||
// /** Here Write your database logic like that insert record or value in database if you want **/
|
||||
|
||||
// // \Session::put('success','Payment success');
|
||||
// // return Redirect::route('paywithpaypal');
|
||||
// echo 'Payment success';
|
||||
// }
|
||||
$obj = json_decode($executePayment);
|
||||
// var_dump($obj);
|
||||
|
||||
if ($executePayment->getState() == 'approved') {
|
||||
|
||||
/** it's all right **/
|
||||
/** Here Write your database logic like that insert record or value in database if you want **/
|
||||
|
||||
// \Session::put('success','Payment success');
|
||||
// return Redirect::route('paywithpaypal');
|
||||
$line2 = null;
|
||||
|
||||
//details
|
||||
@@ -273,7 +441,7 @@ class PaypalController extends Controller
|
||||
|
||||
$currency = $obj->transactions[0]->amount->currency;
|
||||
$invoice_number = $obj->transactions[0]->invoice_number;
|
||||
|
||||
// var_dump( $obj->transactions[0]->item_list->phone);
|
||||
//shipping address details
|
||||
$recipient_name = $obj->transactions[0]->item_list->shipping_address->recipient_name;
|
||||
$line1 = $obj->transactions[0]->item_list->shipping_address->line1;
|
||||
@@ -294,14 +462,7 @@ class PaypalController extends Controller
|
||||
|
||||
/// end paypal codes
|
||||
|
||||
$paypal_model = new PayPalModel;
|
||||
$m = new TeamStoreModel;
|
||||
$cartKey = $request->session()->get('cartkey');
|
||||
$userId = Auth::user()->id;
|
||||
$user_email = Auth::user()->email;
|
||||
|
||||
$items = $m->myCart($cartKey); // item from cart_tmp
|
||||
$getSubtotal = $m->getSubtotal($cartKey);
|
||||
|
||||
$payment_details = array(
|
||||
|
||||
@@ -366,7 +527,9 @@ class PaypalController extends Controller
|
||||
}
|
||||
|
||||
if ($other_email[0] != null) {
|
||||
$other_email = implode(", ", array_filter($other_email, function($value) { return !is_null($value) && $value !== ''; }));
|
||||
$other_email = implode(", ", array_filter($other_email, function ($value) {
|
||||
return !is_null($value) && $value !== '';
|
||||
}));
|
||||
$email_cc = "orders@crewsportswear.com" . "," . $other_email;
|
||||
} else {
|
||||
$email_cc = "orders@crewsportswear.com";
|
||||
@@ -408,6 +571,32 @@ class PaypalController extends Controller
|
||||
return view('paypal.get_done')
|
||||
->with('currency', $currency)
|
||||
->with('total', $total);
|
||||
} else {
|
||||
Session::put('cartkeyError', 'Something went wrong. Please try again.');
|
||||
return Redirect::route('cart');
|
||||
}
|
||||
} catch (PayPalConnectionException $e) {
|
||||
//throw $th;
|
||||
// echo $e->getCode();
|
||||
echo $e->getData();
|
||||
Session::put('cartkeyError', 'Invalid payment.');
|
||||
return Redirect::route('cart');
|
||||
}
|
||||
|
||||
|
||||
// print_r($executePayment);
|
||||
// if ($executePayment->getState() == 'approved') {
|
||||
|
||||
// /** it's all right **/
|
||||
// /** Here Write your database logic like that insert record or value in database if you want **/
|
||||
|
||||
// // \Session::put('success','Payment success');
|
||||
// // return Redirect::route('paywithpaypal');
|
||||
// echo 'Payment success';
|
||||
// }
|
||||
|
||||
// var_dump($obj->payer->payer_info->shipping_address);
|
||||
// var_dump($obj->transactions[0]->item_list->shipping_address);
|
||||
}
|
||||
|
||||
|
||||
@@ -419,6 +608,10 @@ class PaypalController extends Controller
|
||||
$items = $m->myCart($cartKey);
|
||||
$getSubtotal = $m->getSubtotal($cartKey);
|
||||
|
||||
if ($items == null) {
|
||||
return redirect()->route('cart');
|
||||
}
|
||||
|
||||
foreach ($items as $item) {
|
||||
if ($item->VoucherId != null) {
|
||||
$voucherIds[] = $item->VoucherId;
|
||||
@@ -441,4 +634,47 @@ class PaypalController extends Controller
|
||||
|
||||
return redirect()->route('cart');
|
||||
}
|
||||
|
||||
public function createWebProfile()
|
||||
{
|
||||
$UserModel = new UserModel;
|
||||
$userId = Auth::user()->id;
|
||||
$array_address_book = $UserModel->selectAddresBook('UserId', $userId);
|
||||
if (count($array_address_book) <= 0) {
|
||||
$message = 'Please add Shipping address.';
|
||||
Session::flash('cartkeyError', $message);
|
||||
return Redirect::back();
|
||||
}
|
||||
|
||||
// $shippingAddress = [
|
||||
// "recipient_name" => ,
|
||||
|
||||
$flowConfig = PayPal::FlowConfig();
|
||||
$presentation = PayPal::Presentation();
|
||||
$inputFields = PayPal::InputFields();
|
||||
$webProfile = PayPal::WebProfile();
|
||||
|
||||
|
||||
// $presentation->setLogoImage("https://www.crewsportswear.com/beta/public/images/logo.png")->setBrandName("Merchbay"); //NB: Paypal recommended to use https for the logo's address and the size set to 190x60.
|
||||
$presentation->setBrandName("Crewsportswear"); //NB: Paypal recommended to use https for the logo's address and the size set to 190x60.
|
||||
|
||||
if ($array_address_book[0]->CountryCode == "CA") {
|
||||
$flowConfig->setLandingPageType("Billing"); //Set the page type
|
||||
$inputFields->setAllowNote(true)->setAddressOverride(1);
|
||||
} else {
|
||||
$inputFields->setAllowNote(true)->setAddressOverride(0);
|
||||
}
|
||||
|
||||
|
||||
$webProfile->setName("Crewsportswear " . uniqid())
|
||||
->setFlowConfig($flowConfig)
|
||||
// Parameters for style and presentation.
|
||||
->setPresentation($presentation)
|
||||
// Parameters for input field customization.
|
||||
->setInputFields($inputFields);
|
||||
|
||||
$createProfileResponse = $webProfile->create($this->_apiContext);
|
||||
|
||||
return $createProfileResponse->getId(); //The new webprofile's id
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php namespace App\Http\Controllers\teamstore;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\teamstore;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
@@ -13,7 +15,8 @@ use Illuminate\Support\Facades\Mail;
|
||||
use Analytics;
|
||||
|
||||
|
||||
class TeamStoreController extends Controller {
|
||||
class TeamStoreController extends Controller
|
||||
{
|
||||
|
||||
public function index(Request $request, $teamStoreURL)
|
||||
{
|
||||
@@ -73,7 +76,6 @@ class TeamStoreController extends Controller {
|
||||
'thumb' => $displayThumbnails
|
||||
|
||||
);
|
||||
|
||||
} else {
|
||||
$thumbnails[] = array(
|
||||
'folder' => $store_array[0]->ImageFolder,
|
||||
@@ -151,7 +153,6 @@ class TeamStoreController extends Controller {
|
||||
// sort only
|
||||
$stores_array = $m->selectTeamstoreFilter($field, $sort_value);
|
||||
}
|
||||
|
||||
} else {
|
||||
$field = "StoreName";
|
||||
$sort_value = "ASC";
|
||||
@@ -175,11 +176,9 @@ class TeamStoreController extends Controller {
|
||||
if ($store_array) {
|
||||
$request->session()->put('teamstore_data_array', $store_array);
|
||||
return redirect('teamstore/' . $store_array[0]->StoreUrl);
|
||||
|
||||
} else {
|
||||
return redirect()->back()->with('errors', 'Invalid Password.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private $teams_array;
|
||||
@@ -234,7 +233,6 @@ class TeamStoreController extends Controller {
|
||||
->with('teams_array', $teams_array)
|
||||
->with('sizes_array', $sizes_array)
|
||||
->with('available_qty', $availableQty);
|
||||
|
||||
}
|
||||
|
||||
public function login(Request $request)
|
||||
@@ -280,8 +278,6 @@ class TeamStoreController extends Controller {
|
||||
->render();
|
||||
|
||||
return $handle_form;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function addToCart(Request $request)
|
||||
@@ -375,8 +371,6 @@ class TeamStoreController extends Controller {
|
||||
'Quantity' => $post['quantity'],
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
|
||||
|
||||
} elseif ($product_form == "name-number-form") {
|
||||
|
||||
$order_names = $post['order_names'];
|
||||
@@ -423,7 +417,6 @@ class TeamStoreController extends Controller {
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
}
|
||||
|
||||
} elseif ($product_form == "number-form") {
|
||||
|
||||
$order_number = $post['order_number'];
|
||||
@@ -521,7 +514,6 @@ class TeamStoreController extends Controller {
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
} elseif ($product_form == "number-jersey-shorts-form") {
|
||||
|
||||
@@ -571,9 +563,25 @@ class TeamStoreController extends Controller {
|
||||
));
|
||||
}
|
||||
|
||||
public function cart(Request $request){
|
||||
public function cart(Request $request)
|
||||
{
|
||||
|
||||
$m = new TeamStoreModel;
|
||||
$UserModel = new UserModel;
|
||||
$array_address_book = null;
|
||||
|
||||
if(!Auth::guest()){
|
||||
$userId = Auth::user()->id;
|
||||
$array_address_book = $UserModel->selectAddresBook('UserId', $userId);
|
||||
if (count($array_address_book) <= 0) {
|
||||
$array_address_book = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$cartKey = $request->session()->get('cartkey');
|
||||
$items = $m->myCart($cartKey);
|
||||
$getSubtotal = $m->getSubtotal($cartKey);
|
||||
@@ -628,15 +636,29 @@ class TeamStoreController extends Controller {
|
||||
$finalSubTotal = $getSubtotal[0]->Subtotal;
|
||||
}
|
||||
|
||||
if($cartKey != null) {
|
||||
$shippingFee = app(\App\Http\Controllers\paypal\PaypalController::class)->getShippingFee($cartKey);
|
||||
$tax = app(\App\Http\Controllers\paypal\PaypalController::class)->getTax($cartKey);
|
||||
}else{
|
||||
$shippingFee = 0;
|
||||
$tax = [];
|
||||
}
|
||||
|
||||
|
||||
return view('sublayouts.cart')
|
||||
->with('item_group', $items_group)
|
||||
->with('row', $items)
|
||||
->with('img_thumb', $item_thumbs)
|
||||
->with('getSubtotal', $finalSubTotal)
|
||||
->with('store_array', $store_array);
|
||||
->with('store_array', $store_array)
|
||||
->with('store_array', $store_array)
|
||||
->with('shipping_fee', $shippingFee)
|
||||
->with('tax', $tax)
|
||||
->with('address_book', $array_address_book);
|
||||
}
|
||||
|
||||
public function addVoucher(Request $request){
|
||||
public function addVoucher(Request $request)
|
||||
{
|
||||
$cartKey = $request->session()->get('cartkey');
|
||||
|
||||
if ($cartKey == "") {
|
||||
@@ -693,7 +715,6 @@ class TeamStoreController extends Controller {
|
||||
if ($item->VoucherId != null) {
|
||||
$voucherIds[] = $item->VoucherId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$vouchers = $TeamStoreModel->selectVoucherWhereIn($voucherIds);
|
||||
@@ -751,9 +772,6 @@ class TeamStoreController extends Controller {
|
||||
'message' => $message,
|
||||
'subtotal' => $finalSubTotal
|
||||
));
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
return response()->json(array(
|
||||
@@ -783,7 +801,6 @@ class TeamStoreController extends Controller {
|
||||
->with('row', $items)
|
||||
->with('getSubtotal', $getSubtotal)
|
||||
->with('array_address_book', $array_address_book);
|
||||
|
||||
}
|
||||
|
||||
public function mail()
|
||||
@@ -799,13 +816,10 @@ class TeamStoreController extends Controller {
|
||||
|
||||
|
||||
// dd('Mail Send Successfully');
|
||||
Mail::raw('Text to e-mail', function($message)
|
||||
{
|
||||
Mail::raw('Text to e-mail', function ($message) {
|
||||
$message->from('us@example.com', 'Laravel');
|
||||
|
||||
$message->to('frank.begornia@yahoo.com')->subject('sample email');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -79,11 +79,13 @@ class UserController extends Controller {
|
||||
'ContactNumber' => $post['mobilenumber'],
|
||||
'OtherNotes' => $post['othernotes'],
|
||||
'Address' => $post['address'],
|
||||
'Address2' => $post['address2'],
|
||||
'State' => $post['state'],
|
||||
'City' => $post['city'],
|
||||
'ZipCode' => $post['zipcode']
|
||||
'ZipCode' => $post['zipcode'],
|
||||
'CountryCode' => $post['countryCode'],
|
||||
'Country' => $post['country']
|
||||
);
|
||||
|
||||
echo $i = $m->insertAddressBook($data);
|
||||
|
||||
}
|
||||
@@ -116,11 +118,15 @@ class UserController extends Controller {
|
||||
'ContactNumber' => $post['mobilenumber'],
|
||||
'OtherNotes' => $post['othernotes'],
|
||||
'Address' => $post['address'],
|
||||
'Address2' => $post['address2'],
|
||||
'State' => $post['state'],
|
||||
'City' => $post['city'],
|
||||
'ZipCode' => $post['zipcode']
|
||||
'ZipCode' => $post['zipcode'],
|
||||
'CountryCode' => $post['countryCode'],
|
||||
'Country' => $post['country']
|
||||
);
|
||||
|
||||
|
||||
echo $i = $m->saveUpdateAddressBook($data, $id);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php namespace App\Http\Middleware;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class Authenticate {
|
||||
class Authenticate
|
||||
{
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
@@ -32,19 +36,19 @@ class Authenticate {
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest())
|
||||
{
|
||||
if ($request->ajax())
|
||||
{
|
||||
if ($this->auth->guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
$prev = URL::previous();
|
||||
if (str_contains($prev, ['cart'])) {
|
||||
return redirect()->guest('auth/register?redirectUrl='. $prev);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return redirect()->guest('auth/login');
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,4 +38,14 @@ class PayPalModel extends Model {
|
||||
// var_dump($i);
|
||||
return $i;
|
||||
}
|
||||
|
||||
function checkCartKey($ck){
|
||||
|
||||
$i = DB::table('payment_details')
|
||||
->where('CartKey', $ck)
|
||||
// ->take(1)
|
||||
->get();
|
||||
// var_dump($i);
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,13 +35,13 @@ return [
|
||||
],
|
||||
|
||||
// sandbox
|
||||
// 'paypal' => [
|
||||
// 'client_id' => 'AQuz-HKzQiL7FygkG8skSekaWf-RP6Rgj4f1XeX1Ghp86bUFj7tQXVT1xbpluu5_WCGRbQpOVGtlJKVB',
|
||||
// 'secret' => 'EJAMKxQsl-mFkL_4J_90cvTamYfcsgswqgIxz9wQPiRAwJ6sy_wNsttMlmrXIpxI96JpYzdMXkLCHAPz'
|
||||
// ],
|
||||
'paypal_sandbox' => [
|
||||
'client_id' => 'AQuz-HKzQiL7FygkG8skSekaWf-RP6Rgj4f1XeX1Ghp86bUFj7tQXVT1xbpluu5_WCGRbQpOVGtlJKVB',
|
||||
'secret' => 'EJAMKxQsl-mFkL_4J_90cvTamYfcsgswqgIxz9wQPiRAwJ6sy_wNsttMlmrXIpxI96JpYzdMXkLCHAPz'
|
||||
],
|
||||
|
||||
// live
|
||||
'paypal' => [
|
||||
'paypal_live' => [
|
||||
'client_id' => 'AUqBUFW5lfyYmrlBtFZA3RNw45sttM3ltbvS_d4qCVBMrkcMG9rEeivGvtNFSy8XTiEp50YyQ6khKxbq',
|
||||
'secret' => 'ELlnuiupoFKwGUSc2g5j-sD1EmsvKpdhth1gFV7njpfvyNtKsK8WwIKUMOS0ehJcRatV865eMhfgsnd_'
|
||||
],
|
||||
|
||||
372
public/api/canada.json
Normal file
372
public/api/canada.json
Normal file
@@ -0,0 +1,372 @@
|
||||
{
|
||||
"Alberta": [
|
||||
"Airdrie",
|
||||
"Grande Prairie",
|
||||
"Red Deer",
|
||||
"Beaumont",
|
||||
"Hanna",
|
||||
"St. Albert",
|
||||
"Bonnyville",
|
||||
"Hinton",
|
||||
"Spruce Grove",
|
||||
"Brazeau",
|
||||
"Irricana",
|
||||
"Strathcona County",
|
||||
"Breton",
|
||||
"Lacombe",
|
||||
"Strathmore",
|
||||
"Calgary",
|
||||
"Leduc",
|
||||
"Sylvan Lake",
|
||||
"Camrose",
|
||||
"Lethbridge",
|
||||
"Swan Hills",
|
||||
"Canmore",
|
||||
"McLennan",
|
||||
"Taber",
|
||||
"Didzbury",
|
||||
"Medicine Hat",
|
||||
"Turner Valley",
|
||||
"Drayton Valley",
|
||||
"Olds",
|
||||
"Vermillion",
|
||||
"Edmonton",
|
||||
"Onoway",
|
||||
"Wood Buffalo",
|
||||
"Ft. Saskatchewan",
|
||||
"Provost"
|
||||
],
|
||||
"British Columbia": [
|
||||
"Burnaby",
|
||||
"Lumby",
|
||||
"City of Port Moody",
|
||||
"Cache Creek",
|
||||
"Maple Ridge",
|
||||
"Prince George",
|
||||
"Castlegar",
|
||||
"Merritt",
|
||||
"Prince Rupert",
|
||||
"Chemainus",
|
||||
"Mission",
|
||||
"Richmond",
|
||||
"Chilliwack",
|
||||
"Nanaimo",
|
||||
"Saanich",
|
||||
"Clearwater",
|
||||
"Nelson",
|
||||
"Sooke",
|
||||
"Colwood",
|
||||
"New Westminster",
|
||||
"Sparwood",
|
||||
"Coquitlam",
|
||||
"North Cowichan",
|
||||
"Surrey",
|
||||
"Cranbrook",
|
||||
"North Vancouver",
|
||||
"Terrace",
|
||||
"Dawson Creek",
|
||||
"North Vancouver",
|
||||
"Tumbler",
|
||||
"Delta",
|
||||
"Osoyoos",
|
||||
"Vancouver",
|
||||
"Fernie",
|
||||
"Parksville",
|
||||
"Vancouver",
|
||||
"Invermere",
|
||||
"Peace River",
|
||||
"Vernon",
|
||||
"Kamloops",
|
||||
"Penticton",
|
||||
"Victoria",
|
||||
"Kaslo",
|
||||
"Port Alberni",
|
||||
"Whistler",
|
||||
"Langley",
|
||||
"Port Hardy"
|
||||
],
|
||||
"Manitoba": [
|
||||
"Birtle",
|
||||
"Flin Flon",
|
||||
"Swan River",
|
||||
"Brandon",
|
||||
"Snow Lake",
|
||||
"The Pas",
|
||||
"Cranberry Portage",
|
||||
"Steinbach",
|
||||
"Thompson",
|
||||
"Dauphin",
|
||||
"Stonewall",
|
||||
"Winnipeg"
|
||||
],
|
||||
"New Brunswick": [
|
||||
"Cap-Pele",
|
||||
"Miramichi",
|
||||
"Saint John",
|
||||
"Fredericton",
|
||||
"Moncton",
|
||||
"Saint Stephen",
|
||||
"Grand Bay-Westfield",
|
||||
"Oromocto",
|
||||
"Shippagan",
|
||||
"Grand Falls",
|
||||
"Port Elgin",
|
||||
"Sussex",
|
||||
"Memramcook",
|
||||
"Sackville",
|
||||
"Tracadie-Sheila"
|
||||
],
|
||||
"Newfoundland And Labrador": [
|
||||
"Argentia",
|
||||
"Corner Brook",
|
||||
"Paradise",
|
||||
"Bishop's Falls",
|
||||
"Labrador City",
|
||||
"Portaux Basques",
|
||||
"Botwood",
|
||||
"Mount Pearl",
|
||||
"St. John's",
|
||||
"Brigus"
|
||||
],
|
||||
"Northwest Territories": [
|
||||
"Town of Hay River",
|
||||
"Town of Inuvik",
|
||||
"Yellowknife"
|
||||
],
|
||||
"Nova Scotia": [
|
||||
"Amherst",
|
||||
"Hants County",
|
||||
"Pictou",
|
||||
"Annapolis",
|
||||
"Inverness County",
|
||||
"Pictou County",
|
||||
"Argyle",
|
||||
"Kentville",
|
||||
"Queens",
|
||||
"Baddeck",
|
||||
"County of Kings",
|
||||
"Richmond",
|
||||
"Bridgewater",
|
||||
"Lunenburg",
|
||||
"Shelburne",
|
||||
"Cape Breton",
|
||||
"Lunenburg County",
|
||||
"Stellarton",
|
||||
"Chester",
|
||||
"Mahone Bay",
|
||||
"Truro",
|
||||
"Cumberland County",
|
||||
"New Glasgow",
|
||||
"Windsor",
|
||||
"East Hants",
|
||||
"New Minas",
|
||||
"Yarmouth",
|
||||
"Halifax",
|
||||
"Parrsboro"
|
||||
],
|
||||
"Ontario": [
|
||||
"Ajax",
|
||||
"Halton",
|
||||
"Peterborough",
|
||||
"Atikokan",
|
||||
"Halton Hills",
|
||||
"Pickering",
|
||||
"Barrie",
|
||||
"Hamilton",
|
||||
"Port Bruce",
|
||||
"Belleville",
|
||||
"Hamilton-Wentworth",
|
||||
"Port Burwell",
|
||||
"Blandford-Blenheim",
|
||||
"Hearst",
|
||||
"Port Colborne",
|
||||
"Blind River",
|
||||
"Huntsville",
|
||||
"Port Hope",
|
||||
"Brampton",
|
||||
"Ingersoll",
|
||||
"Prince Edward",
|
||||
"Brant",
|
||||
"James",
|
||||
"Quinte West",
|
||||
"Brantford",
|
||||
"Kanata",
|
||||
"Renfrew",
|
||||
"Brock",
|
||||
"Kincardine",
|
||||
"Richmond Hill",
|
||||
"Brockville",
|
||||
"King",
|
||||
"Sarnia",
|
||||
"Burlington",
|
||||
"Kingston",
|
||||
"Sault Ste. Marie",
|
||||
"Caledon",
|
||||
"Kirkland Lake",
|
||||
"Scarborough",
|
||||
"Cambridge",
|
||||
"Kitchener",
|
||||
"Scugog",
|
||||
"Chatham-Kent",
|
||||
"Larder Lake",
|
||||
"Souix Lookout CoC Sioux Lookout",
|
||||
"Chesterville",
|
||||
"Leamington",
|
||||
"Smiths Falls",
|
||||
"Clarington",
|
||||
"Lennox-Addington",
|
||||
"South-West Oxford",
|
||||
"Cobourg",
|
||||
"Lincoln",
|
||||
"St. Catharines",
|
||||
"Cochrane",
|
||||
"Lindsay",
|
||||
"St. Thomas",
|
||||
"Collingwood",
|
||||
"London",
|
||||
"Stoney Creek",
|
||||
"Cornwall",
|
||||
"Loyalist Township",
|
||||
"Stratford",
|
||||
"Cumberland",
|
||||
"Markham",
|
||||
"Sudbury",
|
||||
"Deep River",
|
||||
"Metro Toronto",
|
||||
"Temagami",
|
||||
"Dundas",
|
||||
"Merrickville",
|
||||
"Thorold",
|
||||
"Durham",
|
||||
"Milton",
|
||||
"Thunder Bay",
|
||||
"Dymond",
|
||||
"Nepean",
|
||||
"Tillsonburg",
|
||||
"Ear Falls",
|
||||
"Newmarket",
|
||||
"Timmins",
|
||||
"East Gwillimbury",
|
||||
"Niagara",
|
||||
"Toronto",
|
||||
"East Zorra-Tavistock",
|
||||
"Niagara Falls",
|
||||
"Uxbridge",
|
||||
"Elgin",
|
||||
"Niagara-on-the-Lake",
|
||||
"Vaughan",
|
||||
"Elliot Lake",
|
||||
"North Bay",
|
||||
"Wainfleet",
|
||||
"Flamborough",
|
||||
"North Dorchester",
|
||||
"Wasaga Beach",
|
||||
"Fort Erie",
|
||||
"North Dumfries",
|
||||
"Waterloo",
|
||||
"Fort Frances",
|
||||
"North York",
|
||||
"Waterloo",
|
||||
"Gananoque",
|
||||
"Norwich",
|
||||
"Welland",
|
||||
"Georgina",
|
||||
"Oakville",
|
||||
"Wellesley",
|
||||
"Glanbrook",
|
||||
"Orangeville",
|
||||
"West Carleton",
|
||||
"Gloucester",
|
||||
"Orillia",
|
||||
"West Lincoln",
|
||||
"Goulbourn",
|
||||
"Osgoode",
|
||||
"Whitby",
|
||||
"Gravenhurst",
|
||||
"Oshawa",
|
||||
"Wilmot",
|
||||
"Grimsby",
|
||||
"Ottawa",
|
||||
"Windsor",
|
||||
"Guelph",
|
||||
"Ottawa-Carleton",
|
||||
"Woolwich",
|
||||
"Haldimand-Norfork",
|
||||
"Owen Sound",
|
||||
"York"
|
||||
],
|
||||
"Prince Edward Island": [
|
||||
"Alberton",
|
||||
"Montague",
|
||||
"Stratford",
|
||||
"Charlottetown",
|
||||
"Souris",
|
||||
"Summerside",
|
||||
"Cornwall"
|
||||
],
|
||||
"Quebec": [
|
||||
"Alma",
|
||||
"Fleurimont",
|
||||
"Longueuil",
|
||||
"Amos",
|
||||
"Gaspe",
|
||||
"Marieville",
|
||||
"Anjou",
|
||||
"Gatineau",
|
||||
"Mount Royal",
|
||||
"Aylmer",
|
||||
"Hull",
|
||||
"Montreal",
|
||||
"Beauport",
|
||||
"Joliette",
|
||||
"Montreal Region",
|
||||
"Bromptonville",
|
||||
"Jonquiere",
|
||||
"Montreal-Est",
|
||||
"Brosssard",
|
||||
"Lachine",
|
||||
"Quebec",
|
||||
"Chateauguay",
|
||||
"Lasalle",
|
||||
"Saint-Leonard",
|
||||
"Chicoutimi",
|
||||
"Laurentides",
|
||||
"Sherbrooke",
|
||||
"Coaticook",
|
||||
"LaSalle",
|
||||
"Sorel",
|
||||
"Coaticook",
|
||||
"Laval",
|
||||
"Thetford Mines",
|
||||
"Dorval",
|
||||
"Lennoxville",
|
||||
"Victoriaville",
|
||||
"Drummondville",
|
||||
"Levis"
|
||||
],
|
||||
"Saskatchewan": [
|
||||
"Avonlea",
|
||||
"Melfort",
|
||||
"Swift Current",
|
||||
"Colonsay",
|
||||
"Nipawin",
|
||||
"Tisdale",
|
||||
"Craik",
|
||||
"Prince Albert",
|
||||
"Unity",
|
||||
"Creighton",
|
||||
"Regina",
|
||||
"Weyburn",
|
||||
"Eastend",
|
||||
"Saskatoon",
|
||||
"Wynyard",
|
||||
"Esterhazy",
|
||||
"Shell Lake",
|
||||
"Yorkton",
|
||||
"Gravelbourg"
|
||||
],
|
||||
"Yukon": [
|
||||
"Carcross",
|
||||
"Whitehorse"
|
||||
]
|
||||
}
|
||||
238
public/api/usa.json
Normal file
238
public/api/usa.json
Normal file
@@ -0,0 +1,238 @@
|
||||
[
|
||||
{
|
||||
"name": "Alabama",
|
||||
"abbreviation": "AL"
|
||||
},
|
||||
{
|
||||
"name": "Alaska",
|
||||
"abbreviation": "AK"
|
||||
},
|
||||
{
|
||||
"name": "American Samoa",
|
||||
"abbreviation": "AS"
|
||||
},
|
||||
{
|
||||
"name": "Arizona",
|
||||
"abbreviation": "AZ"
|
||||
},
|
||||
{
|
||||
"name": "Arkansas",
|
||||
"abbreviation": "AR"
|
||||
},
|
||||
{
|
||||
"name": "California",
|
||||
"abbreviation": "CA"
|
||||
},
|
||||
{
|
||||
"name": "Colorado",
|
||||
"abbreviation": "CO"
|
||||
},
|
||||
{
|
||||
"name": "Connecticut",
|
||||
"abbreviation": "CT"
|
||||
},
|
||||
{
|
||||
"name": "Delaware",
|
||||
"abbreviation": "DE"
|
||||
},
|
||||
{
|
||||
"name": "District Of Columbia",
|
||||
"abbreviation": "DC"
|
||||
},
|
||||
{
|
||||
"name": "Federated States Of Micronesia",
|
||||
"abbreviation": "FM"
|
||||
},
|
||||
{
|
||||
"name": "Florida",
|
||||
"abbreviation": "FL"
|
||||
},
|
||||
{
|
||||
"name": "Georgia",
|
||||
"abbreviation": "GA"
|
||||
},
|
||||
{
|
||||
"name": "Guam",
|
||||
"abbreviation": "GU"
|
||||
},
|
||||
{
|
||||
"name": "Hawaii",
|
||||
"abbreviation": "HI"
|
||||
},
|
||||
{
|
||||
"name": "Idaho",
|
||||
"abbreviation": "ID"
|
||||
},
|
||||
{
|
||||
"name": "Illinois",
|
||||
"abbreviation": "IL"
|
||||
},
|
||||
{
|
||||
"name": "Indiana",
|
||||
"abbreviation": "IN"
|
||||
},
|
||||
{
|
||||
"name": "Iowa",
|
||||
"abbreviation": "IA"
|
||||
},
|
||||
{
|
||||
"name": "Kansas",
|
||||
"abbreviation": "KS"
|
||||
},
|
||||
{
|
||||
"name": "Kentucky",
|
||||
"abbreviation": "KY"
|
||||
},
|
||||
{
|
||||
"name": "Louisiana",
|
||||
"abbreviation": "LA"
|
||||
},
|
||||
{
|
||||
"name": "Maine",
|
||||
"abbreviation": "ME"
|
||||
},
|
||||
{
|
||||
"name": "Marshall Islands",
|
||||
"abbreviation": "MH"
|
||||
},
|
||||
{
|
||||
"name": "Maryland",
|
||||
"abbreviation": "MD"
|
||||
},
|
||||
{
|
||||
"name": "Massachusetts",
|
||||
"abbreviation": "MA"
|
||||
},
|
||||
{
|
||||
"name": "Michigan",
|
||||
"abbreviation": "MI"
|
||||
},
|
||||
{
|
||||
"name": "Minnesota",
|
||||
"abbreviation": "MN"
|
||||
},
|
||||
{
|
||||
"name": "Mississippi",
|
||||
"abbreviation": "MS"
|
||||
},
|
||||
{
|
||||
"name": "Missouri",
|
||||
"abbreviation": "MO"
|
||||
},
|
||||
{
|
||||
"name": "Montana",
|
||||
"abbreviation": "MT"
|
||||
},
|
||||
{
|
||||
"name": "Nebraska",
|
||||
"abbreviation": "NE"
|
||||
},
|
||||
{
|
||||
"name": "Nevada",
|
||||
"abbreviation": "NV"
|
||||
},
|
||||
{
|
||||
"name": "New Hampshire",
|
||||
"abbreviation": "NH"
|
||||
},
|
||||
{
|
||||
"name": "New Jersey",
|
||||
"abbreviation": "NJ"
|
||||
},
|
||||
{
|
||||
"name": "New Mexico",
|
||||
"abbreviation": "NM"
|
||||
},
|
||||
{
|
||||
"name": "New York",
|
||||
"abbreviation": "NY"
|
||||
},
|
||||
{
|
||||
"name": "North Carolina",
|
||||
"abbreviation": "NC"
|
||||
},
|
||||
{
|
||||
"name": "North Dakota",
|
||||
"abbreviation": "ND"
|
||||
},
|
||||
{
|
||||
"name": "Northern Mariana Islands",
|
||||
"abbreviation": "MP"
|
||||
},
|
||||
{
|
||||
"name": "Ohio",
|
||||
"abbreviation": "OH"
|
||||
},
|
||||
{
|
||||
"name": "Oklahoma",
|
||||
"abbreviation": "OK"
|
||||
},
|
||||
{
|
||||
"name": "Oregon",
|
||||
"abbreviation": "OR"
|
||||
},
|
||||
{
|
||||
"name": "Palau",
|
||||
"abbreviation": "PW"
|
||||
},
|
||||
{
|
||||
"name": "Pennsylvania",
|
||||
"abbreviation": "PA"
|
||||
},
|
||||
{
|
||||
"name": "Puerto Rico",
|
||||
"abbreviation": "PR"
|
||||
},
|
||||
{
|
||||
"name": "Rhode Island",
|
||||
"abbreviation": "RI"
|
||||
},
|
||||
{
|
||||
"name": "South Carolina",
|
||||
"abbreviation": "SC"
|
||||
},
|
||||
{
|
||||
"name": "South Dakota",
|
||||
"abbreviation": "SD"
|
||||
},
|
||||
{
|
||||
"name": "Tennessee",
|
||||
"abbreviation": "TN"
|
||||
},
|
||||
{
|
||||
"name": "Texas",
|
||||
"abbreviation": "TX"
|
||||
},
|
||||
{
|
||||
"name": "Utah",
|
||||
"abbreviation": "UT"
|
||||
},
|
||||
{
|
||||
"name": "Vermont",
|
||||
"abbreviation": "VT"
|
||||
},
|
||||
{
|
||||
"name": "Virgin Islands",
|
||||
"abbreviation": "VI"
|
||||
},
|
||||
{
|
||||
"name": "Virginia",
|
||||
"abbreviation": "VA"
|
||||
},
|
||||
{
|
||||
"name": "Washington",
|
||||
"abbreviation": "WA"
|
||||
},
|
||||
{
|
||||
"name": "West Virginia",
|
||||
"abbreviation": "WV"
|
||||
},
|
||||
{
|
||||
"name": "Wisconsin",
|
||||
"abbreviation": "WI"
|
||||
},
|
||||
{
|
||||
"name": "Wyoming",
|
||||
"abbreviation": "WY"
|
||||
}
|
||||
]
|
||||
250131
public/api/usaCities.json
250131
public/api/usaCities.json
File diff suppressed because it is too large
Load Diff
23909
public/api/usaCities.old.json
Normal file
23909
public/api/usaCities.old.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
@@ -27,12 +28,16 @@
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-136108155-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
|
||||
function gtag() {
|
||||
dataLayer.push(arguments);
|
||||
}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'UA-136108155-1');
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- <nav class="navbar navbar-default">
|
||||
<div class="container">
|
||||
@@ -118,12 +123,15 @@
|
||||
|
||||
$("#frm-register").validate({
|
||||
rules: {
|
||||
name: {
|
||||
firstname: {
|
||||
required: true
|
||||
},
|
||||
username: {
|
||||
lastname: {
|
||||
required: true
|
||||
},
|
||||
// username: {
|
||||
// required: true
|
||||
// },
|
||||
email: {
|
||||
required: true,
|
||||
email: true
|
||||
@@ -131,6 +139,24 @@
|
||||
password: {
|
||||
required: true
|
||||
//minlength: 6 // <-- removed underscore
|
||||
},
|
||||
mobilenumber: {
|
||||
required: true
|
||||
},
|
||||
address: {
|
||||
required: true
|
||||
},
|
||||
state: {
|
||||
required: true
|
||||
},
|
||||
city: {
|
||||
required: true
|
||||
},
|
||||
zipcode: {
|
||||
required: true
|
||||
},
|
||||
countryCode: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
messages: {},
|
||||
@@ -162,6 +188,147 @@
|
||||
|
||||
}); // end document ready
|
||||
|
||||
function getSelectedCountry() {
|
||||
var selectedState = $('#select_country').data('selected');
|
||||
if (selectedState) {
|
||||
// console.log(selectedState)
|
||||
$("#select_country").val(selectedState).change();
|
||||
// selectCountry()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function selectCountry(item) {
|
||||
|
||||
const country = item.options[item.selectedIndex].text;
|
||||
const countryCode = item.options[item.selectedIndex].value
|
||||
console.log(countryCode)
|
||||
|
||||
if (countryCode === "US") {
|
||||
fetchUSA()
|
||||
}
|
||||
|
||||
if (countryCode === "CA") {
|
||||
fetchCanada()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function fetchCanada() {
|
||||
$.getJSON("{{ asset('/public/api/canada.json') }}", function(items) {
|
||||
var states = [];
|
||||
|
||||
Object.keys(items).forEach(function(state) {
|
||||
states.push(state)
|
||||
});
|
||||
|
||||
var uniqueStates = Array.from(new Set(states));
|
||||
var selectedState = $('#lst-states').data('selected');
|
||||
|
||||
$('.dynamic-state').remove();
|
||||
$('.dynamic-city').remove();
|
||||
uniqueStates.sort().forEach(function(key) {
|
||||
if (selectedState == key) {
|
||||
$('#lst-states').append('<option value="' + key + '" selected class="dynamic-state">' + key + '</option>');
|
||||
|
||||
var cities = [];
|
||||
cities = items[selectedState];
|
||||
var uniqueCities = Array.from(new Set(cities));
|
||||
var selectedCity = $('#lst-cities').data('selected');
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
if (selectedCity == key) {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city" selected>' + key + '</option>');
|
||||
} else {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city">' + key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
$('#lst-states').append('<option value="' + key + '" class="dynamic-state">' + key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$(document).on('select change', '#lst-states', function() {
|
||||
var cities = [];
|
||||
var selectedState = $(this).val()
|
||||
cities = items[selectedState];
|
||||
var uniqueCities = Array.from(new Set(cities));
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city">' + key + '</option>');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function fetchUSA() {
|
||||
$.getJSON("{{ asset('/public/api/usaCities.json') }}", function(data) {
|
||||
var states = [];
|
||||
|
||||
for (i = 0; i < data.length; i++) {
|
||||
states.push(data[i]['state']);
|
||||
}
|
||||
var uniqueStates = Array.from(new Set(states));
|
||||
var selectedState = $('#lst-states').data('selected');
|
||||
$('.dynamic-state').remove();
|
||||
$('.dynamic-city').remove();
|
||||
uniqueStates.sort().forEach(function(key) {
|
||||
if (selectedState == key) {
|
||||
$('#lst-states').append('<option value="' + key + '" selected class="dynamic-state">' + key + '</option>');
|
||||
//
|
||||
var cities = [];
|
||||
for (i = 0; i < data.length; i++) {
|
||||
console.log(data[i])
|
||||
cities.push(data[i]);
|
||||
}
|
||||
var city = getCities(cities, key);
|
||||
var uniqueCities = Array.from(new Set(city));
|
||||
var selectedCity = $('#lst-cities').data('selected');
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
if (selectedCity == key) {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city" selected>' + key + '</option>');
|
||||
} else {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city">' + key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
$('#lst-states').append('<option value="' + key + '" class="dynamic-state">' + key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$(document).on('select change', '#lst-states', function() {
|
||||
var cities = [];
|
||||
for (i = 0; i < data.length; i++) {
|
||||
cities.push(data[i]);
|
||||
}
|
||||
var city = getCities(cities, $(this).val());
|
||||
var uniqueCities = Array.from(new Set(city));
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city">' + key + '</option>');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function getCities(arr, q) {
|
||||
var sd = [];
|
||||
arr.find(function(element) {
|
||||
if (element['state'] == q) {
|
||||
sd.push(element['city']);
|
||||
}
|
||||
});
|
||||
return sd;
|
||||
}
|
||||
|
||||
function submitLoginForm() {
|
||||
// method="POST" action="{{ url('/auth/login') }}"
|
||||
var data = $("#frm-login").serialize();
|
||||
@@ -197,7 +364,11 @@
|
||||
} /* login submit */
|
||||
|
||||
function submitRegisterForm() {
|
||||
var data = $("#frm-register").serialize();
|
||||
var data = $("#frm-register").serializeArray();
|
||||
data.push({
|
||||
name: "country",
|
||||
value: $("#select_country option:selected").text()
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@@ -213,7 +384,11 @@
|
||||
$("#register-response-msg").fadeIn(1000, function() {
|
||||
|
||||
if (response.success) {
|
||||
if (response.redirect != "") {
|
||||
window.location = response.redirect;
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
} else {
|
||||
$("#register-response-msg").html(response.message);
|
||||
}
|
||||
@@ -226,8 +401,7 @@
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -5,6 +5,7 @@
|
||||
.error {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.g-recaptcha {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -22,22 +23,37 @@
|
||||
<div class="col-xs-12">
|
||||
<div id="register-response-msg"></div>
|
||||
<form role="form" id="frm-register">
|
||||
<div class="form-group text-center">
|
||||
<h5>Personal Information</h5>
|
||||
</div>
|
||||
<input type="hidden" name="redirect" value="{{ Request::get('redirectUrl') }}">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">Fullname</label>
|
||||
<input type="text" class="form-control" name="name" value="{{ old('name') }}" placeholder="Fullname">
|
||||
<label class="control-label">First name</label>
|
||||
<input type="text" class="form-control" name="firstname" placeholder="First name">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">Last name</label>
|
||||
<input type="text" class="form-control" name="lastname" placeholder="Last name">
|
||||
</div>
|
||||
|
||||
<!-- <div class="form-group">
|
||||
<label class="control-label">Username</label>
|
||||
<input type="text" class="form-control" name="username" value="{{ old('username') }}" placeholder="Username">
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">Email Address</label>
|
||||
<input type="email" class="form-control" name="email" value="{{ old('email') }}" placeholder="Email Address">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">Phone Number</label>
|
||||
<input type="text" class="form-control" name="mobilenumber" placeholder="Phone Number">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">Password</label>
|
||||
<input type="password" class="form-control" name="password" id="password" required placeholder="Password">
|
||||
@@ -48,6 +64,50 @@
|
||||
<input type="password" class="form-control" name="password_confirmation" placeholder="Confirm Password" data-rule-equalTo="#password" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group text-center">
|
||||
<h5>Address Information</h5>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">Select Country</label>
|
||||
<select name="countryCode" id="select_country" class="form-control" onchange="selectCountry(this)">
|
||||
<option value="">Select Country</option>
|
||||
<option value="US">United States</option>
|
||||
<option value="CA">Canada</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">State / Province</label>
|
||||
<label></label>
|
||||
<select class="form-control" name="state" id="lst-states">
|
||||
<option value="">Select State</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">City</label>
|
||||
<select class="form-control" name="city" id="lst-cities">
|
||||
<option value="">Select City</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">Address 1</label>
|
||||
<input type="text" class="form-control" name="address" placeholder="Address 1">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">Address 2</label>
|
||||
<input type="text" class="form-control" name="address2" placeholder="Address 2">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">Zip Code</label>
|
||||
<input type="text" class="form-control" name="zipcode" placeholder="Please enter your zip code">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="g-recaptcha text-center" data-sitekey="{{ env('CAPTCHA_SITE_KEY') }}"></div>
|
||||
</div>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
@if(Session::has('cartkeyError'))
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="fa fa-exclamation-circle"></i> Error:</h4>
|
||||
<h4><i class="fa fa-exclamation-circle"></i> Almost there:</h4>
|
||||
{!! Session::get('cartkeyError') !!}
|
||||
</div>
|
||||
@endif
|
||||
@@ -52,8 +52,41 @@
|
||||
<h3>Order Summary</h3>
|
||||
</div>
|
||||
|
||||
@if (!Auth::guest())
|
||||
|
||||
<div style="border: 1px solid #e2e2e2; padding: 10px; border-bottom: none;">
|
||||
<h3>Subtotal: <span id="my_subtotal">{{ round($getSubtotal, 2) }}</span> <small>{{ $store_array[0]->StoreCurrency }}</small></h3>
|
||||
|
||||
<p><strong>Ship to:</strong></p>
|
||||
|
||||
@if ($address_book === null)
|
||||
<a href="{{ url('user/address-book/create') }}">[ Add ]</a>
|
||||
@else
|
||||
<div>{{ $address_book[0]->Fullname }}</div>
|
||||
<div>{{ $address_book[0]->ContactNumber }}</div>
|
||||
<div>
|
||||
{{ $address_book[0]->Address . ' ' . $address_book[0]->Address2 . ', ' . $address_book[0]->State . ', ' . $address_book[0]->City . ', ' . $address_book[0]->Country . ', ' . $address_book[0]->CountryCode . ' ' . $address_book[0]->ZipCode }}
|
||||
<a href="{{ url('user/address-book/edit/'.$address_book[0]->Id) }}">[ Edit ]</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div style="border: 1px solid #e2e2e2; padding: 10px; border-bottom: none;">
|
||||
{{-- <h3>Subtotal: <span id="my_subtotal">{{ round($getSubtotal, 2) }}</span> <small>{{ $store_array[0]->StoreCurrency }}</small></h3> --}}
|
||||
<h5><strong>Subtotal:</strong>
|
||||
<span>{{ number_format($tax['order_grandtotal'], 2) . ' ' . $store_array[0]->StoreCurrency }}</span>
|
||||
</h5>
|
||||
<h5><strong>Shipping Fee:</strong>
|
||||
<span>{{ number_format($shipping_fee, 2) . ' ' . $store_array[0]->StoreCurrency }}</span>
|
||||
</h5>
|
||||
<h5> <strong>Tax:</strong>
|
||||
<span>{{ number_format($tax['tax'], 2) . ' ' . $store_array[0]->StoreCurrency }}</span>
|
||||
</h5>
|
||||
<hr>
|
||||
<h3> <strong>Total:</strong> <span id="my_subtotal">{{ number_format($tax['order_grandtotal'] + $shipping_fee + $tax['tax'], 2) }}</span>
|
||||
<span>{{ $store_array[0]->StoreCurrency }}</span>
|
||||
</h3>
|
||||
<hr>
|
||||
<div class="form-group" id="voucher_list">
|
||||
@foreach($row as $item)
|
||||
|
||||
@@ -34,15 +34,13 @@
|
||||
<tr>
|
||||
<th>Full name</th>
|
||||
<th>Address</th>
|
||||
<th>Postcode</th>
|
||||
<th>Phone Number</th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
@foreach($array_address_book as $row)
|
||||
<tr>
|
||||
<td>{{ $row->Fullname }}</td>
|
||||
<td>{{ $row->Address }}</td>
|
||||
<td>{{ $row->State }}, {{ $row->City }}, {{ $row->ZipCode }}</td>
|
||||
<td>{{ $row->Address . ' ' . $row->Address2 }}, {{ $row->State }}, {{ $row->City }}, {{ $row->Country}} {{ $row->CountryCode}}, {{ $row->ZipCode }}</td>
|
||||
<td>{{ $row->ContactNumber }}</td>
|
||||
<td class="text-center">
|
||||
<a href="{{ url('user/address-book/edit/') }}/{{ $row->Id }}" class="btn btn-default btn-xs"><i class="fa fa-edit"></i> Edit</a>
|
||||
|
||||
@@ -46,11 +46,15 @@
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>House Number, Building and Street Name</label>
|
||||
<input type="text" class="form-control" name="address" placeholder="Please enter your House Number, Building and Street Name">
|
||||
<label>Country</label>
|
||||
<select class="form-control" name="countryCode" id="select_country" onchange="selectCountry(this)">
|
||||
<option value="">Select Country</option>
|
||||
<option value="US">United States</option>
|
||||
<option value="CA">Canada</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>State</label>
|
||||
<label>State / Province</label>
|
||||
<select class="form-control" name="state" id="lst-states">
|
||||
<option value="">Select State</option>
|
||||
</select>
|
||||
@@ -61,6 +65,14 @@
|
||||
<option value="">Select City</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Address 1</label>
|
||||
<textarea type="text" class="form-control" name="address" placeholder="Address 1"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Address 2</label>
|
||||
<textarea type="text" class="form-control" name="address2" placeholder="Address 2"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Zip Code</label>
|
||||
<input type="text" class="form-control" name="zipcode" placeholder="Please enter your zip code">
|
||||
|
||||
@@ -46,8 +46,12 @@
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label>House Number, Building and Street Name</label>
|
||||
<input type="text" class="form-control" name="address" placeholder="Please enter your House Number, Building and Street Name" value="{{ $array_address_book[0]->Address }}">
|
||||
<label>Country</label>
|
||||
<select class="form-control" name="countryCode" id="select_country" onchange="selectCountry(this)" data-selected="{{ $array_address_book[0]->CountryCode }}">
|
||||
<option value="">Select Country</option>
|
||||
<option value="US">United States</option>
|
||||
<option value="CA">Canada</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>State</label>
|
||||
@@ -61,6 +65,15 @@
|
||||
<option value="">Select City</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Address 1</label>
|
||||
<input type="text" class="form-control" name="address" placeholder="Address 1" value="{{ $array_address_book[0]->Address }}">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Address 2</label>
|
||||
<input type="text" class="form-control" name="address2" placeholder="Address 2" value="{{ $array_address_book[0]->Address2 }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Zip Code</label>
|
||||
<input type="text" class="form-control" name="zipcode" placeholder="Please enter your zip code" value="{{ $array_address_book[0]->ZipCode }}">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
@@ -51,47 +52,66 @@
|
||||
<![endif]-->
|
||||
|
||||
<style>
|
||||
.skin-black-light .wrapper, .skin-black-light .main-sidebar, .skin-black-light .left-side{
|
||||
.skin-black-light .wrapper,
|
||||
.skin-black-light .main-sidebar,
|
||||
.skin-black-light .left-side {
|
||||
background-color: #222d32;
|
||||
}
|
||||
|
||||
.skin-black-light .sidebar-menu>li:hover>a, .skin-black-light .sidebar-menu>li.active>a{
|
||||
.skin-black-light .sidebar-menu>li:hover>a,
|
||||
.skin-black-light .sidebar-menu>li.active>a {
|
||||
color: #fff;
|
||||
background: #1e282c;
|
||||
border-left-color: #fff;
|
||||
}
|
||||
|
||||
.skin-black-light .sidebar-menu>li.header {
|
||||
color: #4b646f;
|
||||
background: #1a2226;
|
||||
}
|
||||
|
||||
.skin-black-light .sidebar a {
|
||||
color: rgb(184, 199, 206);
|
||||
}
|
||||
.skin-black-light .user-panel>.info, .skin-black-light .user-panel>.info>a {
|
||||
|
||||
.skin-black-light .user-panel>.info,
|
||||
.skin-black-light .user-panel>.info>a {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.skin-black-light .sidebar-menu>li>.treeview-menu {
|
||||
margin: 0 1px;
|
||||
background: #2c3b41;
|
||||
}
|
||||
.skin-black-light .treeview-menu>li.active>a, .skin-black-light .treeview-menu>li>a:hover{
|
||||
|
||||
.skin-black-light .treeview-menu>li.active>a,
|
||||
.skin-black-light .treeview-menu>li>a:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.skin-black .treeview-menu>li>a {
|
||||
color: #8aa4af;
|
||||
}
|
||||
|
||||
.box.box-custom-color {
|
||||
border-top-color: #222d32;
|
||||
}
|
||||
|
||||
.carousel-inner>.item>a>img, .carousel-inner>.item>img, .img-responsive, .thumbnail a>img, .thumbnail>img, .product-center{
|
||||
.carousel-inner>.item>a>img,
|
||||
.carousel-inner>.item>img,
|
||||
.img-responsive,
|
||||
.thumbnail a>img,
|
||||
.thumbnail>img,
|
||||
.product-center {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.sports-border {
|
||||
border: 1px solid #e2e2e2;
|
||||
padding: 5px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.sport-edit-btn {
|
||||
margin-top: 5px;
|
||||
}
|
||||
@@ -159,7 +179,9 @@
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.wizard .nav-tabs > li.active > a, .wizard .nav-tabs > li.active > a:hover, .wizard .nav-tabs > li.active > a:focus {
|
||||
.wizard .nav-tabs>li.active>a,
|
||||
.wizard .nav-tabs>li.active>a:hover,
|
||||
.wizard .nav-tabs>li.active>a:focus {
|
||||
color: #555555;
|
||||
cursor: default;
|
||||
border: 0;
|
||||
@@ -180,14 +202,17 @@
|
||||
text-align: center;
|
||||
font-size: 25px;
|
||||
}
|
||||
|
||||
span.round-tab i {
|
||||
color: #555555;
|
||||
}
|
||||
|
||||
.wizard li.active span.round-tab {
|
||||
background: #fff;
|
||||
border: 2px solid #5bc0de;
|
||||
|
||||
}
|
||||
|
||||
.wizard li.active span.round-tab i {
|
||||
color: #5bc0de;
|
||||
}
|
||||
@@ -271,14 +296,17 @@
|
||||
left: 35%;
|
||||
}
|
||||
}
|
||||
|
||||
/*end*/
|
||||
|
||||
.custom-panel-footer.panel-footer {
|
||||
padding: 2px 2px;
|
||||
}
|
||||
|
||||
.custom-panel-body.panel-body {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.obj-container {
|
||||
height: 254px;
|
||||
width: 100%;
|
||||
@@ -287,7 +315,8 @@
|
||||
|
||||
|
||||
/*add pattern Select custom css*/
|
||||
.select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{
|
||||
.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,
|
||||
.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple {
|
||||
|
||||
border-radius: 0;
|
||||
border-color: #d2d6de;
|
||||
@@ -318,6 +347,7 @@
|
||||
color: #c5c5c5;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
/*end add pattern Select custom css*/
|
||||
|
||||
#template-img-preview {
|
||||
@@ -339,6 +369,7 @@
|
||||
div.list-group-item.active small {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.stars {
|
||||
margin: 20px auto 1px;
|
||||
}
|
||||
@@ -360,6 +391,7 @@
|
||||
.btn-custom-save {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: #F44336;
|
||||
}
|
||||
@@ -535,9 +567,11 @@
|
||||
position: relative;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.grid-divider>[class*='col-'] {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.grid-divider>[class*='col-']:nth-child(n+2):before {
|
||||
content: "";
|
||||
border-left: 1px solid #DDD;
|
||||
@@ -545,10 +579,12 @@
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.col-padding {
|
||||
padding: 0 15px;
|
||||
}
|
||||
}
|
||||
|
||||
/* table.dataTable td,table.dataTable th {
|
||||
padding: 3px 10px;
|
||||
width: 1px;
|
||||
@@ -560,7 +596,10 @@
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-136108155-1"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
|
||||
function gtag() {
|
||||
dataLayer.push(arguments);
|
||||
}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'UA-136108155-1');
|
||||
@@ -665,27 +704,46 @@
|
||||
|
||||
var min = $('#min').datepicker("getDate");
|
||||
var max = $('#max').datepicker("getDate");
|
||||
var startDate = new Date(data[10]);
|
||||
if (min == null && max == null) { return true; }
|
||||
if (min == null && startDate <= max) { return true;}
|
||||
if(max == null && startDate >= min) {return true;}
|
||||
if (startDate <= max && startDate >= min) { return true; }
|
||||
var startDate = new Date(data[12]);
|
||||
if (min == null && max == null) {
|
||||
return true;
|
||||
}
|
||||
if (min == null && startDate <= max) {
|
||||
return true;
|
||||
}
|
||||
if (max == null && startDate >= min) {
|
||||
return true;
|
||||
}
|
||||
if (startDate <= max && startDate >= min) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
$("#min").datepicker({ onSelect: function () { table.draw(); }, changeMonth: true, changeYear: true });
|
||||
$("#max").datepicker({ onSelect: function () { table.draw(); }, changeMonth: true, changeYear: true });
|
||||
$("#min").datepicker({
|
||||
onSelect: function() {
|
||||
table.draw();
|
||||
},
|
||||
changeMonth: true,
|
||||
changeYear: true
|
||||
});
|
||||
$("#max").datepicker({
|
||||
onSelect: function() {
|
||||
table.draw();
|
||||
},
|
||||
changeMonth: true,
|
||||
changeYear: true
|
||||
});
|
||||
|
||||
var table = $('#tbl_store_orders').DataTable({
|
||||
scrollX: true,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
{
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
exportOptions: {
|
||||
// columns: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ]
|
||||
columns: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]
|
||||
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
|
||||
},
|
||||
className: "btn btn-default",
|
||||
text: "<i class=\"fa fa-table\"></i> CSV",
|
||||
@@ -696,7 +754,7 @@
|
||||
{
|
||||
extend: 'excel',
|
||||
exportOptions: {
|
||||
columns: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]
|
||||
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
|
||||
},
|
||||
className: "btn btn-default",
|
||||
text: "<i class=\"fa fa-file-excel-o\"></i> Excel",
|
||||
@@ -734,9 +792,15 @@
|
||||
// }
|
||||
// }
|
||||
],
|
||||
columnDefs: [
|
||||
{ targets: 10, type: 'date', visible: false },
|
||||
{ targets: 10, type: 'date' }
|
||||
columnDefs: [{
|
||||
targets: 12,
|
||||
type: 'date',
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
targets: 12,
|
||||
type: 'date'
|
||||
}
|
||||
],
|
||||
|
||||
});
|
||||
@@ -955,57 +1019,6 @@
|
||||
|
||||
resend_timer();
|
||||
|
||||
$.getJSON("{{ asset('/public/api/usaCities.json') }}", function(data) {
|
||||
var states = [];
|
||||
|
||||
for(i = 0 ; i < data.length ; i++){
|
||||
states.push(data[i]['state']);
|
||||
}
|
||||
var uniqueStates = Array.from(new Set(states));
|
||||
// console.log(uniqueItems.sort())
|
||||
var selectedState = $('#lst-states').data('selected');
|
||||
uniqueStates.sort().forEach(function(key) {
|
||||
if(selectedState == key){
|
||||
$('#lst-states').append('<option value="'+key+'" selected>'+ key + '</option>');
|
||||
//
|
||||
var cities = [];
|
||||
for(i = 0 ; i < data.length ; i++){
|
||||
cities.push(data[i]);
|
||||
}
|
||||
var city = getCities(cities, key);
|
||||
var uniqueCities = Array.from(new Set(city));
|
||||
var selectedCity = $('#lst-cities').data('selected');
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
if(selectedCity == key){
|
||||
$('#lst-cities').append('<option value="'+key+'" class="dynamic-city" selected>'+ key + '</option>');
|
||||
}else{
|
||||
$('#lst-cities').append('<option value="'+key+'" class="dynamic-city">'+ key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
$('#lst-states').append('<option value="'+key+'">'+ key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$(document).on('select change', '#lst-states', function(){
|
||||
var cities = [];
|
||||
for(i = 0 ; i < data.length ; i++){
|
||||
cities.push(data[i]);
|
||||
}
|
||||
var city = getCities(cities, $(this).val());
|
||||
var uniqueCities = Array.from(new Set(city));
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
|
||||
$('#lst-cities').append('<option value="'+key+'" class="dynamic-city">'+ key + '</option>');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$("#frm-create-address-book").validate({
|
||||
rules: {
|
||||
@@ -1026,6 +1039,9 @@
|
||||
},
|
||||
zipcode: {
|
||||
required: true
|
||||
},
|
||||
countryCode: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1054,17 +1070,20 @@
|
||||
mobilenumber: {
|
||||
required: true
|
||||
},
|
||||
address: {
|
||||
required: true
|
||||
},
|
||||
state: {
|
||||
required: true
|
||||
},
|
||||
city: {
|
||||
required: true
|
||||
},
|
||||
address: {
|
||||
required: true
|
||||
},
|
||||
zipcode: {
|
||||
required: true
|
||||
},
|
||||
countryCode: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
messages: {},
|
||||
@@ -1515,8 +1534,15 @@
|
||||
// /[\\]/g matches backward slashes.
|
||||
});
|
||||
|
||||
$('#list').click(function(event){event.preventDefault();$('#products .item').addClass('list-group-item');});
|
||||
$('#grid').click(function(event){event.preventDefault();$('#products .item').removeClass('list-group-item');$('#products .item').addClass('grid-group-item');});
|
||||
$('#list').click(function(event) {
|
||||
event.preventDefault();
|
||||
$('#products .item').addClass('list-group-item');
|
||||
});
|
||||
$('#grid').click(function(event) {
|
||||
event.preventDefault();
|
||||
$('#products .item').removeClass('list-group-item');
|
||||
$('#products .item').addClass('grid-group-item');
|
||||
});
|
||||
|
||||
$('input[name="setActive"]').change(function() {
|
||||
if ($(this).prop('checked')) {
|
||||
@@ -1687,7 +1713,7 @@
|
||||
alert(response.message);
|
||||
window.location = "{{ url('user/store-items') }}";
|
||||
} else {
|
||||
alert(response.message);
|
||||
alert("Something went wrong. Please try again!");
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
@@ -1697,11 +1723,143 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
// fetchUSA()
|
||||
// fetchCanada()
|
||||
getSelectedCountry()
|
||||
}); //end document ready
|
||||
|
||||
// function
|
||||
|
||||
function getSelectedCountry() {
|
||||
var selectedState = $('#select_country').data('selected');
|
||||
if (selectedState) {
|
||||
// console.log(selectedState)
|
||||
$("#select_country").val(selectedState).change();
|
||||
// selectCountry()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function selectCountry(item) {
|
||||
|
||||
const country = item.options[item.selectedIndex].text;
|
||||
const countryCode = item.options[item.selectedIndex].value
|
||||
console.log(countryCode)
|
||||
|
||||
if (countryCode === "US") {
|
||||
fetchUSA()
|
||||
}
|
||||
|
||||
if (countryCode === "CA") {
|
||||
fetchCanada()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function fetchCanada() {
|
||||
$.getJSON("{{ asset('/public/api/canada.json') }}", function(items) {
|
||||
var states = [];
|
||||
|
||||
Object.keys(items).forEach(function(state) {
|
||||
states.push(state)
|
||||
});
|
||||
|
||||
var uniqueStates = Array.from(new Set(states));
|
||||
var selectedState = $('#lst-states').data('selected');
|
||||
|
||||
$('.dynamic-state').remove();
|
||||
$('.dynamic-city').remove();
|
||||
uniqueStates.sort().forEach(function(key) {
|
||||
if (selectedState == key) {
|
||||
$('#lst-states').append('<option value="' + key + '" selected class="dynamic-state">' + key + '</option>');
|
||||
|
||||
var cities = [];
|
||||
cities = items[selectedState];
|
||||
var uniqueCities = Array.from(new Set(cities));
|
||||
var selectedCity = $('#lst-cities').data('selected');
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
if (selectedCity == key) {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city" selected>' + key + '</option>');
|
||||
} else {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city">' + key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
$('#lst-states').append('<option value="' + key + '" class="dynamic-state">' + key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$(document).on('select change', '#lst-states', function() {
|
||||
var cities = [];
|
||||
var selectedState = $(this).val()
|
||||
cities = items[selectedState];
|
||||
var uniqueCities = Array.from(new Set(cities));
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city">' + key + '</option>');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function fetchUSA() {
|
||||
$.getJSON("{{ asset('/public/api/usaCities.json') }}", function(data) {
|
||||
var states = [];
|
||||
|
||||
for (i = 0; i < data.length; i++) {
|
||||
states.push(data[i]['state']);
|
||||
}
|
||||
var uniqueStates = Array.from(new Set(states));
|
||||
var selectedState = $('#lst-states').data('selected');
|
||||
$('.dynamic-state').remove();
|
||||
$('.dynamic-city').remove();
|
||||
uniqueStates.sort().forEach(function(key) {
|
||||
if (selectedState == key) {
|
||||
$('#lst-states').append('<option value="' + key + '" selected class="dynamic-state">' + key + '</option>');
|
||||
//
|
||||
var cities = [];
|
||||
for (i = 0; i < data.length; i++) {
|
||||
console.log(data[i])
|
||||
cities.push(data[i]);
|
||||
}
|
||||
var city = getCities(cities, key);
|
||||
var uniqueCities = Array.from(new Set(city));
|
||||
var selectedCity = $('#lst-cities').data('selected');
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
if (selectedCity == key) {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city" selected>' + key + '</option>');
|
||||
} else {
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city">' + key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
$('#lst-states').append('<option value="' + key + '" class="dynamic-state">' + key + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$(document).on('select change', '#lst-states', function() {
|
||||
var cities = [];
|
||||
for (i = 0; i < data.length; i++) {
|
||||
cities.push(data[i]);
|
||||
}
|
||||
var city = getCities(cities, $(this).val());
|
||||
var uniqueCities = Array.from(new Set(city));
|
||||
$('.dynamic-city').remove();
|
||||
uniqueCities.sort().forEach(function(key) {
|
||||
|
||||
$('#lst-cities').append('<option value="' + key + '" class="dynamic-city">' + key + '</option>');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function submitFormAnnouncement() {
|
||||
@@ -1767,7 +1925,9 @@
|
||||
'</div>').fadeIn().delay(5000).fadeOut();
|
||||
}
|
||||
|
||||
$("html, body").animate({ scrollTop: 0 }, "slow");
|
||||
$("html, body").animate({
|
||||
scrollTop: 0
|
||||
}, "slow");
|
||||
$("#btn_update_store").attr('disabled', false);
|
||||
$("#btn_update_store").html('Save Changes');
|
||||
|
||||
@@ -1788,6 +1948,7 @@
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function getCities(arr, q) {
|
||||
var sd = [];
|
||||
arr.find(function(element) {
|
||||
@@ -1799,7 +1960,11 @@
|
||||
}
|
||||
|
||||
function submitFormCreateAddressBook() {
|
||||
var data = $("#frm-create-address-book").serialize();
|
||||
var data = $("#frm-create-address-book").serializeArray();
|
||||
data.push({
|
||||
name: "country",
|
||||
value: $("#select_country option:selected").text()
|
||||
});
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "{{ url('user/address-book/save') }}",
|
||||
@@ -1816,7 +1981,7 @@
|
||||
// console.log(response);
|
||||
if (response) {
|
||||
alert("Address is successfully added.");
|
||||
window.location = "{{ url('user/address-book') }}";
|
||||
window.location = "{{ url('/cart') }}";
|
||||
} else {
|
||||
alert("Something went wrong. Please try again!");
|
||||
location.reload();
|
||||
@@ -1827,8 +1992,11 @@
|
||||
}
|
||||
|
||||
function submitFormEditAddressBook() {
|
||||
var data = $("#frm-edit-address-book").serialize();
|
||||
// console.log(data);
|
||||
var data = $("#frm-edit-address-book").serializeArray();
|
||||
data.push({
|
||||
name: "country",
|
||||
value: $("#select_country option:selected").text()
|
||||
});
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "{{ url('user/address-book/update') }}",
|
||||
@@ -1845,7 +2013,7 @@
|
||||
// console.log(response);
|
||||
if (response) {
|
||||
alert("Address is successfully updated.");
|
||||
window.location = "{{ url('user/address-book') }}";
|
||||
window.location = "{{ url('/cart') }}";
|
||||
} else {
|
||||
alert("Something went wrong. Please try again!");
|
||||
location.reload();
|
||||
@@ -1952,7 +2120,7 @@
|
||||
|
||||
function submitFormItemDetails() {
|
||||
var data = $("#frm-item-details").serialize();
|
||||
console.log(data)
|
||||
// console.log(data)
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "{{ url('user/store-items/update') }}",
|
||||
@@ -2159,4 +2327,5 @@
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user