Show price after login modified

This commit is contained in:
Prashant Singh 2019-06-22 13:53:36 +05:30
parent 1d988dd82a
commit c3bfcf5d79
12 changed files with 277 additions and 63 deletions

View File

@ -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

View File

@ -1,22 +1,76 @@
@php
$status = core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable');
@if ($product->type == "configurable")
<div class="cart-wish-wrap">
<a href="{{ route('cart.add.configurable', $product->url_key) }}" class="btn btn-lg btn-primary addtocart">
{{ __('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")
<div class="cart-wish-wrap">
<a href="{{ route('cart.add.configurable', $product->url_key) }}" class="btn btn-lg btn-primary addtocart">
{{ __('shop::app.products.add-to-cart') }}
</a>
@include('shop::products.wishlist')
</div>
@else
<div class="cart-wish-wrap">
<form action="{{ route('cart.add', $product->id) }}" method="POST">
@csrf
<input type="hidden" name="product" value="{{ $product->id }}">
<input type="hidden" name="quantity" value="1">
<input type="hidden" value="false" name="is_configurable">
<button class="btn btn-lg btn-primary addtocart" {{ $product->haveSufficientQuantity(1) ? '' : 'disabled' }}>{{ __('shop::app.products.add-to-cart') }}</button>
</form>
@include('shop::products.wishlist')
</div>
@endif
@elseif (! auth()->guard('customer')->check() && $status && ($status == "hide-buy-cart-guest"))
<div class="login-to-view-price" style="width:100%;">
<a class="btn btn-lg btn-primary addtocart" href="{{ route('customer.session.index') }}">
{{ __('ShowPriceAfterLogin::app.products.login-to-buy') }}
</a>
</div>
@elseif (! auth()->guard('customer')->check() && $status && $function == "hide-price-buy-cart-guest")
<div class="login-to-view-price" style="width:100%;">
<a class="btn btn-lg btn-primary addtocart" href="{{ route('customer.session.index') }}">
{{ __('ShowPriceAfterLogin::app.products.login-to-view-price') }}
</a>
@include('shop::products.wishlist')
</div>
@else
<div class="cart-wish-wrap">
<form action="{{ route('cart.add', $product->product_id) }}" method="POST">
@csrf
<input type="hidden" name="product" value="{{ $product->product_id }}">
<input type="hidden" name="quantity" value="1">
<input type="hidden" value="false" name="is_configurable">
<button class="btn btn-lg btn-primary addtocart" {{ $product->haveSufficientQuantity(1) ? '' : 'disabled' }}>{{ __('shop::app.products.add-to-cart') }}</button>
</form>
@if ($product->type == "configurable")
<div class="cart-wish-wrap">
<a href="{{ route('cart.add.configurable', $product->url_key) }}" class="btn btn-lg btn-primary addtocart">
{{ __('shop::app.products.add-to-cart') }}
</a>
@include('shop::products.wishlist')
</div>
@endif
@include('shop::products.wishlist')
</div>
@else
<div class="cart-wish-wrap">
<form action="{{ route('cart.add', $product->id) }}" method="POST">
@csrf
<input type="hidden" name="product" value="{{ $product->id }}">
<input type="hidden" name="quantity" value="1">
<input type="hidden" value="false" name="is_configurable">
@if ($product->totalQuantity() < 1 && $product->allow_preorder)
<button class="btn btn-lg btn-primary addtocart">{{ __('preorder::app.shop.products.preorder') }}</button>
@else
<button class="btn btn-lg btn-primary addtocart" {{ $product->haveSufficientQuantity(1) ? '' : 'disabled' }}>{{ __('shop::app.products.add-to-cart') }}</button>
@endif
</form>
@include('shop::products.wishlist')
</div>
@endif
@endif
@endif

View File

@ -1,7 +1,22 @@
{!! view_render_event('bagisto.shop.products.add_to_cart.before', ['product' => $product]) !!}
<button type="submit" class="btn btn-lg btn-primary addtocart" {{ $product->type != 'configurable' && ! $product->haveSufficientQuantity(1) ? 'disabled' : '' }}>
{{ __('shop::app.products.add-to-cart') }}
</button>
@php
$status = core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable');
$function = core()->getConfigData('ShowPriceAfterLogin.settings.settings.selectfunction');
@endphp
@if(auth()->guard('customer')->check() && $status)
<button type="submit" class="btn btn-lg btn-primary addtocart" {{ $product->type != 'configurable' && !$product->haveSufficientQuantity(1) ? 'disabled' : '' }}>
{{ __('shop::app.products.add-to-cart') }}
</button>
@elseif(! auth()->guard('customer')->check() && $status && ($function == "hide-price-buy-cart-guest" || $function == "hide-buy-cart-guest"))
@else
<button type="submit" class="btn btn-lg btn-primary addtocart" {{ $product->type != 'configurable' && ! $product->haveSufficientQuantity(1) ? 'disabled' : '' }}>
{{ __('shop::app.products.add-to-cart') }}
</button>
@endif
{!! view_render_event('bagisto.shop.products.add_to_cart.after', ['product' => $product]) !!}

View File

@ -1,7 +1,23 @@
{!! view_render_event('bagisto.shop.products.buy_now.before', ['product' => $product]) !!}
<button type="submit" data-href="{{ route('shop.product.buynow', $product->product_id)}}" class="btn btn-lg btn-primary buynow" {{ $product->type != 'configurable' && ! $product->haveSufficientQuantity(1) ? 'disabled' : '' }}>
{{ __('shop::app.products.buy-now') }}
</button>
@php
$status = core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable');
$function = core()->getConfigData('ShowPriceAfterLogin.settings.settings.selectfunction');
@endphp
@if(auth()->guard('customer')->check() && $status)
<button type="submit" data-href="{{ route('shop.product.buynow', $product->id)}}" class="btn btn-lg btn-primary buynow" {{ $product->type != 'configurable' && !$product->haveSufficientQuantity(1) ? 'disabled' : '' }}>
{{ __('shop::app.products.buy-now') }}
</button>
@elseif(! auth()->guard('customer')->check() && $status && ( $function == "hide-price-buy-cart-guest" || $function == "hide-buy-cart-guest"))
@else
<button type="submit" data-href="{{ route('shop.product.buynow', $product->id)}}" class="btn btn-lg btn-primary buynow" {{ $product->type != 'configurable' && !$product->haveSufficientQuantity(1) ? 'disabled' : '' }}>
{{ __('shop::app.products.buy-now') }}
</button>
@endif
{!! view_render_event('bagisto.shop.products.buy_now.after', ['product' => $product]) !!}

View File

@ -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
<div class="product-price">
@inject ('priceHelper', 'Webkul\Product\Helpers\Price')
@if(auth()->guard('customer')->check() && $status)
@inject ('priceHelper', 'Webkul\Product\Helpers\Price')
@if ($product->type == 'configurable')
<span class="price-label">{{ __('shop::app.products.price-label') }}</span>
@if ($product->type == 'configurable')
<span class="final-price">{{ core()->currency($priceHelper->getMinimalPrice($product)) }}</span>
@else
@if ($priceHelper->haveSpecialPrice($product))
<div class="sticker sale">
{{ __('shop::app.products.sale') }}
</div>
<span class="price-label">{{ __('shop::app.products.price-label') }}</span>
<span class="regular-price">{{ core()->currency($product->price) }}</span>
<span class="final-price">{{ core()->currency($priceHelper->getMinimalPrice($product)) }}</span>
<span class="special-price">{{ core()->currency($priceHelper->getSpecialPrice($product)) }}</span>
@else
<span>{{ core()->currency($product->price) }}</span>
@if ($priceHelper->haveSpecialPrice($product))
<div class="sticker sale">
{{ __('shop::app.products.sale') }}
</div>
<span class="regular-price">{{ core()->currency($product->price) }}</span>
<span class="special-price">{{ core()->currency($priceHelper->getSpecialPrice($product)) }}</span>
@else
<span>{{ core()->currency($product->price) }}</span>
@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')
<span class="price-label">{{ __('shop::app.products.price-label') }}</span>
<span class="final-price">{{ core()->currency($priceHelper->getMinimalPrice($product)) }}</span>
@else
@if ($priceHelper->haveSpecialPrice($product))
<div class="sticker sale">
{{ __('shop::app.products.sale') }}
</div>
<span class="regular-price">{{ core()->currency($product->price) }}</span>
<span class="special-price">{{ core()->currency($priceHelper->getSpecialPrice($product)) }}</span>
@else
<span>{{ core()->currency($product->price) }}</span>
@endif
@endif
@endif
</div>
{!! view_render_event('bagisto.shop.products.price.after', ['product' => $product]) !!}

View File

@ -1,3 +1,10 @@
@php
$status = core()->getConfigData('ShowPriceAfterLogin.settings.settings.enableordisable');
$function = core()->getConfigData('ShowPriceAfterLogin.settings.settings.selectfunction');
@endphp
@if(! $status)
<div class="product-price mt-10">
@inject ('priceHelper', 'Webkul\Product\Helpers\Price')
@ -10,4 +17,5 @@
<span class="pro-price">{{ core()->currency($product->price) }}</span>
@endif
@endif
</div>
</div>
@endif

View File

@ -1,9 +1,41 @@
{!! view_render_event('bagisto.shop.products.view.product-add.after', ['product' => $product]) !!}
<div class="add-to-buttons">
@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
<div class="add-to-buttons">
@if ($product->type != 'configurable')
@if ($product->totalQuantity() < 1 && $product->allow_preorder)
<button type="submit" class="btn btn-lg btn-primary addtocart" style="width: 100%">
{{ __('preorder::app.shop.products.preorder') }}
</button>
@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")
<div class="login-to-view-price" style="width:100%;">
<a class="btn btn-lg btn-primary addtocart" href="{{ route('customer.session.index') }}">
{{ __('ShowPriceAfterLogin::app.products.login-to-view-price') }}
</a>
</div>
@elseif (! auth()->guard('customer')->check() && $status && ($function == "hide-buy-cart-guest"))
<div class="login-to-view-price" style="width:100%;">
<a class="btn btn-lg btn-primary addtocart" href="{{ route('customer.session.index') }}">
{{ __('ShowPriceAfterLogin::app.products.login-to-buy') }}
</a>
</div>
@endif
@endif
</div>
{!! view_render_event('bagisto.shop.products.view.product-add.after', ['product' => $product]) !!}

View File

@ -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');

View File

@ -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'

View File

@ -60,7 +60,12 @@
<input type="hidden" name="product" value="{{ $product->id }}">
<input type="hidden" name="quantity" value="1">
<input type="hidden" value="false" name="is_configurable">
<button class="btn btn-lg btn-primary addtocart" {{ $product->haveSufficientQuantity(1) ? '' : 'disabled' }}>{{ __('shop::app.products.add-to-cart') }}</button>
@if ($product->totalQuantity() < 1 && $product->allow_preorder)
<button class="btn btn-lg btn-primary addtocart">{{ __('preorder::app.shop.products.preorder') }}</button>
@else
<button class="btn btn-lg btn-primary addtocart" {{ $product->haveSufficientQuantity(1) ? '' : 'disabled' }}>{{ __('shop::app.products.add-to-cart') }}</button>
@endif
</form>
@include('shop::products.wishlist')

View File

@ -14,7 +14,7 @@
@elseif(! auth()->guard('customer')->check() && $status && ($function == "hide-price-buy-cart-guest" || $function == "hide-buy-cart-guest"))
@else
<button type="submit" class="btn btn-lg btn-primary addtocart" {{ $product->type != 'configurable' && !$product->haveSufficientQuantity(1) ? 'disabled' : '' }}>
<button type="submit" class="btn btn-lg btn-primary addtocart" {{ $product->type != 'configurable' && ! $product->haveSufficientQuantity(1) ? 'disabled' : '' }}>
{{ __('shop::app.products.add-to-cart') }}
</button>

View File

@ -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
<div class="add-to-buttons">
@include ('shop::products.add-to-cart', ['product' => $product])
@if ($product->type != 'configurable')
@if ($product->totalQuantity() < 1 && $product->allow_preorder)
<button type="submit" class="btn btn-lg btn-primary addtocart" style="width: 100%">
{{ __('preorder::app.shop.products.preorder') }}
</button>
@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")
<div class="login-to-view-price" style="width:100%;">
<a class="btn btn-lg btn-primary addtocart" href="{{ route('customer.session.index') }}">
{{ __('ShowPriceAfterLogin::app.products.login-to-view-price') }}
</a>
</div>
@elseif (! auth()->guard('customer')->check() && $status && ($function == "hide-buy-cart-guest"))
<div class="login-to-view-price" style="width:100%;">
<a class="btn btn-lg btn-primary addtocart" href="{{ route('customer.session.index') }}">
{{ __('ShowPriceAfterLogin::app.products.login-to-buy') }}
</a>
</div>
@if(! auth()->guard('customer')->check() && $status && $function == "hide-price-buy-cart-guest")
<div class="login-to-view-price" style="width:100%;">
<a class="btn btn-lg btn-primary addtocart" href="{{ route('customer.session.index') }}">
{{ __('ShowPriceAfterLogin::app.products.login-to-view-price') }}
</a>
</div>
@elseif (! auth()->guard('customer')->check() && $status && ($function == "hide-buy-cart-guest"))
<div class="login-to-view-price" style="width:100%;">
<a class="btn btn-lg btn-primary addtocart" href="{{ route('customer.session.index') }}">
{{ __('ShowPriceAfterLogin::app.products.login-to-buy') }}
</a>
</div>
@endif
@endif
</div>