From c3bfcf5d79225fac43fb7734c524d628ee1f949a Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Sat, 22 Jun 2019 13:53:36 +0530 Subject: [PATCH] Show price after login modified --- config/app.php | 2 +- .../views/products/add-buttons.blade.php | 88 +++++++++++++++---- .../views/products/add-to-cart.blade.php | 21 ++++- .../views/products/buy-now.blade.php | 22 ++++- .../Resources/views/products/price.blade.php | 71 ++++++++++++--- .../views/products/review-price.blade.php | 10 ++- .../views/products/view/product-add.blade.php | 38 +++++++- .../Http/Middleware/ShowShopAfterLogin.php | 26 ++++++ .../src/Resources/lang/en/app.php | 3 +- .../views/Shop/add-buttons.blade.php | 7 +- .../views/Shop/add-to-cart.blade.php | 2 +- .../views/Shop/view/product-add.blade.php | 50 +++++++---- 12 files changed, 277 insertions(+), 63 deletions(-) diff --git a/config/app.php b/config/app.php index c2ff96bcf..c6d52aaaf 100755 --- a/config/app.php +++ b/config/app.php @@ -251,7 +251,7 @@ return [ Webkul\AdminAuthCheck\Providers\AdminAuthCheckServiceProvider::class, Webkul\StripeConnect\Providers\StripeConnectServiceProvider::class, Webkul\CustomerGroupCatalog\Providers\CustomerGroupCatalogServiceProvider::class, - // Webkul\ShowPriceAfterLogin\Providers\ShowPriceAfterLoginServiceProvider::class, + Webkul\ShowPriceAfterLogin\Providers\ShowPriceAfterLoginServiceProvider::class, Webkul\CustomerCreditMax\Providers\CustomerCreditMaxServiceProvider::class, Webkul\SAASPreOrder\Providers\SAASPreOrderServiceProvider::class, Webkul\SAASCustomizer\Providers\SAASCustomizerServiceProvider::class diff --git a/packages/Webkul/Shop/src/Resources/views/products/add-buttons.blade.php b/packages/Webkul/Shop/src/Resources/views/products/add-buttons.blade.php index 22c22ef3a..48a0f326e 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/add-buttons.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/add-buttons.blade.php @@ -1,22 +1,76 @@ +@php + $status = core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable'); - @if ($product->type == "configurable") -
- - {{ __('shop::app.products.add-to-cart') }} + $function = core()->getConfigData('ShowPriceAfterLogin.settings.settings.selectfunction'); +@endphp + +@if (Route::currentRouteName() == "shop.products.index") + @include ('shop::products.add-to', ['product' => $product]) +@else + @if(auth()->guard('customer')->check() && $status) + @if ($product->type == "configurable") +
+ + {{ __('shop::app.products.add-to-cart') }} + + + @include('shop::products.wishlist') +
+ @else +
+
+ @csrf + + + + +
+ + @include('shop::products.wishlist') +
+ @endif + + + + @elseif (! auth()->guard('customer')->check() && $status && ($status == "hide-buy-cart-guest")) + + @elseif (! auth()->guard('customer')->check() && $status && $function == "hide-price-buy-cart-guest") + @else -
-
- @csrf - - - - -
+ @if ($product->type == "configurable") +
+ + {{ __('shop::app.products.add-to-cart') }} + - @include('shop::products.wishlist') -
- @endif \ No newline at end of file + @include('shop::products.wishlist') +
+ @else +
+
+ @csrf + + + + + @if ($product->totalQuantity() < 1 && $product->allow_preorder) + + @else + + @endif +
+ + @include('shop::products.wishlist') +
+ @endif + + @endif +@endif \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/products/add-to-cart.blade.php b/packages/Webkul/Shop/src/Resources/views/products/add-to-cart.blade.php index 6f3e31784..3f9151fdd 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/add-to-cart.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/add-to-cart.blade.php @@ -1,7 +1,22 @@ {!! view_render_event('bagisto.shop.products.add_to_cart.before', ['product' => $product]) !!} - +@php + $status = core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable'); + $function = core()->getConfigData('ShowPriceAfterLogin.settings.settings.selectfunction'); +@endphp + +@if(auth()->guard('customer')->check() && $status) + + +@elseif(! auth()->guard('customer')->check() && $status && ($function == "hide-price-buy-cart-guest" || $function == "hide-buy-cart-guest")) + +@else + + +@endif {!! view_render_event('bagisto.shop.products.add_to_cart.after', ['product' => $product]) !!} \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/products/buy-now.blade.php b/packages/Webkul/Shop/src/Resources/views/products/buy-now.blade.php index e38dcda14..7450c39e3 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/buy-now.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/buy-now.blade.php @@ -1,7 +1,23 @@ {!! view_render_event('bagisto.shop.products.buy_now.before', ['product' => $product]) !!} - +@php + $status = core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable'); + + $function = core()->getConfigData('ShowPriceAfterLogin.settings.settings.selectfunction'); +@endphp + +@if(auth()->guard('customer')->check() && $status) + + +@elseif(! auth()->guard('customer')->check() && $status && ( $function == "hide-price-buy-cart-guest" || $function == "hide-buy-cart-guest")) + + +@else + +@endif {!! view_render_event('bagisto.shop.products.buy_now.after', ['product' => $product]) !!} \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/products/price.blade.php b/packages/Webkul/Shop/src/Resources/views/products/price.blade.php index a6d740bc4..bb55b2433 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/price.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/price.blade.php @@ -1,25 +1,70 @@ {!! view_render_event('bagisto.shop.products.price.before', ['product' => $product]) !!} +@php + $status = core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable'); + + $function = core()->getConfigData('ShowPriceAfterLogin.settings.settings.selectfunction'); +@endphp
- @inject ('priceHelper', 'Webkul\Product\Helpers\Price') + @if(auth()->guard('customer')->check() && $status) + @inject ('priceHelper', 'Webkul\Product\Helpers\Price') - @if ($product->type == 'configurable') - {{ __('shop::app.products.price-label') }} + @if ($product->type == 'configurable') - {{ core()->currency($priceHelper->getMinimalPrice($product)) }} - @else - @if ($priceHelper->haveSpecialPrice($product)) -
- {{ __('shop::app.products.sale') }} -
+ {{ __('shop::app.products.price-label') }} - {{ core()->currency($product->price) }} + {{ core()->currency($priceHelper->getMinimalPrice($product)) }} - {{ core()->currency($priceHelper->getSpecialPrice($product)) }} @else - {{ core()->currency($product->price) }} + + @if ($priceHelper->haveSpecialPrice($product)) + +
+ {{ __('shop::app.products.sale') }} +
+ + {{ core()->currency($product->price) }} + + {{ core()->currency($priceHelper->getSpecialPrice($product)) }} + + @else + + {{ core()->currency($product->price) }} + + @endif + + @endif + + @elseif(!auth()->guard('customer')->check() && $status && ($function == "hide-price-buy-cart-guest")) + + @else + @inject ('priceHelper', 'Webkul\Product\Helpers\Price') + + @if ($product->type == 'configurable') + + {{ __('shop::app.products.price-label') }} + + {{ core()->currency($priceHelper->getMinimalPrice($product)) }} + + @else + + @if ($priceHelper->haveSpecialPrice($product)) + +
+ {{ __('shop::app.products.sale') }} +
+ + {{ core()->currency($product->price) }} + + {{ core()->currency($priceHelper->getSpecialPrice($product)) }} + + @else + + {{ core()->currency($product->price) }} + + @endif + @endif @endif
- {!! view_render_event('bagisto.shop.products.price.after', ['product' => $product]) !!} \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/products/review-price.blade.php b/packages/Webkul/Shop/src/Resources/views/products/review-price.blade.php index 4a69f26af..717cf28c4 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/review-price.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/review-price.blade.php @@ -1,3 +1,10 @@ +@php + $status = core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable'); + + $function = core()->getConfigData('ShowPriceAfterLogin.settings.settings.selectfunction'); +@endphp + +@if(! $status)
@inject ('priceHelper', 'Webkul\Product\Helpers\Price') @@ -10,4 +17,5 @@ {{ core()->currency($product->price) }} @endif @endif -
\ No newline at end of file +
+@endif \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/views/products/view/product-add.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view/product-add.blade.php index 3254792c6..11308baf4 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/view/product-add.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view/product-add.blade.php @@ -1,9 +1,41 @@ {!! view_render_event('bagisto.shop.products.view.product-add.after', ['product' => $product]) !!} -
- @include ('shop::products.add-to-cart', ['product' => $product]) +@php +$status = core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable'); - @include ('shop::products.buy-now') +$function = core()->getConfigData('ShowPriceAfterLogin.settings.settings.selectfunction'); +@endphp + +
+ @if ($product->type != 'configurable') + @if ($product->totalQuantity() < 1 && $product->allow_preorder) + + @else + @include ('shop::products.add-to-cart', ['product' => $product]) + + @include ('shop::products.buy-now') + @endif + @else + @include ('shop::products.add-to-cart', ['product' => $product]) + + @include ('shop::products.buy-now') + + @if(! auth()->guard('customer')->check() && $status && $function == "hide-price-buy-cart-guest") + + @elseif (! auth()->guard('customer')->check() && $status && ($function == "hide-buy-cart-guest")) + + @endif + @endif
{!! view_render_event('bagisto.shop.products.view.product-add.after', ['product' => $product]) !!} \ No newline at end of file diff --git a/packages/Webkul/ShowPriceAfterLogin/src/Http/Middleware/ShowShopAfterLogin.php b/packages/Webkul/ShowPriceAfterLogin/src/Http/Middleware/ShowShopAfterLogin.php index 443e9cb9c..b5e743406 100644 --- a/packages/Webkul/ShowPriceAfterLogin/src/Http/Middleware/ShowShopAfterLogin.php +++ b/packages/Webkul/ShowPriceAfterLogin/src/Http/Middleware/ShowShopAfterLogin.php @@ -15,6 +15,32 @@ class ShowShopAfterLogin */ public function handle($request, Closure $next) { + $primaryServerName = config('app.url'); + + $currentURL = $_SERVER['SERVER_NAME']; + + $params['domain'] = $currentURL; + + if (str_contains($primaryServerName, 'http://')) { + $primaryServerNameWithoutProtocol = explode('http://', $primaryServerName)[1]; + } else if (str_contains($primaryServerName, 'https://')) { + $primaryServerNameWithoutProtocol = explode('https://', $primaryServerName)[1]; + } else { + $primaryServerNameWithoutProtocol = $primaryServerName; + } + + if (str_contains($currentURL, 'http://')) { + $currentServerNameWithoutProtocol = explode('http://', $currentURL)[1]; + } else if (str_contains($currentURL, 'https://')) { + $currentServerNameWithoutProtocol = explode('https://', $currentURL)[1]; + } else { + $currentServerNameWithoutProtocol = $currentURL; + } + + if ($primaryServerNameWithoutProtocol == $primaryServerNameWithoutProtocol) { + return $next($request); + } + $status =(boolean) core()->getConfigData('ShowPriceAfterLogin.settings.settings.hide-shop-before-login'); $moduleEnabled =(boolean) core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable'); diff --git a/packages/Webkul/ShowPriceAfterLogin/src/Resources/lang/en/app.php b/packages/Webkul/ShowPriceAfterLogin/src/Resources/lang/en/app.php index 14ae839ce..7590896d7 100644 --- a/packages/Webkul/ShowPriceAfterLogin/src/Resources/lang/en/app.php +++ b/packages/Webkul/ShowPriceAfterLogin/src/Resources/lang/en/app.php @@ -8,10 +8,11 @@ return [ 'hide-shop-before-login' => 'Hide Shop Before Login', 'hide-price-buy-cart-guest' => 'Hide Price & Buy/Add-to-Cart For Guest', 'hide-buy-cart-guest' => 'Hide Buy/Add-to-Cart For Guest', - 'select-function' => 'Select Functional', + 'select-function' => 'Select Function', 'configure' => 'Configure', 'configurations' => 'Configuration', ], + 'products' => [ 'login-to-view-price' => 'Login To View Price', 'login-to-buy' => 'Login To Buy' diff --git a/packages/Webkul/ShowPriceAfterLogin/src/Resources/views/Shop/add-buttons.blade.php b/packages/Webkul/ShowPriceAfterLogin/src/Resources/views/Shop/add-buttons.blade.php index 854770b59..48a0f326e 100644 --- a/packages/Webkul/ShowPriceAfterLogin/src/Resources/views/Shop/add-buttons.blade.php +++ b/packages/Webkul/ShowPriceAfterLogin/src/Resources/views/Shop/add-buttons.blade.php @@ -60,7 +60,12 @@ - + + @if ($product->totalQuantity() < 1 && $product->allow_preorder) + + @else + + @endif @include('shop::products.wishlist') diff --git a/packages/Webkul/ShowPriceAfterLogin/src/Resources/views/Shop/add-to-cart.blade.php b/packages/Webkul/ShowPriceAfterLogin/src/Resources/views/Shop/add-to-cart.blade.php index 55c0e025c..3f9151fdd 100755 --- a/packages/Webkul/ShowPriceAfterLogin/src/Resources/views/Shop/add-to-cart.blade.php +++ b/packages/Webkul/ShowPriceAfterLogin/src/Resources/views/Shop/add-to-cart.blade.php @@ -14,7 +14,7 @@ @elseif(! auth()->guard('customer')->check() && $status && ($function == "hide-price-buy-cart-guest" || $function == "hide-buy-cart-guest")) @else - diff --git a/packages/Webkul/ShowPriceAfterLogin/src/Resources/views/Shop/view/product-add.blade.php b/packages/Webkul/ShowPriceAfterLogin/src/Resources/views/Shop/view/product-add.blade.php index 0521ef014..11308baf4 100644 --- a/packages/Webkul/ShowPriceAfterLogin/src/Resources/views/Shop/view/product-add.blade.php +++ b/packages/Webkul/ShowPriceAfterLogin/src/Resources/views/Shop/view/product-add.blade.php @@ -1,28 +1,40 @@ {!! view_render_event('bagisto.shop.products.view.product-add.after', ['product' => $product]) !!} +@php +$status = core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable'); + +$function = core()->getConfigData('ShowPriceAfterLogin.settings.settings.selectfunction'); +@endphp +
- @include ('shop::products.add-to-cart', ['product' => $product]) + @if ($product->type != 'configurable') + @if ($product->totalQuantity() < 1 && $product->allow_preorder) + + @else + @include ('shop::products.add-to-cart', ['product' => $product]) - @include ('shop::products.buy-now') + @include ('shop::products.buy-now') + @endif + @else + @include ('shop::products.add-to-cart', ['product' => $product]) - @php - $status = core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable'); + @include ('shop::products.buy-now') - $function = core()->getConfigData('ShowPriceAfterLogin.settings.settings.selectfunction'); - @endphp - - @if(! auth()->guard('customer')->check() && $status && $function == "hide-price-buy-cart-guest") - - @elseif (! auth()->guard('customer')->check() && $status && ($function == "hide-buy-cart-guest")) - + @if(! auth()->guard('customer')->check() && $status && $function == "hide-price-buy-cart-guest") + + @elseif (! auth()->guard('customer')->check() && $status && ($function == "hide-buy-cart-guest")) + + @endif @endif