Pre Loaded

This commit is contained in:
prashant-webkul 2018-11-05 10:25:05 +05:30
parent 11095b3176
commit 3a801a5d72
9 changed files with 35119 additions and 11 deletions

View File

@ -532,9 +532,9 @@ class Cart {
$this->collectTotals();
return redirect()->back();
return true;
} else {
return redirect()->back();
return true;
}
}
@ -615,7 +615,7 @@ class Cart {
session()->forget('cart');
session()->flash('success', trans('shop::app.checkout.cart.quantity.success_remove'));
session()->flash('success', trans('shop::app.checkout.cart.item.success-remove'));
}
}
}
@ -633,7 +633,7 @@ class Cart {
if ($quantity < 1) {
session()->flash('warning', trans('shop::app.checkout.cart.quantity.warning'));
return redirect()->back();
return false;
}
$item = $this->cartItem->findOneByField('id', $itemId);
@ -893,6 +893,7 @@ class Cart {
public function validateItems() {
$cart = $this->getCart();
//rare case of accident-->used when there are no items.
if(count($cart->items) == 0) {
$this->cart->delete($cart->id);

View File

@ -0,0 +1,92 @@
<?php
namespace Webkul\Core\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Core\Repositories\CountryRepository as Country;
use Webkul\Core\Repositories\CountryStateRepository as State;
/**
* Country controller
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CountryStateController extends Controller
{
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* CountryRepository object
*
* @var array
*/
protected $country;
/**
* StateRepository object
*
* @var array
*/
protected $state;
/**
* Create a new controller instance.
*
* @param Webkul\Core\Repositories\CountryRepository $country
* @return void
*/
public function __construct(Country $country, State $state)
{
$this->country = $country;
$this->state = $state;
$this->_config = request('_config');
}
/**
* Function to retrieve states with respect to countries with codes and names for both of the countries and states.
*
* @return array
*/
public function getCountries() {
$countries = $this->country->all();
$states = $this->state->all();
$nestedArray = [];
foreach($countries as $keyCountry => $country) {
foreach($states as $keyState => $state) {
if($country->code == $state->country_code) {
$nestedArray[$country->name][$state->code] = $state->default_name;
}
}
}
return view($this->_config['view'])->with('statesCountries', $nestedArray);
}
public function getStates($country) {
$countries = $this->country->all();
$states = $this->state->all();
$nestedArray = [];
foreach($countries as $keyCountry => $country) {
foreach($states as $keyState => $state) {
if($country->code == $state->country_code) {
$nestedArray[$country->name][$state->code] = $state->default_name;
}
}
}
return view($this->_config['view'])->with('statesCountries', $nestedArray);
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
{
"/js/shop.js": "/js/shop.js?id=55f8798e657b22f380c9",
"/css/shop.css": "/css/shop.css?id=4def3ab1fb731fea6751"
"/js/shop.js": "/js/shop.js",
"/css/shop.css": "/css/shop.css"
}

View File

@ -17,6 +17,16 @@ Route::group(['middleware' => ['web', 'theme', 'locale', 'currency']], function
'view' => 'shop::search.search'
])->name('shop.search.index');
//Country State Selector
Route::get('get/countries', 'Webkul\Core\Http\Controllers\CountryStateController@getCountries')->defaults('_config', [
'view' => 'shop::test'
])->name('get.countries');
//Get States When Country is Passed
Route::get('get/states/{country}', 'Webkul\Core\Http\Controllers\CountryStateController@getStates')->defaults('_config', [
'view' => 'shop::test'
])->name('get.states');
//checkout and cart
//Cart Items(listing)
Route::get('checkout/cart', 'Webkul\Shop\Http\Controllers\CartController@index')->defaults('_config', [

View File

@ -131,7 +131,6 @@
//buy now anchor href changer with options
var buyNowLink = $('#buynow-changer').attr('href');
if(this.selectedProductId != '') {
var splitted = buyNowLink.split("/");

View File

@ -0,0 +1,50 @@
@extends('shop::layouts.master')
@section('page_title')
{{ __('shop::app.home.page-title') }}
@endsection
@section('content-wrapper')
{{-- <ul>
@foreach ($statesCountries as $key => $stateCountry)
<li><h3>{{ $key }}</h3></li>
<select>
@foreach ($stateCountry as $key1 => $state)
<option value="{{$key1}}">{{ $state }}</option>
@endforeach
</select>
@endforeach
</ul> --}}
<script type="text/x-template" id="country-state-select">
<div>
<li>
<h3>{{ $key }}</h3>
</li>
<select v-model="country">
</select>
</div>
</script>
<script>
var countryState = @json($statesCountries);
Vue.component('country-state-select', {
template: '#country-state-select',
data: () => ({
country: '',
state: ''
});
mounted: function() {
for(country in statesCountries) {
console.log(country);
}
}
});
</script>
@endsection

View File

@ -1,8 +1,8 @@
const { mix } = require("laravel-mix");
require("laravel-mix-merge-manifest");
var publicPath = 'publishable/assets';
// var publicPath = "../../../public/themes/default/assets";
// var publicPath = 'publishable/assets';
var publicPath = "../../../public/themes/default/assets";
mix.setPublicPath(publicPath).mergeManifest();
mix.disableNotifications();