From 10f45d9fa899c97c57612914819be717ab019352 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Fri, 29 Jan 2021 15:54:39 +0530 Subject: [PATCH 1/7] Issue #3269 fixed --- .../src/Helpers/ConfigurableOption.php | 4 +- .../Webkul/Product/src/Type/Configurable.php | 50 +++++++++++++++++-- .../view/configurable-options.blade.php | 3 ++ .../view/configurable-options.blade.php | 3 ++ 4 files changed, 53 insertions(+), 7 deletions(-) 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/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/products/view/configurable-options.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php index 970adc256..2eed78664 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,15 +275,18 @@ 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'; + regularPriceElement.style.display = 'none'; priceElement.innerHTML = this.config.variant_prices[this.simpleProduct].final_price.formated_price; eventBus.$emit('configurable-variant-selected-event', this.simpleProduct) } else { priceLabelElement.style.display = 'inline-block'; + regularPriceElement.style.display = 'inline-block'; priceElement.innerHTML = this.config.regular_price.formated_price; diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/products/view/configurable-options.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/products/view/configurable-options.blade.php index 5d33d0af3..8a2168818 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/products/view/configurable-options.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/products/view/configurable-options.blade.php @@ -290,15 +290,18 @@ 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'; + regularPriceElement.style.display = 'none'; priceElement.innerHTML = this.config.variant_prices[this.simpleProduct].final_price.formated_price; eventBus.$emit('configurable-variant-selected-event', this.simpleProduct) } else { priceLabelElement.style.display = 'inline-block'; + regularPriceElement.style.display = 'inline-block'; priceElement.innerHTML = this.config.regular_price.formated_price; From 73e4deebaf4e188581bd99eea1705681d2f17818 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Fri, 29 Jan 2021 16:58:35 +0530 Subject: [PATCH 2/7] Fixes according to chnages --- .../views/products/view/configurable-options.blade.php | 4 ++-- .../views/shop/products/view/configurable-options.blade.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 2eed78664..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 @@ -279,14 +279,14 @@ if (this.childAttributes.length == selectedOptionCount) { priceLabelElement.style.display = 'none'; - regularPriceElement.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'; - regularPriceElement.style.display = 'inline-block'; priceElement.innerHTML = this.config.regular_price.formated_price; diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/products/view/configurable-options.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/products/view/configurable-options.blade.php index 8a2168818..d2757fd89 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/products/view/configurable-options.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/products/view/configurable-options.blade.php @@ -294,14 +294,14 @@ if (this.childAttributes.length == selectedOptionCount) { priceLabelElement.style.display = 'none'; - regularPriceElement.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'; - regularPriceElement.style.display = 'inline-block'; priceElement.innerHTML = this.config.regular_price.formated_price; From a8cdf29fc7aed023d982b802e09845ba39d66857 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Mon, 1 Feb 2021 15:35:04 +0530 Subject: [PATCH 3/7] Issue #3572, fixes percentage for 2 decimal values --- packages/Webkul/Product/src/Type/AbstractType.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php index 083c38c57..eb286c93f 100644 --- a/packages/Webkul/Product/src/Type/AbstractType.php +++ b/packages/Webkul/Product/src/Type/AbstractType.php @@ -959,7 +959,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)); } } @@ -985,7 +985,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]); From 4b1109823b989361248b3eaf82ef7c8f8b6725c2 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Mon, 1 Feb 2021 16:16:05 +0530 Subject: [PATCH 4/7] Issue #4533, set scheduler for daily basis --- app/Console/Kernel.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 2cf59a56a..7610f8751 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -25,6 +25,8 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule) { $schedule->command('booking:cron')->dailyAt('3:00'); + + $schedule->command('campaign:process')->daily(); } /** @@ -36,6 +38,7 @@ class Kernel extends ConsoleKernel { $this->load(__DIR__.'/Commands'); $this->load(__DIR__.'/../../packages/Webkul/Core/src/Console/Commands'); + $this->load(__DIR__.'/../../packages/Webkul/Marketing/src/Console/Commands'); require base_path('routes/console.php'); } From c9d09731e1446629b0ffba75b484b3f67d982295 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Mon, 1 Feb 2021 16:40:13 +0530 Subject: [PATCH 5/7] chnage according to comment --- app/Console/Kernel.php | 3 --- .../Marketing/src/Providers/MarketingServiceProvider.php | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 7610f8751..2cf59a56a 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -25,8 +25,6 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule) { $schedule->command('booking:cron')->dailyAt('3:00'); - - $schedule->command('campaign:process')->daily(); } /** @@ -38,7 +36,6 @@ class Kernel extends ConsoleKernel { $this->load(__DIR__.'/Commands'); $this->load(__DIR__.'/../../packages/Webkul/Core/src/Console/Commands'); - $this->load(__DIR__.'/../../packages/Webkul/Marketing/src/Console/Commands'); require base_path('routes/console.php'); } diff --git a/packages/Webkul/Marketing/src/Providers/MarketingServiceProvider.php b/packages/Webkul/Marketing/src/Providers/MarketingServiceProvider.php index ba2ffaf37..34cad0cf8 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('comain:process')->daily(); + }); } /** From 1f6f7a3bac046becec2089b81ba5af5ec3489c95 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Mon, 1 Feb 2021 16:44:46 +0530 Subject: [PATCH 6/7] corrected spelling --- .../Webkul/Marketing/src/Providers/MarketingServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Webkul/Marketing/src/Providers/MarketingServiceProvider.php b/packages/Webkul/Marketing/src/Providers/MarketingServiceProvider.php index 34cad0cf8..d5f19b8ea 100644 --- a/packages/Webkul/Marketing/src/Providers/MarketingServiceProvider.php +++ b/packages/Webkul/Marketing/src/Providers/MarketingServiceProvider.php @@ -20,7 +20,7 @@ class MarketingServiceProvider extends ServiceProvider $this->loadRoutesFrom(__DIR__ . '/../Http/routes.php'); $this->callAfterResolving(Schedule::class, function (Schedule $schedule) { - $schedule->command('comain:process')->daily(); + $schedule->command('campaign:process')->daily(); }); } From 6c69025a13b8052515a97b76e83166a587d2e0b1 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Mon, 1 Feb 2021 17:28:37 +0530 Subject: [PATCH 7/7] Issue #4532 fixed --- .../views/customers/account/profile/edit.blade.php | 8 ++++++++ .../shop/customers/account/profile/edit.blade.php | 13 +++++++++++++ 2 files changed, 21 insertions(+) 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/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]) !!} +