Resolved conflicts
This commit is contained in:
commit
0f42e8ff8f
|
|
@ -4,9 +4,10 @@ APP_VERSION=1.0.0
|
|||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_TIMEZONE='Asia/Kolkata'
|
||||
APP_TIMEZONE=
|
||||
APP_LOCALE=
|
||||
LOG_CHANNEL=stack
|
||||
APP_CURRENCY=USD
|
||||
APP_CURRENCY=
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ about: 'Report a general library issue.'
|
|||
|
||||
### Title
|
||||
**Just a quick sentence to brief your trouble with Bagisto or something associated with it.**
|
||||
**Please be calm, short and emaphasize on points.**
|
||||
**Please be calm, short and emphasize on points.**
|
||||
|
||||
### Issue Description
|
||||
**Description helps the developers to understand the bug. It describes the problem encountered or some after effect of some kind.**
|
||||
|
|
|
|||
|
|
@ -3,9 +3,13 @@
|
|||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Webkul\Product\Repositories\ProductRepository as Product;
|
||||
use Webkul\Product\Helpers\GenerateProduct;
|
||||
|
||||
/**
|
||||
* Class GenerateProducts
|
||||
*
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class GenerateProducts extends Command
|
||||
{
|
||||
/**
|
||||
|
|
@ -54,12 +58,24 @@ class GenerateProducts extends Command
|
|||
if (! is_string($this->argument('value')) || ! is_numeric($this->argument('quantity'))) {
|
||||
$this->info('Illegal parameters or value of parameters are passed');
|
||||
} else {
|
||||
if (strtolower($this->argument('value')) == 'product' || strtolower($this->argument('value')) == 'products') {
|
||||
$quantity = intval($this->argument('quantity'));
|
||||
if (strtolower($this->argument('value')) == 'product' || strtolower($this->argument('value')) == 'products') {
|
||||
$quantity = (int)$this->argument('quantity');
|
||||
|
||||
// @see https://laravel.com/docs/6.x/artisan#writing-output
|
||||
// @see https://symfony.com/doc/current/components/console/helpers/progressbar.html
|
||||
$bar = $this->output->createProgressBar($quantity);
|
||||
|
||||
$this->line("Generating $quantity {$this->argument('value')}.");
|
||||
|
||||
$bar->start();
|
||||
|
||||
$generatedProducts = 0;
|
||||
$this->generateProduct->generateDemoBrand();
|
||||
while ($quantity > 0) {
|
||||
try {
|
||||
$result = $this->generateProduct->create();
|
||||
$generatedProducts++;
|
||||
$bar->advance();
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
continue;
|
||||
|
|
@ -68,10 +84,13 @@ class GenerateProducts extends Command
|
|||
$quantity--;
|
||||
}
|
||||
|
||||
if ($result)
|
||||
$this->info('Product(s) created successfully.');
|
||||
else
|
||||
|
||||
if ($result) {
|
||||
$bar->finish();
|
||||
$this->info("\n$generatedProducts Product(s) created successfully.");
|
||||
} else {
|
||||
$this->info('Product(s) cannot be created successfully.');
|
||||
}
|
||||
} else {
|
||||
$this->line('Sorry, this generate option is invalid.');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,35 +78,57 @@ class install extends Command
|
|||
{
|
||||
$envExists = File::exists(base_path() . '/.env');
|
||||
if (!$envExists) {
|
||||
$this->info('Creating .env file');
|
||||
$this->info('Creating the environment configuration file.');
|
||||
$this->createEnvFile();
|
||||
} else {
|
||||
$this->info('Great! .env file aready exists');
|
||||
$this->info('Great! your environment configuration file aready exists.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new .env file.
|
||||
*/
|
||||
public function createEnvFile()
|
||||
{
|
||||
try {
|
||||
File::copy('.env.example', '.env');
|
||||
Artisan::call('key:generate');
|
||||
$this->envUpdate('APP_URL=http://localhost', ':8000');
|
||||
|
||||
$locale = $this->choice('Please select the default locale or press enter to continue', ['ar', 'en', 'fa', 'nl', 'pt_BR'], 1);
|
||||
$this->envUpdate('APP_LOCALE=', $locale);
|
||||
|
||||
$TimeZones = timezone_identifiers_list();
|
||||
$timezone = $this->anticipate('Please enter the default timezone', $TimeZones, date_default_timezone_get());
|
||||
$this->envUpdate('APP_TIMEZONE=', $timezone);
|
||||
|
||||
$currency = $this->choice('Please enter the default currency', ['USD', 'EUR'], 'USD');
|
||||
$this->envUpdate('APP_CURRENCY=', $currency);
|
||||
|
||||
|
||||
$this->addDatabaseDetails();
|
||||
} catch (\Exception $e) {
|
||||
$this->error('Error in creating .env file, please create manually and then run `php artisan migrate` again');
|
||||
$this->error('Error in creating .env file, please create it manually and then run `php artisan migrate` again.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the database credentials to the .env file.
|
||||
*/
|
||||
public function addDatabaseDetails()
|
||||
{
|
||||
$dbName = $this->ask('What is your database name to be used by bagisto');
|
||||
$dbUser = $this->anticipate('What is your database username', ['root']);
|
||||
$dbPass = $this->secret('What is your database password');
|
||||
$dbName = $this->ask('What is the database name to be used by bagisto?');
|
||||
$dbUser = $this->anticipate('What is your database username?', ['root']);
|
||||
$dbPass = $this->secret('What is your database password?');
|
||||
|
||||
$this->envUpdate('DB_DATABASE=', $dbName);
|
||||
$this->envUpdate('DB_USERNAME=', $dbUser);
|
||||
$this->envUpdate('DB_PASSWORD=', $dbPass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the .env values.
|
||||
*/
|
||||
public static function envUpdate($key, $value)
|
||||
{
|
||||
$path = base_path() . '/.env';
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'locale' => 'en',
|
||||
'locale' => env('APP_LOCALE', 'en'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
@ -116,8 +116,8 @@ return [
|
|||
| Here you may specify the base currency code for your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'currency' => env('APP_CURRENCY','USD'),
|
||||
|
||||
'currency' => env('APP_CURRENCY', 'USD'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -56,8 +56,7 @@ class CartController extends Controller
|
|||
CartRepository $cartRepository,
|
||||
CartItemRepository $cartItemRepository,
|
||||
WishlistRepository $wishlistRepository
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->guard = request()->has('token') ? 'api' : 'customer';
|
||||
|
||||
auth()->setDefaultDriver($this->guard);
|
||||
|
|
@ -93,7 +92,8 @@ class CartController extends Controller
|
|||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store($id)
|
||||
|
|
@ -101,7 +101,7 @@ class CartController extends Controller
|
|||
if (request()->get('is_buy_now')) {
|
||||
Event::dispatch('shop.item.buy-now', $id);
|
||||
}
|
||||
|
||||
|
||||
Event::dispatch('checkout.cart.item.add.before', $id);
|
||||
|
||||
$result = Cart::addProduct($id, request()->except('_token'));
|
||||
|
|
@ -110,8 +110,8 @@ class CartController extends Controller
|
|||
$message = session()->get('warning') ?? session()->get('error');
|
||||
|
||||
return response()->json([
|
||||
'error' => session()->get('warning')
|
||||
], 400);
|
||||
'error' => session()->get('warning')
|
||||
], 400);
|
||||
}
|
||||
|
||||
if ($customer = auth($this->guard)->user()) {
|
||||
|
|
@ -125,9 +125,9 @@ class CartController extends Controller
|
|||
$cart = Cart::getCart();
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Product added to cart successfully.',
|
||||
'data' => $cart ? new CartResource($cart) : null
|
||||
]);
|
||||
'message' => __('shop::app.checkout.cart.item.success'),
|
||||
'data' => $cart ? new CartResource($cart) : null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -137,11 +137,11 @@ class CartController extends Controller
|
|||
*/
|
||||
public function update()
|
||||
{
|
||||
foreach (request()->get('qty') as$qty) {
|
||||
foreach (request()->get('qty') as $qty) {
|
||||
if ($qty <= 0) {
|
||||
return response()->json([
|
||||
'message' => trans('shop::app.checkout.cart.quantity.illegal')
|
||||
], 401);
|
||||
'message' => trans('shop::app.checkout.cart.quantity.illegal')
|
||||
], 401);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,9 +160,9 @@ class CartController extends Controller
|
|||
$cart = Cart::getCart();
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Cart updated successfully.',
|
||||
'data' => $cart ? new CartResource($cart) : null
|
||||
]);
|
||||
'message' => __('shop::app.checkout.cart.quantity.success'),
|
||||
'data' => $cart ? new CartResource($cart) : null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -181,15 +181,16 @@ class CartController extends Controller
|
|||
$cart = Cart::getCart();
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Cart removed successfully.',
|
||||
'data' => $cart ? new CartResource($cart) : null
|
||||
]);
|
||||
'message' => __('shop::app.checkout.cart.item.success-remove'),
|
||||
'data' => $cart ? new CartResource($cart) : null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroyItem($id)
|
||||
|
|
@ -205,9 +206,9 @@ class CartController extends Controller
|
|||
$cart = Cart::getCart();
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Cart removed successfully.',
|
||||
'data' => $cart ? new CartResource($cart) : null
|
||||
]);
|
||||
'message' => __('shop::app.checkout.cart.item.success-remove'),
|
||||
'data' => $cart ? new CartResource($cart) : null
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -229,8 +230,8 @@ class CartController extends Controller
|
|||
$cart = Cart::getCart();
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Cart item moved to wishlist successfully.',
|
||||
'data' => $cart ? new CartResource($cart) : null
|
||||
]);
|
||||
'message' => __('shop::app.checkout.cart.move-to-wishlist-success'),
|
||||
'data' => $cart ? new CartResource($cart) : null
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
<div class="control-group">
|
||||
<label for="status">{{ __('admin::app.promotions.cart-rules.status') }}</label>
|
||||
|
||||
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="status" name="status" value="1" {{ old('status') ? 'checked' : '' }}>
|
||||
<span class="slider round"></span>
|
||||
|
|
@ -140,16 +140,16 @@
|
|||
|
||||
<div class="control-group date">
|
||||
<label for="starts_from">{{ __('admin::app.promotions.cart-rules.from') }}</label>
|
||||
<date>
|
||||
<datetime>
|
||||
<input type="text" name="starts_from" class="control" value="{{ old('starts_from') }}"/>
|
||||
</date>
|
||||
</datetime>
|
||||
</div>
|
||||
|
||||
<div class="control-group date">
|
||||
<label for="ends_till">{{ __('admin::app.promotions.cart-rules.to') }}</label>
|
||||
<date>
|
||||
<datetime>
|
||||
<input type="text" name="ends_till" class="control" value="{{ old('ends_till') }}"/>
|
||||
</date>
|
||||
</datetime>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
|
|
@ -427,11 +427,11 @@
|
|||
|
||||
attribute_type_indexes: {
|
||||
'cart': 0,
|
||||
|
||||
|
||||
'cart_item': 1,
|
||||
|
||||
'product': 2
|
||||
},
|
||||
},
|
||||
|
||||
condition_operators: {
|
||||
'price': [{
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
<div class="control-group">
|
||||
<label for="status">{{ __('admin::app.promotions.cart-rules.status') }}</label>
|
||||
|
||||
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="status" name="status" value="{{ $cartRule->status }}" {{ $cartRule->status ? 'checked' : '' }}>
|
||||
<span class="slider round"></span>
|
||||
|
|
@ -144,16 +144,16 @@
|
|||
|
||||
<div class="control-group date">
|
||||
<label for="starts_from">{{ __('admin::app.promotions.cart-rules.from') }}</label>
|
||||
<date>
|
||||
<datetime>
|
||||
<input type="text" name="starts_from" class="control" value="{{ old('starts_from') ?: $cartRule->starts_from }}"/>
|
||||
</date>
|
||||
</datetime>
|
||||
</div>
|
||||
|
||||
<div class="control-group date">
|
||||
<label for="ends_till">{{ __('admin::app.promotions.cart-rules.to') }}</label>
|
||||
<date>
|
||||
<datetime>
|
||||
<input type="text" name="ends_till" class="control" value="{{ old('ends_till') ?: $cartRule->ends_till }}"/>
|
||||
</date>
|
||||
</datetime>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ChangeColumnTypeInCartRulesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('cart_rules', function (Blueprint $table) {
|
||||
$table->dateTime('starts_from')->change();
|
||||
$table->dateTime('ends_till')->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('cart_rules', function (Blueprint $table) {
|
||||
$table->dateTime('starts_from')->change();
|
||||
$table->dateTime('ends_till')->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ use Webkul\CartRule\Repositories\CartRuleCouponRepository;
|
|||
use Webkul\CartRule\Repositories\CartRuleCouponUsageRepository;
|
||||
use Webkul\CartRule\Repositories\CartRuleCustomerRepository;
|
||||
use Webkul\Customer\Repositories\CustomerGroupRepository;
|
||||
use Webkul\Checkout\Models\CartItem;
|
||||
use Webkul\Rule\Helpers\Validator;
|
||||
use Webkul\Checkout\Facades\Cart;
|
||||
|
||||
|
|
@ -63,12 +64,13 @@ class CartRule
|
|||
/**
|
||||
* Create a new helper instance.
|
||||
*
|
||||
* @param Webkul\CartRule\Repositories\CartRuleRepository $cartRuleRepository
|
||||
* @param Webkul\CartRule\Repositories\CartRuleCouponRepository $cartRuleCouponRepository
|
||||
* @param Webkul\CartRule\Repositories\CartRuleCouponUsageRepository $cartRuleCouponUsageRepository
|
||||
* @param Webkul\CartRule\Repositories\CartRuleCustomerRepository $cartRuleCustomerRepository
|
||||
* @param Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository
|
||||
* @param Webkul\Rule\Helpers\Validator $validator
|
||||
* @param Webkul\CartRule\Repositories\CartRuleRepository $cartRuleRepository
|
||||
* @param Webkul\CartRule\Repositories\CartRuleCouponRepository $cartRuleCouponRepository
|
||||
* @param Webkul\CartRule\Repositories\CartRuleCouponUsageRepository $cartRuleCouponUsageRepository
|
||||
* @param Webkul\CartRule\Repositories\CartRuleCustomerRepository $cartRuleCustomerRepository
|
||||
* @param Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository
|
||||
* @param Webkul\Rule\Helpers\Validator $validator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
|
|
@ -101,17 +103,23 @@ class CartRule
|
|||
public function collect()
|
||||
{
|
||||
$cart = Cart::getCart();
|
||||
$appliedCartRuleIds = [];
|
||||
|
||||
$this->calculateCartItemTotals($cart->items()->get());
|
||||
|
||||
foreach ($cart->items()->get() as $item) {
|
||||
$this->process($item);
|
||||
$itemCartRuleIds = $this->process($item);
|
||||
$appliedCartRuleIds = array_merge($appliedCartRuleIds, $itemCartRuleIds);
|
||||
|
||||
if ($item->children()->count() && $item->product->getTypeInstance()->isChildrenCalculated()) {
|
||||
$this->devideDiscount($item);
|
||||
$this->divideDiscount($item);
|
||||
}
|
||||
}
|
||||
|
||||
$cart->applied_cart_rule_ids = implode(',', array_unique($appliedCartRuleIds, SORT_REGULAR));
|
||||
$cart->save();
|
||||
$cart->refresh();
|
||||
|
||||
$this->processShippingDiscount($cart);
|
||||
|
||||
$this->processFreeShippingDiscount($cart);
|
||||
|
|
@ -142,18 +150,20 @@ class CartRule
|
|||
}
|
||||
}
|
||||
|
||||
$cartRules = $this->cartRuleRepository->scopeQuery(function($query) use ($customerGroupId) {
|
||||
$cartRules = $this->cartRuleRepository->scopeQuery(function ($query) use ($customerGroupId) {
|
||||
return $query->leftJoin('cart_rule_customer_groups', 'cart_rules.id', '=', 'cart_rule_customer_groups.cart_rule_id')
|
||||
->leftJoin('cart_rule_channels', 'cart_rules.id', '=', 'cart_rule_channels.cart_rule_id')
|
||||
->where('cart_rule_customer_groups.customer_group_id', $customerGroupId)
|
||||
->where('cart_rule_channels.channel_id', core()->getCurrentChannel()->id)
|
||||
->where(function ($query1) {
|
||||
$query1->where('cart_rules.starts_from', '<=', Carbon::now()->format('Y-m-d'))->orWhereNull('cart_rules.starts_from');
|
||||
})
|
||||
->where(function ($query2) {
|
||||
$query2->where('cart_rules.ends_till', '>=', Carbon::now()->format('Y-m-d'))->orWhereNull('cart_rules.ends_till');
|
||||
})
|
||||
->orderBy('sort_order', 'asc');
|
||||
->leftJoin('cart_rule_channels', 'cart_rules.id', '=', 'cart_rule_channels.cart_rule_id')
|
||||
->where('cart_rule_customer_groups.customer_group_id', $customerGroupId)
|
||||
->where('cart_rule_channels.channel_id', core()->getCurrentChannel()->id)
|
||||
->where(function ($query1) {
|
||||
$query1->where('cart_rules.starts_from', '<=', Carbon::now()->format('Y-m-d'))
|
||||
->orWhereNull('cart_rules.starts_from');
|
||||
})
|
||||
->where(function ($query2) {
|
||||
$query2->where('cart_rules.ends_till', '>=', Carbon::now()->format('Y-m-d'))
|
||||
->orWhereNull('cart_rules.ends_till');
|
||||
})
|
||||
->orderBy('sort_order', 'asc');
|
||||
})->findWhere(['status' => 1]);
|
||||
|
||||
return $cartRules;
|
||||
|
|
@ -163,29 +173,30 @@ class CartRule
|
|||
* Check if cart rule can be applied
|
||||
*
|
||||
* @param CartRule $rule
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canProcessRule($rule)
|
||||
public function canProcessRule($rule): bool
|
||||
{
|
||||
$cart = Cart::getCart();
|
||||
|
||||
if ($rule->coupon_type) {
|
||||
if (strlen($cart->coupon_code)) {
|
||||
$coupon = $this->cartRuleCouponRepository->findOneWhere([
|
||||
'cart_rule_id' => $rule->id,
|
||||
'code' => $cart->coupon_code,
|
||||
]);
|
||||
'cart_rule_id' => $rule->id,
|
||||
'code' => $cart->coupon_code,
|
||||
]);
|
||||
|
||||
if ($coupon) {
|
||||
if ($coupon->usage_limit && $coupon->times_used >= $coupon->usage_limit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ($cart->customer_id && $coupon->usage_per_customer) {
|
||||
$couponUsage = $this->cartRuleCouponUsageRepository->findOneWhere([
|
||||
'cart_rule_coupon_id' => $coupon->id,
|
||||
'customer_id' => $cart->customer_id
|
||||
]);
|
||||
'cart_rule_coupon_id' => $coupon->id,
|
||||
'customer_id' => $cart->customer_id,
|
||||
]);
|
||||
|
||||
if ($couponUsage && $couponUsage->times_used >= $coupon->usage_per_customer) {
|
||||
return false;
|
||||
|
|
@ -201,9 +212,9 @@ class CartRule
|
|||
|
||||
if ($rule->usage_per_customer) {
|
||||
$ruleCustomer = $this->cartRuleCustomerRepository->findOneWhere([
|
||||
'cart_rule_id' => $rule->id,
|
||||
'customer_id' => $cart->customer_id,
|
||||
]);
|
||||
'cart_rule_id' => $rule->id,
|
||||
'customer_id' => $cart->customer_id,
|
||||
]);
|
||||
|
||||
if ($ruleCustomer && $ruleCustomer->times_used >= $rule->usage_per_customer) {
|
||||
return false;
|
||||
|
|
@ -216,19 +227,16 @@ class CartRule
|
|||
/**
|
||||
* Cart item discount calculation process
|
||||
*
|
||||
* @param CartItem $item
|
||||
* @return void
|
||||
* @param \Webkul\Checkout\Models\CartItem $item
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function process($item)
|
||||
public function process(CartItem $item): array
|
||||
{
|
||||
$item->discount_percent = 0;
|
||||
$item->discount_amount = 0;
|
||||
$item->base_discount_amount = 0;
|
||||
|
||||
$cart = $item->cart;
|
||||
|
||||
$cart->applied_cart_rule_ids = null;
|
||||
|
||||
$appliedRuleIds = [];
|
||||
|
||||
foreach ($this->getCartRules() as $rule) {
|
||||
|
|
@ -310,8 +318,8 @@ class CartRule
|
|||
break;
|
||||
}
|
||||
|
||||
$item->discount_amount = min($item->discount_amount + $discountAmount, $item->price * $quantity);
|
||||
$item->base_discount_amount = min($item->base_discount_amount + $baseDiscountAmount, $item->base_price * $quantity);
|
||||
$item->discount_amount = min($item->discount_amount + $discountAmount, $item->price * $quantity + $item->tax_amount);
|
||||
$item->base_discount_amount = min($item->base_discount_amount + $baseDiscountAmount, $item->base_price * $quantity + $item->base_tax_amount);
|
||||
|
||||
$appliedRuleIds[$rule->id] = $rule->id;
|
||||
|
||||
|
|
@ -320,25 +328,18 @@ class CartRule
|
|||
}
|
||||
}
|
||||
|
||||
$item->applied_cart_rule_ids = join(',', $appliedRuleIds);
|
||||
$item->applied_cart_rule_ids = implode(',', $appliedRuleIds);
|
||||
|
||||
$item->save();
|
||||
|
||||
$cartAppliedCartRuleIds = array_merge(explode(',', $cart->applied_cart_rule_ids), $appliedRuleIds);
|
||||
|
||||
$cartAppliedCartRuleIds = array_filter($cartAppliedCartRuleIds);
|
||||
|
||||
$cartAppliedCartRuleIds = array_unique($cartAppliedCartRuleIds);
|
||||
|
||||
$cart->applied_cart_rule_ids = join(',', $cartAppliedCartRuleIds);
|
||||
|
||||
$cart->save();
|
||||
return $appliedRuleIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cart shipping discount calculation process
|
||||
*
|
||||
* @param Cart $cart
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function processShippingDiscount($cart)
|
||||
|
|
@ -388,9 +389,9 @@ class CartRule
|
|||
$selectedShipping->discount_amount = min($selectedShipping->discount_amount + $discountAmount, $selectedShipping->price);
|
||||
|
||||
$selectedShipping->base_discount_amount = min(
|
||||
$selectedShipping->base_discount_amount + $baseDiscountAmount,
|
||||
$selectedShipping->base_price
|
||||
);
|
||||
$selectedShipping->base_discount_amount + $baseDiscountAmount,
|
||||
$selectedShipping->base_price
|
||||
);
|
||||
|
||||
$selectedShipping->save();
|
||||
|
||||
|
|
@ -409,7 +410,7 @@ class CartRule
|
|||
|
||||
$cartAppliedCartRuleIds = array_unique($cartAppliedCartRuleIds);
|
||||
|
||||
$cart->applied_cart_rule_ids = join(',', $cartAppliedCartRuleIds);
|
||||
$cart->applied_cart_rule_ids = implode(',', $cartAppliedCartRuleIds);
|
||||
|
||||
$cart->save();
|
||||
|
||||
|
|
@ -420,6 +421,7 @@ class CartRule
|
|||
* Cart free shipping discount calculation process
|
||||
*
|
||||
* @param Cart $cart
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function processFreeShippingDiscount($cart)
|
||||
|
|
@ -475,6 +477,7 @@ class CartRule
|
|||
* Calculate cart item totals for each rule
|
||||
*
|
||||
* @param mixed $items
|
||||
*
|
||||
* @return Validator
|
||||
*/
|
||||
public function calculateCartItemTotals($items)
|
||||
|
|
@ -524,12 +527,13 @@ class CartRule
|
|||
}
|
||||
|
||||
/**
|
||||
* Devide discount amount to children
|
||||
* Divide discount amount to children
|
||||
*
|
||||
* @param CartItem $item
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function devideDiscount($item)
|
||||
protected function divideDiscount($item)
|
||||
{
|
||||
foreach ($item->children as $child) {
|
||||
$ratio = $item->base_total != 0 ? $child->base_total / $item->base_total : 0;
|
||||
|
|
@ -545,4 +549,4 @@ class CartRule
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,30 @@ use Webkul\Customer\Models\CustomerGroupProxy;
|
|||
// class CartRule extends TranslatableModel implements CartRuleContract
|
||||
class CartRule extends Model implements CartRuleContract
|
||||
{
|
||||
protected $fillable = ['name', 'description', 'starts_from', 'ends_till', 'status', 'coupon_type', 'use_auto_generation', 'usage_per_customer', 'uses_per_coupon', 'times_used', 'condition_type', 'conditions', 'actions', 'end_other_rules', 'uses_attribute_conditions', 'action_type', 'discount_amount', 'discount_quantity', 'discount_step', 'apply_to_shipping', 'free_shipping', 'sort_order'];
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'starts_from',
|
||||
'ends_till',
|
||||
'status',
|
||||
'coupon_type',
|
||||
'use_auto_generation',
|
||||
'usage_per_customer',
|
||||
'uses_per_coupon',
|
||||
'times_used',
|
||||
'condition_type',
|
||||
'conditions',
|
||||
'actions',
|
||||
'end_other_rules',
|
||||
'uses_attribute_conditions',
|
||||
'action_type',
|
||||
'discount_amount',
|
||||
'discount_quantity',
|
||||
'discount_step',
|
||||
'apply_to_shipping',
|
||||
'free_shipping',
|
||||
'sort_order',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'conditions' => 'array',
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ class Cart
|
|||
'items_count' => 1,
|
||||
];
|
||||
|
||||
//Authentication details
|
||||
// Fill in the customer data, as far as possible:
|
||||
if ($this->getCurrentCustomer()->check()) {
|
||||
$cartData['customer_id'] = $this->getCurrentCustomer()->user()->id;
|
||||
$cartData['is_guest'] = 0;
|
||||
|
|
@ -675,7 +675,7 @@ class Cart
|
|||
$cart->tax_total = Tax::getTaxTotal($cart, false);
|
||||
$cart->base_tax_total = Tax::getTaxTotal($cart, true);
|
||||
|
||||
$cart->grand_total = $cart->sub_total + $cart->tax_total + $cart->discount_amount;
|
||||
$cart->grand_total = $cart->sub_total + $cart->tax_total - $cart->discount_amount;
|
||||
$cart->base_grand_total = $cart->base_sub_total + $cart->base_tax_total - $cart->base_discount_amount;
|
||||
|
||||
if ($shipping = $cart->selected_shipping_rate) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,21 @@ class CartAddress extends Model implements CartAddressContract
|
|||
{
|
||||
protected $table = 'cart_address';
|
||||
|
||||
protected $fillable = ['first_name', 'last_name', 'email', 'address1', 'city', 'state', 'postcode', 'country', 'phone', 'address_type', 'cart_id'];
|
||||
protected $fillable = [
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email',
|
||||
'company_name',
|
||||
'vat_id',
|
||||
'address1',
|
||||
'city',
|
||||
'state',
|
||||
'postcode',
|
||||
'country',
|
||||
'phone',
|
||||
'address_type',
|
||||
'cart_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the shipping rates for the cart address.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class PropagateCompanyName extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('cart_address', function (Blueprint $table) {
|
||||
$table->string('company_name')->nullable()->after('email');
|
||||
$table->string('vat_id')->nullable()->after('company_name');
|
||||
|
||||
});
|
||||
|
||||
Schema::table('order_address', function (Blueprint $table) {
|
||||
$table->string('company_name')->nullable()->after('email');
|
||||
$table->string('vat_id')->nullable()->after('company_name');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('cart_address', function (Blueprint $table) {
|
||||
$table->dropColumn('company_name');
|
||||
$table->dropColumn('vat_id');
|
||||
});
|
||||
|
||||
Schema::table('order_address', function (Blueprint $table) {
|
||||
$table->dropColumn('company_name');
|
||||
$table->dropColumn('vat_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,17 @@
|
|||
|
||||
namespace Webkul\Product\Helpers;
|
||||
|
||||
use Webkul\Attribute\Models\Attribute;
|
||||
use Webkul\Attribute\Models\AttributeOption;
|
||||
use Webkul\Product\Repositories\ProductRepository as Product;
|
||||
use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Class GenerateProduct
|
||||
*
|
||||
* @package Webkul\Product\Helpers
|
||||
*/
|
||||
class GenerateProduct
|
||||
{
|
||||
/**
|
||||
|
|
@ -28,18 +35,50 @@ class GenerateProduct
|
|||
$this->product = $product;
|
||||
|
||||
$this->types = [
|
||||
'text', 'textarea', 'boolean', 'select', 'multiselect', 'datetime', 'date', 'price', 'image', 'file', 'checkbox'
|
||||
'text',
|
||||
'textarea',
|
||||
'boolean',
|
||||
'select',
|
||||
'multiselect',
|
||||
'datetime',
|
||||
'date',
|
||||
'price',
|
||||
'image',
|
||||
'file',
|
||||
'checkbox',
|
||||
];
|
||||
|
||||
$this->attributeFamily = $attributeFamily;
|
||||
}
|
||||
|
||||
/**
|
||||
* This brand option needs to be available so that the generated product
|
||||
* can be linked to the order_brands table after checkout.
|
||||
*/
|
||||
public function generateDemoBrand()
|
||||
{
|
||||
$brand = Attribute::where(['code' => 'brand'])->first();
|
||||
|
||||
if (! AttributeOption::where(['attribute_id' => $brand->id])->exists()) {
|
||||
|
||||
AttributeOption::create([
|
||||
'admin_name' => 'Webkul Demo Brand (c) 2020',
|
||||
'attribute_id' => $brand->id,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$attributes = $this->getDefaultFamilyAttributes();
|
||||
|
||||
$attributeFamily = $this->attributeFamily->findWhere([
|
||||
'code' => 'default'
|
||||
'code' => 'default',
|
||||
]);
|
||||
|
||||
$sku = Str::random(10);
|
||||
|
|
@ -59,7 +98,11 @@ class GenerateProduct
|
|||
|
||||
foreach ($attributes as $attribute) {
|
||||
if ($attribute->type == 'text') {
|
||||
if ($attribute->code == 'width' || $attribute->code == 'height' || $attribute->code == 'depth' || $attribute->code == 'weight') {
|
||||
if ($attribute->code == 'width'
|
||||
|| $attribute->code == 'height'
|
||||
|| $attribute->code == 'depth'
|
||||
|| $attribute->code == 'weight'
|
||||
) {
|
||||
$data[$attribute->code] = $faker->randomNumber(3);
|
||||
} elseif ($attribute->code == 'url_key') {
|
||||
$data[$attribute->code] = strtolower($sku);
|
||||
|
|
@ -72,7 +115,7 @@ class GenerateProduct
|
|||
$data[$attribute->code] = $faker->text;
|
||||
|
||||
if ($attribute->code == 'description' || $attribute->code == 'short_description') {
|
||||
$data[$attribute->code] = '<p>'. $data[$attribute->code] . '</p>';
|
||||
$data[$attribute->code] = '<p>' . $data[$attribute->code] . '</p>';
|
||||
}
|
||||
} elseif ($attribute->type == 'boolean') {
|
||||
$data[$attribute->code] = $faker->boolean;
|
||||
|
|
@ -117,7 +160,7 @@ class GenerateProduct
|
|||
} elseif ($attribute->code == 'checkbox') {
|
||||
$options = $attribute->options;
|
||||
|
||||
if ($options->count()) {
|
||||
if ($options->count()) {
|
||||
$option = $options->first()->id;
|
||||
|
||||
$optionArray = [];
|
||||
|
|
@ -135,20 +178,23 @@ class GenerateProduct
|
|||
|
||||
$data['locale'] = core()->getCurrentLocale()->code;
|
||||
|
||||
$brand = Attribute::where(['code' => 'brand'])->first();
|
||||
$data['brand'] = AttributeOption::where(['attribute_id' => $brand->id])->first()->id ?? '';
|
||||
|
||||
$data['channel'] = $channel->code;
|
||||
|
||||
$data['channels'] = [
|
||||
0 => $channel->id
|
||||
0 => $channel->id,
|
||||
];
|
||||
|
||||
$inventorySource = $channel->inventory_sources[0];
|
||||
|
||||
$data['inventories'] = [
|
||||
$inventorySource->id => 10
|
||||
$inventorySource->id => 10,
|
||||
];
|
||||
|
||||
$data['categories'] = [
|
||||
0 => $channel->root_category->id
|
||||
0 => $channel->root_category->id,
|
||||
];
|
||||
|
||||
$updated = $this->product->update($data, $product->id);
|
||||
|
|
@ -159,7 +205,7 @@ class GenerateProduct
|
|||
public function getDefaultFamilyAttributes()
|
||||
{
|
||||
$attributeFamily = $this->attributeFamily->findWhere([
|
||||
'code' => 'default'
|
||||
'code' => 'default',
|
||||
]);
|
||||
|
||||
$attributes = collect();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,24 @@ class OrderAddress extends Model implements OrderAddressContract
|
|||
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
protected $fillable = [
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email',
|
||||
'company_name',
|
||||
'vat_id',
|
||||
'address1',
|
||||
'address2',
|
||||
'city',
|
||||
'state',
|
||||
'postcode',
|
||||
'country',
|
||||
'phone',
|
||||
'address_type',
|
||||
'cart_id',
|
||||
'customer_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get of the customer fullname.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
"laravel-mix-merge-manifest": "^0.1.2",
|
||||
"sass": "^1.24.4",
|
||||
"sass-loader": "^8.0.0",
|
||||
"vue": "^2.6.10",
|
||||
"vue": "^2.6.11",
|
||||
"vue-template-compiler": "^2.6.11"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -39,3 +39,9 @@
|
|||
*
|
||||
* Date: 2019-05-01T21:04Z
|
||||
*/
|
||||
|
||||
/**
|
||||
* vue-class-component v7.0.1
|
||||
* (c) 2015-present Evan You
|
||||
* @license MIT
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"/js/shop.js": "/js/shop.js?id=6d8ea335fbfa47e80e72",
|
||||
"/js/shop.js": "/js/shop.js?id=6bb928c2e527b045a56b",
|
||||
"/css/shop.css": "/css/shop.css?id=ccf417b825955d8bd301"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import $ from 'jquery';
|
||||
import Vue from 'vue';
|
||||
import VeeValidate from 'vee-validate';
|
||||
import de from 'vee-validate/dist/locale/de';
|
||||
import ar from 'vee-validate/dist/locale/ar';
|
||||
import axios from 'axios';
|
||||
import VueSlider from 'vue-slider-component';
|
||||
import accounting from 'accounting';
|
||||
|
||||
import ImageSlider from './components/image-slider';
|
||||
import { messages as localeMessages } from './lang/locales';
|
||||
|
||||
window.jQuery = window.$ = $;
|
||||
window.Vue = Vue;
|
||||
|
|
@ -17,7 +17,8 @@ require("ez-plus/src/jquery.ez-plus.js");
|
|||
|
||||
Vue.use(VeeValidate, {
|
||||
dictionary: {
|
||||
ar: { messages: localeMessages.ar }
|
||||
ar: ar,
|
||||
de: de,
|
||||
},
|
||||
events: 'input|change|blur',
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
export const messages = {
|
||||
ar: {
|
||||
required : (field) => 'حقل' + field + ' مطلوب',
|
||||
alpha : (field) => field + ' يجب ان يحتوي على حروف فقط',
|
||||
alpha_num : (field) => field + ' قد يحتوي فقط على حروف وارقام',
|
||||
min : (field, length) => 'الحقل ' + field + ' يجب ان يحتوي على ' + length + ' حروف على الأقل',
|
||||
numeric : (field) => field + ' يمكن ان يحتوي فقط على ارقام',
|
||||
oneOf : (field) => 'الحقل ' + field + 'يجب ان يكون قيمة صحيحة',
|
||||
regex : (field) => 'الحقل' + field+ ' غير صحيح',
|
||||
required_if : (field) => 'حقل' + field + ' مطلوب',
|
||||
size : (field, size) => field + ' يجب ان يكون اقل من ' + size + ' كيلوبايت',
|
||||
min_value : (field, min) => 'قيمة الحقل' + field + ' يجب ان تكون اكبر من ' + min + ' او تساويها',
|
||||
alpha_spaces : (field) => field + ' قد يحتوي فقط على حروف ومسافات',
|
||||
between : (field, min, max) => 'قيمة ' +field+ ' يجب ان تكون ما بين ' + min + ' و ' + max,
|
||||
confirmed : (field) => field + ' لا يماثل التأكيد',
|
||||
digits : (field, length) => field + ' يجب ان تحتوي فقط على ارقام والا يزيد عددها عن ' + length + ' رقم',
|
||||
dimensions : (field, width, height) => field + ' يجب ان تكون بمقاس ' + width + ' بكسل في ' + height + ' بكسل',
|
||||
email : (field) => field + ' يجب ان يكون بريدا اليكتروني صحيح',
|
||||
excluded : (field) => 'الحقل' + field +'غير صحيح',
|
||||
ext : (field) =>'نوع مل'+ field + 'غير صحيح',
|
||||
image : (field) => field + ' يجب ان تكون صورة',
|
||||
integer : (field) => 'الحقل ' +field + ' يجب ان يكون عدداً صحيحاً',
|
||||
length : (field, length) => 'حقل'+ field + ' يجب الا يزيد عن ' + length,
|
||||
max_value : (field, min) => 'قيمة الحقل '+ field + ' يجب ان تكون اصغر من ' + min + ' او تساويها',
|
||||
max : (field, length) => 'الحقل' + field + 'يجب ان يحتوي على ' + length + ' حروف على الأكثر',
|
||||
mimes : (field) => 'نوع ملف' + field + 'غير صحيح'
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue