utilisation du setting de display prix
This commit is contained in:
parent
0efd3c9cf8
commit
f6dfd4135f
3 changed files with 44 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 "-.--";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -83,7 +83,12 @@ class AppServiceProvider extends ServiceProvider
|
|||
View::share('front_settings', $front_settings);
|
||||
|
||||
Blade::directive('fmt_currency', function ($expression) {
|
||||
return "<?php echo sprintf('%s € TTC', number_format($expression, 2, ',', ' ')); ?>";
|
||||
return "<?php
|
||||
if(is_float($expression)) {
|
||||
echo sprintf('%s € TTC', number_format($expression, 2, ',', ' '));
|
||||
} else {
|
||||
echo $expression;
|
||||
} ?>";
|
||||
});
|
||||
|
||||
Blade::directive('fmt_sellunit', function ($expression) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue