diff --git a/app/Http/Controllers/BasketController.php b/app/Http/Controllers/BasketController.php index dca0190..2dc2af2 100644 --- a/app/Http/Controllers/BasketController.php +++ b/app/Http/Controllers/BasketController.php @@ -6,6 +6,7 @@ use App\Models\Product; use Illuminate\Http\Request; use Illuminate\Support\Collection; use Gloudemans\Shoppingcart\Facades\Cart; +use Illuminate\Support\Facades\Auth; class BasketController extends Controller { @@ -98,7 +99,27 @@ class BasketController extends Controller 'countItems' => Cart::count(), //nb de produits dans le cart ); - $cartReturn = array($dbpanier,$cartInfos); + $cartInfosNoPrice = array( + "totalTTC" => "-.--", + 'totalTVA' => "-.--", //total des taxes + 'totalHT' => "-.--", //total sans les taxes + 'totalweight' => Cart::weight(), //poids total des items + 'totalHTbefore' => "-.--", //total avant taxes et remises + 'totaldiscount' => "-.--", //total des remises + 'countItems' => Cart::count(), //nb de produits dans le cart + ); + + $cartReturn = array($dbpanier,$cartInfosNoPrice); + if (config('bosettings.show_prices_authenticated') == "authenticated") { + { + if (Auth::guard('customer')->check()) { + $cartReturn = array($dbpanier,$cartInfos); + } + } + } + if (config('bosettings.show_prices_guest') == "guest") { + $cartReturn = array($dbpanier,$cartInfos); + } return $cartReturn; } diff --git a/app/Models/Product.php b/app/Models/Product.php index 8b7624b..ac9b568 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -11,6 +11,8 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Gloudemans\Shoppingcart\Contracts\Buyable; use Gloudemans\Shoppingcart\CanBeBought; +use Illuminate\Support\Facades\Auth; + /** * @todo : unité de vente/unité de poids devrait être des énums (via table liée ou package enum) */ @@ -177,13 +179,25 @@ class Product extends Model implements Buyable public function getDiscountedPriceTtcAttribute() { if (isset($this->discountedPriceTtc)) { - return $this->discountedPriceTtc; + $showPrice = $this->discountedPriceTtc; } else { $discountedPriceTtc = $this->discountedPriceHt * ( 1 + ( $this->tax->rate / 100)); //on travaille avec des centimes puis on redivise par 100 pour avoir des unités monetaires $roundingDiscountedPriceTTC = round($discountedPriceTtc * 100) / 100; - return $this->discountedPriceTtc = $roundingDiscountedPriceTTC; + $showPrice = $this->discountedPriceTtc = $roundingDiscountedPriceTTC; } + //prix transmis en fonction du setting show_prices + if (config('bosettings.show_prices_authenticated') == "authenticated") { + { + if (Auth::guard('customer')->check()) { + return $showPrice; + } + } + } + if (config('bosettings.show_prices_guest') == "guest") { + return $showPrice; + } + return "-.--"; } /** diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index f269336..cd50a26 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -83,7 +83,12 @@ class AppServiceProvider extends ServiceProvider View::share('front_settings', $front_settings); Blade::directive('fmt_currency', function ($expression) { - return ""; + return ""; }); Blade::directive('fmt_sellunit', function ($expression) {