diff --git a/README.md b/README.md index 4cdfa92e5..115fa6419 100755 --- a/README.md +++ b/README.md @@ -12,10 +12,11 @@ # Topics 1. ### [Introduction](#1-introduction-) -2. ### [Requirements](#2-requirements-) -3. ### [Installation & Configuration](#3-installation--configuration-) -4. ### [License](#4-license-) -5. ### [Miscellaneous](#user-content-6-miscellaneous--) +2. ### [Documentation](#2-documentation-) +3. ### [Requirements](#2-requirements-) +4. ### [Installation & Configuration](#3-installation--configuration-) +5. ### [License](#4-license-) +6. ### [Miscellaneous](#5-miscellaneous-) ### 1. Introduction : @@ -53,7 +54,11 @@ It packs in lots of demanding features that allows your business to scale in no Dev guys can take advantage of two of the hottest frameworks used in this project Laravel and Vue.js, both of these frameworks have been used in Bagisto. Bagisto is using power of both of these frameworks and making best out of it out of the box. -### 2. Requirements : +### 2. Documentation : + +# Visit our [Documentation](https://devdocs.bagisto.com) + +### 3. Requirements : * **OS**: Ubuntu 16.04 LTS or higher. * **SERVER**: Apache 2 or NGINX @@ -65,7 +70,7 @@ Bagisto is using power of both of these frameworks and making best out of it out * **Node**: 8.11.3 LTS or higher. * **Composer**: 1.6.5 or higher. -### 3. Installation & Configuration : +### 4. Installation & Configuration : **1. Try our new GUI installer to install Bagisto:** diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index ff9798a88..b23742e1e 100755 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -805,7 +805,7 @@ return [ 'uses-per-cust' => 'Uses per customer', 'all' => 'All', 'any' => 'Any', - 'end_other_rules' => 'End other rules', + 'end-other-rules' => 'End other rules', 'status' => 'Is Active', 'all-conditions-true' => 'Assuming all conditions are true', 'assuming' => 'Assuming', diff --git a/packages/Webkul/Admin/src/Resources/views/promotions/cart-rule/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/promotions/cart-rule/edit.blade.php index 961709f71..60b272517 100644 --- a/packages/Webkul/Admin/src/Resources/views/promotions/cart-rule/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/promotions/cart-rule/edit.blade.php @@ -301,9 +301,9 @@
- + - diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 90c05c387..e751a64ea 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -893,7 +893,7 @@ class Cart { } $item->update([ - 'price' => $price, + 'price' => core()->convertPrice($price), 'base_price' => $price, 'total' => core()->convertPrice($price * ($item->quantity)), 'base_total' => $price * ($item->quantity), @@ -917,7 +917,7 @@ class Cart { } $item->update([ - 'price' => $price, + 'price' => core()->convertPrice($price), 'base_price' => $price, 'total' => core()->convertPrice($price * ($item->quantity)), 'base_total' => $price * ($item->quantity), @@ -1311,6 +1311,7 @@ class Cart { $leastValue = $item->price; $leastSubTotal = [ 'id' => $item->id, + 'total' => $item->total, 'base_total' => $leastValue, 'quantity' => $item->quantity ]; @@ -1331,6 +1332,7 @@ class Cart { $maxValue = $item->total; $maxSubTotal = [ 'id' => $item->id, + 'total' => $item->total, 'base_total' => $maxValue, 'quantity' => $item->quantity ]; diff --git a/packages/Webkul/Discount/src/Helpers/Discount.php b/packages/Webkul/Discount/src/Helpers/Discount.php index f57542acd..6d4d0d08e 100644 --- a/packages/Webkul/Discount/src/Helpers/Discount.php +++ b/packages/Webkul/Discount/src/Helpers/Discount.php @@ -336,10 +336,10 @@ class Discount $result = $this->applyNonCouponAble(); $cart = \Cart::getCart(); $maxImpacts = array(); - // dd($result); + if (isset($result['id']) && count($result['id'])) { $rules = array(); - // dd(2); + if (count($result['id']) > 1) { $leastPriority = 999999999999; @@ -401,7 +401,7 @@ class Discount $disc_amount = $rule->disc_amount; $disc_quantity = $rule->disc_quantity; - $newBaseSubTotal = 0; + $amountDiscounted = 0; $newQuantity = 0; if ($cart->items_qty >= $disc_threshold && $disc_quantity > 0) { @@ -414,22 +414,22 @@ class Discount if ($action_type == config('pricerules.cart.validation.0')) { if ($realQty <= $disc_quantity) { - $newBaseSubTotal = $cart->grand_total - ($leastWorthItem['base_total'] * ($disc_amount * $disc_quantity)) / 100; + $amountDiscounted = (($leastWorthItem['total'] / $realQty) * ($disc_amount / 100)) * $disc_quantity; } else { - $newBaseSubTotal = $cart->grand_total - ($leastWorthItem['base_total'] * $disc_amount) / 100; + $amountDiscounted = ($leastWorthItem['total'] / $realQty) * ($disc_amount / 100); } } else if ($action_type == config('pricerules.cart.validation.1')) { if ($realQty <= $disc_quantity) { - if ($disc_amount > ($disc_quantity * $leastWorthItem['base_total'])) { - $newBaseSubTotal = 0; + if ($disc_amount > ($disc_quantity * $leastWorthItem['total'])) { + $amountDiscounted = 0; } else { - $newBaseSubTotal = $cart->grand_total - $disc_amount; + $amountDiscounted = $cart->sub_total - $disc_amount; } } else { - if ($disc_amount > $leastWorthItem['base_total']) { - $newBaseSubTotal = 0; + if ($disc_amount > $leastWorthItem['total']) { + $amountDiscounted = 0; } else { - $newBaseSubTotal = $cart->grand_total - $disc_amount; + $amountDiscounted = $cart->sub_total - $disc_amount; } } } else if ($action_type == config('pricerules.cart.validation.2')) { @@ -439,7 +439,7 @@ class Discount $newQuantity = $this->cartItem->find($leastWorthItem['id'])->quantity + $disc_quantity; } } else if ($action_type == config('pricerules.cart.validation.3')) { - $newBaseSubTotal = $disc_amount; + $amountDiscounted = $disc_amount; } //standard returns @@ -458,7 +458,7 @@ class Discount 'rule' => $rule, 'item_id' => $leastWorthItem['id'], 'amount_given' => true, - 'amount' => $newBaseSubTotal, + 'amount' => $amountDiscounted, 'action_type' => $action_type ]); } @@ -506,7 +506,7 @@ class Discount ]); } - return ['rule' => $maxImpacts[$leastId]['rule'], 'impact' => $maxImpacts[$leastId], 'endRuleActive' => $this->endRuleActive, 'success' => true]; + return ['rule' => $maxImpacts[$leastId]['rule'], 'impact' => $maxImpacts[$leastId], 'success' => true]; } } @@ -585,7 +585,7 @@ class Discount $disc_amount = $rule->disc_amount; $disc_quantity = $rule->disc_quantity; - $newBaseSubTotal = 0; + $amountDiscounted = 0; $newQuantity = 0; if ($cart->items_qty >= $disc_threshold && $disc_quantity > 0) { @@ -598,22 +598,22 @@ class Discount if ($action_type == config('pricerules.cart.validation.0')) { if ($realQty <= $disc_quantity) { - $newBaseSubTotal = $cart->grand_total - ($leastWorthItem['base_total'] * ($disc_amount * $disc_quantity)) / 100; + $amountDiscounted = (($leastWorthItem['total'] / $realQty) * ($disc_amount / 100)) * $disc_quantity; } else { - $newBaseSubTotal = $cart->grand_total - ($leastWorthItem['base_total'] * $disc_amount) / 100; + $amountDiscounted = ($leastWorthItem['total'] / $realQty) * ($disc_amount / 100); } } else if ($action_type == config('pricerules.cart.validation.1')) { if ($realQty <= $disc_quantity) { - if ($disc_amount > ($disc_quantity * $leastWorthItem['base_total'])) { - $newBaseSubTotal = 0; + if ($disc_amount > ($disc_quantity * $leastWorthItem['total'])) { + $amountDiscounted = 0; } else { - $newBaseSubTotal = $cart->grand_total - $disc_amount; + $amountDiscounted = $cart->sub_total - $disc_amount; } } else { - if ($disc_amount > $leastWorthItem['base_total']) { - $newBaseSubTotal = 0; + if ($disc_amount > $leastWorthItem['total']) { + $amountDiscounted = 0; } else { - $newBaseSubTotal = $cart->grand_total - $disc_amount; + $amountDiscounted = $cart->sub_total - $disc_amount; } } } else if ($action_type == config('pricerules.cart.validation.2')) { @@ -623,7 +623,7 @@ class Discount $newQuantity = $this->cartItem->find($leastWorthItem['id'])->quantity + $disc_quantity; } } else if ($action_type == config('pricerules.cart.validation.3')) { - $newBaseSubTotal = $disc_amount; + $amountDiscounted = $disc_amount; } if ($action_type == config('pricerules.cart.validation.2')) { @@ -669,16 +669,21 @@ class Discount } return response()->json([ + 'id' => $appliedRule->id, + 'rule' => $appliedRule, + 'item_id' => $leastWorthItem['id'], 'message' => trans('admin::app.promotion.status.coupon-applied'), - 'action' => $action_type, 'amount_given' => true, - 'amount_payable' => core()->currency($newBaseSubTotal + $cart->tax_total), - 'amount' => core()->currency($cart->grand_total - $newBaseSubTotal), + 'amount' => $amountDiscounted, + 'action_type' => $action_type, 'success' => true ]); } } else { return response()->json([ + 'id' => null, + 'rule' => null, + 'item_id' => null, 'message' => trans('admin::app.promotion.status.coupon-failed'), 'action' => $action_type, 'amount_given' => null, @@ -689,6 +694,9 @@ class Discount } } else { return response()->json([ + 'id' => null, + 'rule' => null, + 'item_id' => null, 'message' => trans('admin::app.promotion.status.coupon-failed'), 'action' => null, 'amount_given' => null, @@ -771,20 +779,16 @@ class Discount break; } } else if ($test_condition == '()') { - // dd($test_condition); } else if ($test_condition == '!()') { - // dd($test_condition); } } - // else if ($condition->type == 'boolean') { - // if ($test_conditions[$condition->type][$test_condition]) { - // if ($test_condition == 0) { - // dd($test_condition); - // } else if ($test_condition == 1) { - // dd($test_condition); - // } - // } - // } + // else if ($condition->type == 'boolean') { + // if ($test_conditions[$condition->type][$test_condition]) { + // if ($test_condition == 0) { + // } else if ($test_condition == 1) { + // } + // } + // } } return $result; } diff --git a/packages/Webkul/Discount/src/Http/Controllers/CartRuleController.php b/packages/Webkul/Discount/src/Http/Controllers/CartRuleController.php index fefc93d80..2e3d653bf 100644 --- a/packages/Webkul/Discount/src/Http/Controllers/CartRuleController.php +++ b/packages/Webkul/Discount/src/Http/Controllers/CartRuleController.php @@ -96,8 +96,6 @@ class CartRuleController extends Controller public function store() { - // dd(request()->all()); // required_if:use_coupon,1 - $types = config('price_rules.cart.validations'); $data = request()->all(); $validated = Validator::make($data, [ @@ -171,6 +169,7 @@ class CartRuleController extends Controller $data['conditions'] = null; } else { $data['conditions'] = json_encode($data['all_conditions']); + unset($data['all_conditions']); } if ($data['use_coupon']) { @@ -378,12 +377,12 @@ class CartRuleController extends Controller $coupons['cart_rule_id'] = $ruleUpdated->id; $coupons['usage_per_customer'] = $data['per_customer']; //0 is for unlimited usage - $couponUpdated = $this->cartRuleCoupon->create($coupons); + $couponUpdated = $ruleUpdated->coupons->update($coupons); } if ($ruleUpdated && $ruleGroupUpdated && $ruleChannelUpdated) { if (isset($couponUpdated) && $couponUpdated) { - session()->flash('success', trans('admin::app.promotion.status.success-coupon')); + session()->flash('info', trans('admin::app.promotion.status.success-coupon')); } session()->flash('info', trans('admin::app.promotion.status.update-success')); diff --git a/packages/Webkul/Discount/src/Repositories/CartRuleRepository.php b/packages/Webkul/Discount/src/Repositories/CartRuleRepository.php index 12551767b..79fdb6450 100644 --- a/packages/Webkul/Discount/src/Repositories/CartRuleRepository.php +++ b/packages/Webkul/Discount/src/Repositories/CartRuleRepository.php @@ -5,6 +5,8 @@ namespace Webkul\Discount\Repositories; use Webkul\Core\Eloquent\Repository; use Webkul\Discount\Repositories\CartRuleChannelsRepository as CartRuleChannels; use Webkul\Discount\Repositories\CartRuleCustomerGroupsRepository as CartRuleCustomerGroups; +use Webkul\Discount\Repositories\CartRuleCouponsRepository as CartRuleCoupons; +use Webkul\Discount\Repositories\CartRuleLabelsRepository as CartRuleLabels; use Illuminate\Container\Container as App; /** @@ -19,13 +21,19 @@ class CartRuleRepository extends Repository protected $cartRuleCustomerGroups; + protected $cartRuleCoupons; + + protected $cartRuleLabels; + /** * */ - public function __construct(CartRuleChannels $cartRuleChannels, CartRuleCustomerGroups $cartRuleCustomerGroups, App $app) + public function __construct(CartRuleChannels $cartRuleChannels, CartRuleCustomerGroups $cartRuleCustomerGroups, CartRuleCoupons $cartRuleCoupons, CartRuleLabels $cartRuleLabels, App $app) { $this->cartRuleChannels = $cartRuleChannels; $this->cartRuleCustomerGroups = $cartRuleCustomerGroups; + $this->cartRuleCoupons = $cartRuleCoupons; + $this->cartRuleLabels = $cartRuleLabels; parent::__construct($app); } @@ -135,8 +143,19 @@ class CartRuleRepository extends Repository return true; } + /** + * To sync the labels associated with the cart rule + */ public function LabelsSync($labels, $cartRule) { } + + /** + * To sync the coupons associated with the cart rule + */ + public function CouponsSync($coupon, $cartRule) + { + + } } \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php index f1a0662b5..483c0b124 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php @@ -127,6 +127,7 @@ class OnepageController extends Controller $cart = Cart::getCart(); $rule = Cart::applyNonCoupon(); + // dd($rule); return response()->json([ 'jump_to_section' => 'review', diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php index a4deed7e3..2010843cb 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/total/summary.blade.php @@ -49,7 +49,7 @@ @if(isset($rule)) - {{--
+
{{ $rule['rule']->name }} {{ __('shop::app.checkout.onepage.applied') }}
@@ -58,44 +58,22 @@ @if ($rule['impact']['amount_given']) - + @else @endif -
--}} - @else - {{-- {{dd('2')}} --}} - {{--
-
- @{{ code }} {{ __('shop::app.checkout.onepage.applied') }} -
- - - - - -
- -
-
- {{ __('shop::app.checkout.onepage.coupon-used') }} -
- - - - - - - - - - -
--}} @endif @endif
- \ No newline at end of file + +@push('scripts') + +@endpush \ No newline at end of file