diff --git a/packages/Webkul/Marketing/src/Providers/MarketingServiceProvider.php b/packages/Webkul/Marketing/src/Providers/MarketingServiceProvider.php index ba2ffaf37..d5f19b8ea 100644 --- a/packages/Webkul/Marketing/src/Providers/MarketingServiceProvider.php +++ b/packages/Webkul/Marketing/src/Providers/MarketingServiceProvider.php @@ -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(); + }); } /** diff --git a/packages/Webkul/Product/src/Helpers/ConfigurableOption.php b/packages/Webkul/Product/src/Helpers/ConfigurableOption.php index 004ede9e5..2ce0b6963 100755 --- a/packages/Webkul/Product/src/Helpers/ConfigurableOption.php +++ b/packages/Webkul/Product/src/Helpers/ConfigurableOption.php @@ -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), diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php index ba021e53e..8383e15b9 100644 --- a/packages/Webkul/Product/src/Type/AbstractType.php +++ b/packages/Webkul/Product/src/Type/AbstractType.php @@ -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]); diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index 7f05f41ed..2f06bde6a 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -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 '' . trans('shop::app.products.price-label') . '' + if ($this->haveOffer()) { + return '
' . trans('shop::app.products.sale') . '
' + . '' . trans('shop::app.products.price-label') . '' + . '' . core()->currency($this->getMinimalPrice()) . '' + . '' . core()->currency($this->getOfferPrice()) . ''; + } else { + return '' . trans('shop::app.products.price-label') . '' . ' ' . '' . core()->currency($this->getMinimalPrice()) . ''; + } } /** diff --git a/packages/Webkul/Shop/src/Resources/views/customers/account/profile/edit.blade.php b/packages/Webkul/Shop/src/Resources/views/customers/account/profile/edit.blade.php index 18f2afc45..2172eb72f 100755 --- a/packages/Webkul/Shop/src/Resources/views/customers/account/profile/edit.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/customers/account/profile/edit.blade.php @@ -76,6 +76,14 @@ {!! view_render_event('bagisto.shop.customers.account.profile.edit.email.after') !!} +
+ + + @{{ errors.first('phone') }} +
+ + {!! view_render_event('bagisto.shop.customers.account.profile.edit.phone.after') !!} +
diff --git a/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php index 970adc256..32c5ff9d5 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php @@ -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'; diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/customers/account/profile/edit.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/customers/account/profile/edit.blade.php index 47a9ee72a..1c7d17017 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/customers/account/profile/edit.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/customers/account/profile/edit.blade.php @@ -130,6 +130,19 @@ {!! view_render_event('bagisto.shop.customers.account.profile.edit.email.after', ['customer' => $customer]) !!} +
+ + +
+ + @{{ errors.first('phone') }} +
+
+ + {!! view_render_event('bagisto.shop.customers.account.profile.edit.phone.after', ['customer' => $customer]) !!} +