Merge branch 'master' into optimization
This commit is contained in:
commit
8804f57ecf
|
|
@ -4,6 +4,7 @@ namespace Webkul\Marketing\Providers;
|
|||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Webkul\Marketing\Console\Commands\EmailsCommand;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
|
||||
class MarketingServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
@ -17,6 +18,10 @@ class MarketingServiceProvider extends ServiceProvider
|
|||
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
|
||||
|
||||
$this->loadRoutesFrom(__DIR__ . '/../Http/routes.php');
|
||||
|
||||
$this->callAfterResolving(Schedule::class, function (Schedule $schedule) {
|
||||
$schedule->command('campaign:process')->daily();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ class ConfigurableOption extends AbstractProduct
|
|||
'attributes' => $this->getAttributesData($product, $options),
|
||||
'index' => isset($options['index']) ? $options['index'] : [],
|
||||
'regular_price' => [
|
||||
'formated_price' => core()->currency($product->getTypeInstance()->getMinimalPrice()),
|
||||
'price' => $product->getTypeInstance()->getMinimalPrice(),
|
||||
'formated_price' => $product->getTypeInstance()->haveOffer() ? core()->currency($product->getTypeInstance()->getOfferPrice()) : core()->currency($product->getTypeInstance()->getMinimalPrice()),
|
||||
'price' => $product->getTypeInstance()->haveOffer() ? $product->getTypeInstance()->getOfferPrice() : $product->getTypeInstance()->getMinimalPrice(),
|
||||
],
|
||||
'variant_prices' => $this->getVariantPrices($product),
|
||||
'variant_images' => $this->getVariantImages($product),
|
||||
|
|
|
|||
|
|
@ -958,7 +958,7 @@ abstract class AbstractType
|
|||
|
||||
if ($haveOffers) {
|
||||
foreach ($customerGroupPrices as $key => $customerGroupPrice) {
|
||||
if ($key > 0) {
|
||||
if ($customerGroupPrice && $customerGroupPrice->qty > 1) {
|
||||
array_push($offerLines, $this->getOfferLines($customerGroupPrice));
|
||||
}
|
||||
}
|
||||
|
|
@ -984,7 +984,7 @@ abstract class AbstractType
|
|||
public function getOfferLines($customerGroupPrice) {
|
||||
$price = $this->getCustomerGroupPrice($this->product, $customerGroupPrice->qty);
|
||||
|
||||
$discount = (($this->product->price - $price) * 100) / ($this->product->price);
|
||||
$discount = number_format((($this->product->price - $price) * 100) / ($this->product->price), 2);
|
||||
|
||||
$offerLines = trans('shop::app.products.offers', ['qty' => $customerGroupPrice->qty,
|
||||
'price' => core()->currency($price), 'discount' => $discount]);
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ class Configurable extends AbstractType
|
|||
*/
|
||||
public function getMinimalPrice($qty = null)
|
||||
{
|
||||
$minPrices = $rulePrices = $customerGroupPrices = [];
|
||||
$minPrices = [];
|
||||
|
||||
/* method is calling many time so using variable */
|
||||
$tablePrefix = DB::getTablePrefix();
|
||||
|
|
@ -373,6 +373,21 @@ class Configurable extends AbstractType
|
|||
$minPrices[] = $price->min_price;
|
||||
}
|
||||
|
||||
if (empty($minPrices)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return min($minPrices);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get product offer price
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getOfferPrice() {
|
||||
$rulePrices = $customerGroupPrices = [];
|
||||
|
||||
foreach ($this->product->variants as $variant) {
|
||||
$rulePrice = app('Webkul\CatalogRule\Helpers\CatalogRuleProductPrice')->getRulePrice($variant);
|
||||
|
||||
|
|
@ -383,11 +398,29 @@ class Configurable extends AbstractType
|
|||
$customerGroupPrices[] = $this->getCustomerGroupPrice($variant, 1);
|
||||
}
|
||||
|
||||
if (empty($minPrices)) {
|
||||
return 0;
|
||||
if ($rulePrices || $customerGroupPrices) {
|
||||
return min(array_merge($rulePrices, $customerGroupPrices));
|
||||
}
|
||||
|
||||
return min(array_merge(array_merge($minPrices, $rulePrices), $customerGroupPrices));
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for offer
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function haveOffer() {
|
||||
$haveOffer = false;
|
||||
|
||||
$offerPrice = $this->getOfferPrice();
|
||||
$minPrice = $this->getMinimalPrice();
|
||||
|
||||
if ($offerPrice < $minPrice) {
|
||||
$haveOffer = true;
|
||||
}
|
||||
|
||||
return $haveOffer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -415,9 +448,16 @@ class Configurable extends AbstractType
|
|||
*/
|
||||
public function getPriceHtml()
|
||||
{
|
||||
return '<span class="price-label">' . trans('shop::app.products.price-label') . '</span>'
|
||||
if ($this->haveOffer()) {
|
||||
return '<div class="sticker sale">' . trans('shop::app.products.sale') . '</div>'
|
||||
. '<span class="price-label">' . trans('shop::app.products.price-label') . '</span>'
|
||||
. '<span class="regular-price">' . core()->currency($this->getMinimalPrice()) . '</span>'
|
||||
. '<span class="final-price">' . core()->currency($this->getOfferPrice()) . '</span>';
|
||||
} else {
|
||||
return '<span class="price-label">' . trans('shop::app.products.price-label') . '</span>'
|
||||
. ' '
|
||||
. '<span class="final-price">' . core()->currency($this->getMinimalPrice()) . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -76,6 +76,14 @@
|
|||
|
||||
{!! view_render_event('bagisto.shop.customers.account.profile.edit.email.after') !!}
|
||||
|
||||
<div class="control-group" :class="[errors.has('phone') ? 'has-error' : '']">
|
||||
<label for="phone">{{ __('shop::app.customer.account.profile.phone') }}</label>
|
||||
<input type="text" class="control" name="phone" value="{{ old('phone') ?? $customer->phone }}" data-vv-as=""{{ __('shop::app.customer.account.profile.phone') }}"">
|
||||
<span class="control-error" v-if="errors.has('phone')">@{{ errors.first('phone') }}</span>
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.customers.account.profile.edit.phone.after') !!}
|
||||
|
||||
<div class="control-group" :class="[errors.has('oldpassword') ? 'has-error' : '']">
|
||||
<label for="password">{{ __('shop::app.customer.account.profile.opassword') }}</label>
|
||||
<input type="password" class="control" name="oldpassword" data-vv-as=""{{ __('shop::app.customer.account.profile.opassword') }}"" v-validate="'min:6'">
|
||||
|
|
|
|||
|
|
@ -275,12 +275,15 @@
|
|||
|
||||
var priceLabelElement = document.querySelector('.price-label');
|
||||
var priceElement = document.querySelector('.final-price');
|
||||
var regularPriceElement = document.querySelector('.regular-price');
|
||||
|
||||
if (this.childAttributes.length == selectedOptionCount) {
|
||||
priceLabelElement.style.display = 'none';
|
||||
|
||||
priceElement.innerHTML = this.config.variant_prices[this.simpleProduct].final_price.formated_price;
|
||||
|
||||
regularPriceElement.innerHTML = this.config.variant_prices[this.simpleProduct].regular_price.formated_price;
|
||||
|
||||
eventBus.$emit('configurable-variant-selected-event', this.simpleProduct)
|
||||
} else {
|
||||
priceLabelElement.style.display = 'inline-block';
|
||||
|
|
|
|||
|
|
@ -130,6 +130,19 @@
|
|||
|
||||
{!! view_render_event('bagisto.shop.customers.account.profile.edit.email.after', ['customer' => $customer]) !!}
|
||||
|
||||
<div class="row">
|
||||
<label class="col-12">
|
||||
{{ __('shop::app.customer.account.profile.phone') }}
|
||||
</label>
|
||||
|
||||
<div class="col-12">
|
||||
<input value="{{ old('phone') ?? $customer->phone }}" name="phone" type="text"/>
|
||||
<span class="control-error" v-if="errors.has('phone')">@{{ errors.first('phone') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.customers.account.profile.edit.phone.after', ['customer' => $customer]) !!}
|
||||
|
||||
<div class="row">
|
||||
<label class="col-12">
|
||||
{{ __('velocity::app.shop.general.enter-current-password') }}
|
||||
|
|
|
|||
|
|
@ -290,12 +290,15 @@
|
|||
|
||||
var priceLabelElement = document.querySelector('.price-label');
|
||||
var priceElement = document.querySelector('.final-price');
|
||||
var regularPriceElement = document.querySelector('.regular-price');
|
||||
|
||||
if (this.childAttributes.length == selectedOptionCount) {
|
||||
priceLabelElement.style.display = 'none';
|
||||
|
||||
priceElement.innerHTML = this.config.variant_prices[this.simpleProduct].final_price.formated_price;
|
||||
|
||||
regularPriceElement.innerHTML = this.config.variant_prices[this.simpleProduct].regular_price.formated_price;
|
||||
|
||||
eventBus.$emit('configurable-variant-selected-event', this.simpleProduct)
|
||||
} else {
|
||||
priceLabelElement.style.display = 'inline-block';
|
||||
|
|
|
|||
Loading…
Reference in New Issue