diff --git a/packages/Webkul/Customer/src/Database/Seeders/CustomerGroupTableSeeder.php b/packages/Webkul/Customer/src/Database/Seeders/CustomerGroupTableSeeder.php index b4457f230..6a83e7b4d 100755 --- a/packages/Webkul/Customer/src/Database/Seeders/CustomerGroupTableSeeder.php +++ b/packages/Webkul/Customer/src/Database/Seeders/CustomerGroupTableSeeder.php @@ -19,6 +19,10 @@ class CustomerGroupTableSeeder extends Seeder 'id' => 2, 'name' => 'Wholesale', 'is_user_defined' => 0, + ], [ + 'id' => 3, + 'name' => 'Not Logged In', + 'is_user_defined' => 0, ]); } } \ No newline at end of file diff --git a/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php b/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php index d2befe446..a2270025d 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php @@ -67,7 +67,6 @@ class CustomerController extends Controller */ public function index() { - dd(auth()->guard('customer')->user()->group); $customer = $this->customer->find(auth()->guard('customer')->user()->id); return view($this->_config['view'], compact('customer')); diff --git a/packages/Webkul/Discount/src/Helpers/Discount.php b/packages/Webkul/Discount/src/Helpers/Discount.php new file mode 100644 index 000000000..d490199cd --- /dev/null +++ b/packages/Webkul/Discount/src/Helpers/Discount.php @@ -0,0 +1,33 @@ +cartRule = $cartRule; + } + + public function checkCoupon() + { + foreach($this->cartRule->all() as $rule) { + return $rule->name; + } + } + + public function findAllRules() + { + $rules = $this->cartRule->all(); + + $channel = core()->getCurrentChannel(); + $locales = $channel->locales; + } +} \ No newline at end of file diff --git a/packages/Webkul/Discount/src/Http/Controllers/CartRuleController.php b/packages/Webkul/Discount/src/Http/Controllers/CartRuleController.php index 7094c8c83..dd076665a 100644 --- a/packages/Webkul/Discount/src/Http/Controllers/CartRuleController.php +++ b/packages/Webkul/Discount/src/Http/Controllers/CartRuleController.php @@ -124,6 +124,11 @@ class CartRuleController extends Controller $data = request()->all(); + if ($data['starts_from'] == "" || $data['ends_till'] == "") { + $data['starts_from'] = null; + $data['ends_till'] = null; + } + unset($data['_token']); $channels = $data['channels']; diff --git a/packages/Webkul/Shop/src/Http/Controllers/HomeController.php b/packages/Webkul/Shop/src/Http/Controllers/HomeController.php index dc4f55dac..50e40b9b0 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/HomeController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/HomeController.php @@ -6,7 +6,8 @@ use Webkul\Shop\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Http\Response; use Webkul\Core\Repositories\SliderRepository; - +use Webkul\Discount\Repositories\CartRuleRepository as CartRule; +use Carbon\Carbon; /** * Home page controller * @@ -21,11 +22,15 @@ use Webkul\Core\Repositories\SliderRepository; protected $current_channel; - public function __construct(SliderRepository $sliderRepository) + protected $cartRule; + + public function __construct(SliderRepository $sliderRepository, CartRule $cartRule) { $this->_config = request('_config'); $this->sliderRepository = $sliderRepository; + + $this->cartRule = $cartRule; } /** @@ -35,6 +40,64 @@ use Webkul\Core\Repositories\SliderRepository; { $currentChannel = core()->getCurrentChannel(); + $rules = $this->cartRule->findWhere(['status' => 1, 'end_other_rules' => 1]); + + $suitableRules = array(); + if ($rules->count() == 0) { + $rules = $this->cartRule->findWhere(['status' => 1]); + } else { + foreach ($rules as $rule) { + foreach($rule->channels as $channel) { + if ($channel->channel_id == $currentChannel->id) { + if (auth()->guard('customer')->check()) { + foreach ($rule->customer_groups as $customerGroup) { + if (auth()->guard('customer')->user()->customer_group_id == $customerGroup->customer_group_id) + array_push($suitableRules, $rule); + } + } + } + } + } + + // suitable rules will now be checked against the + if (count($suitableRules) == 1) { + $rule = reset($suitableRules); + } else if (count($suitableRules) > 1) { + $priorities = array(); + + $leastPriority = 999999999999; + foreach ($suitableRules as $rule) { + if ($leastPriority > $rule->priority) { + $leastPriority = $rule->priority; + } + } + + $leastId = 999999999999; + foreach ($suitableRules as $rule) { + if ($rule->id < $leastId) { + $leastId = $rule->id; + } + } + + if ($leastId != 999999999999) { + $rule = $this->cartRule->find($leastId); + } + } + // foreach($rules as $rule) { + // foreach($rule->channels as $channel) { + + // } + // $starts_from = Carbon::parse($rule->starts_from); + // $ends_till = Carbon::parse($rule->ends_till); + + // $now = Carbon::now(); + + // if ($now->greaterThanOrEqualTo($starts_from) && $now->lessThanOrEqualTo($ends_till)) { + // dd('date time matched'); + // } + // } + } + $sliderData = $this->sliderRepository->findByField('channel_id', $currentChannel->id)->toArray(); return view($this->_config['view'], compact('sliderData')); diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss index f84567e73..69ce21f6b 100755 --- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss @@ -38,6 +38,116 @@ input { border-radius: 0px !important; } +//margin bottom classes +.mb-10 { + margin-bottom: 10px; +} + +.mb-15 { + margin-bottom: 15px; +} + +.mb-20 { + margin-bottom: 20px; +} + +.mb-25 { + margin-bottom: 25px; +} + +.mb-30 { + margin-bottom: 30px; +} + +.mb-35 { + margin-bottom: 35px; +} + +.mb-40 { + margin-bottom: 40px; +} + +.mb-45 { + margin-bottom: 45px; +} + +.mb-50 { + margin-bottom: 50px; +} + +.mb-60 { + margin-bottom: 60px; +} + +.mb-70 { + margin-bottom: 70px; +} + +.mb-80 { + margin-bottom: 80px; +} + +.mb-90 { + margin-bottom: 90px; +} + +//margin-top +.mt-5 { + margin-top: 5px; +} + +.mt-10 { + margin-top: 10px; +} + +.mt-15 { + margin-top: 15px; +} + +.mt-20 { + margin-top: 20px; +} + +.mt-25 { + margin-top: 25px; +} + +.mt-30 { + margin-top: 30px; +} + +.mt-35 { + margin-top: 35px; +} + +.mt-40 { + margin-top: 40px; +} + +.mt-45 { + margin-top: 45px; +} + +.mt-50 { + margin-top: 50px; +} + +.mt-60 { + margin-top: 60px; +} + +.mt-70 { + margin-top: 70px; +} + +.mt-80 { + margin-top: 80px; +} + +.mt-90 { + margin-top: 90px; +} + //pagination .pagination.shop{ display: flex; diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/review.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/review.blade.php index 8ef912c1c..a49052d8b 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/review.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/review.blade.php @@ -165,9 +165,7 @@