better management of shipping and basket summary display

This commit is contained in:
ludo
2023-12-03 00:40:47 +01:00
parent 4bcfc7bc6d
commit ec509df665
26 changed files with 317 additions and 477 deletions

View File

@@ -2,7 +2,7 @@
namespace App\Http\Controllers\Admin\Shop; namespace App\Http\Controllers\Admin\Shop;
use App\Datatables\Shop\PriceListsDataTable; use App\Datatables\Admin\Shop\PriceListsDataTable;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Repositories\Shop\PriceLists; use App\Repositories\Shop\PriceLists;
use App\Repositories\Shop\SaleChannels; use App\Repositories\Shop\SaleChannels;
@@ -14,45 +14,20 @@ class PriceListController extends Controller
{ {
public function index(PriceListsDataTable $dataTable) public function index(PriceListsDataTable $dataTable)
{ {
$data = []; return $dataTable->render('Admin.Shop.PriceLists.list');
return $dataTable->render('Admin.Shop.PriceLists.list', $data);
} }
public function create() public function modalCreate($tariffId)
{ {
$data = []; $data = PriceLists::init($tariffId);
$data['sale_channels'] = SaleChannels::getOptions();
return view('Admin.Shop.PriceLists.create', $data);
}
public function edit($id)
{
$data['price_list'] = PriceLists::get($id);
$data['sale_channels'] = SaleChannels::getOptions();
return view('Admin.Shop.PriceLists.edit', $data);
}
public function modalCreate($tariff_id)
{
$data = [];
$data['price_list']['tariff_id'] = $tariff_id;
$data['price_list']['price_list_values'] = array_fill(0, 3, '');
$data['sale_channels'] = SaleChannels::getOptions();
$data['statuses'] = Tariffs::getStatuses();
$data['taxes'] = Taxes::getOptions();
return view('Admin.Shop.PriceLists.modal', $data); return view('Admin.Shop.PriceLists.modal', $data);
} }
public function modalEdit($id) public function modalEdit($id)
{ {
$data = PriceLists::init();
$data['price_list'] = PriceLists::edit($id); $data['price_list'] = PriceLists::edit($id);
$data['sale_channels'] = SaleChannels::getOptions();
$data['statuses'] = Tariffs::getStatuses();
$data['taxes'] = Taxes::getOptions();
return view('Admin.Shop.PriceLists.modal', $data); return view('Admin.Shop.PriceLists.modal', $data);
} }

View File

@@ -25,32 +25,22 @@ class TariffController extends Controller
public function create() public function create()
{ {
$data['sale_channels'] = SaleChannels::getOptions(); $data = Tariffs::init();
$data['statuses'] = Tariffs::getStatuses();
$data['tariff_unities'] = TariffUnities::getOptions();
$model = new PriceListsDataTable();
$data['datatables']['price_lists'] = $model->html();
return view('Admin.Shop.Tariffs.create', $data); return view('Admin.Shop.Tariffs.create', $data);
} }
public function show($id) public function show($id)
{ {
$data['tariff'] = Tariffs::getFull($id); $data['tariff'] = Tariffs::getArray($id);
return view('Admin.Shop.Tariffs.view', $data); return view('Admin.Shop.Tariffs.view', $data);
} }
public function edit($id) public function edit($id)
{ {
$data = Tariffs::init();
$data['tariff'] = Tariffs::get($id); $data['tariff'] = Tariffs::get($id);
$data['sale_channels'] = SaleChannels::getOptions();
$data['statuses'] = Tariffs::getStatuses();
$data['tariff_unities'] = TariffUnities::getOptions();
$model = new PriceListsDataTable();
$data['datatables']['price_lists'] = $model->html();
return view('Admin.Shop.Tariffs.edit', $data); return view('Admin.Shop.Tariffs.edit', $data);
} }

View File

@@ -5,8 +5,7 @@ namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Repositories\Core\User\ShopCart; use App\Repositories\Core\User\ShopCart;
use App\Repositories\Shop\Baskets; use App\Repositories\Shop\Baskets;
use App\Repositories\Shop\Deliveries; use App\Repositories\Shop\Customers;
use App\Repositories\Shop\DeliveryTypes;
use App\Repositories\Shop\Offers; use App\Repositories\Shop\Offers;
use App\Repositories\Shop\Orders; use App\Repositories\Shop\Orders;
use App\Repositories\Users; use App\Repositories\Users;

View File

@@ -69,4 +69,9 @@ class Customer extends Authenticatable
{ {
$this->notify(new ResetPassword($token)); $this->notify(new ResetPassword($token));
} }
public function getNameAttribute()
{
return $this->getAttribute('first_name').' '.$this->getAttribute('last_name');
}
} }

View File

@@ -6,19 +6,19 @@ use App\Repositories\Core\User\ShopCart;
class Baskets class Baskets
{ {
public static function addBasket($offer_id, $quantity = 1, $update = false) public static function addBasket($offerId, $quantity = 1, $update = false)
{ {
if (ShopCart::has($offer_id) && ! $quantity) { if (ShopCart::has($offerId) && ! $quantity) {
$ret = ShopCart::remove($offer_id); $ret = ShopCart::remove($offerId);
} }
$data = $quantity ? self::getBasketData($offer_id, $quantity) : false; $data = $quantity ? self::getBasketData($offerId, $quantity) : false;
return $data ? ShopCart::add($data, $update) : false; return $data ? ShopCart::add($data, $update) : false;
} }
public static function getBasketTotal($deliveryId = false, $deliveryTypeId = false) public static function getBasketTotal($deliveryId = false, $deliveryTypeId = false)
{ {
$saleChannelId = $deliveryId ? Deliveries::getField($deliveryId, 'sale_channel_id') : SaleChannels::getDefaultID(); $saleChannelId = Deliveries::getSaleChannelId($deliveryId);
return self::getBasketSummary($saleChannelId, $deliveryTypeId); return self::getBasketSummary($saleChannelId, $deliveryTypeId);
} }
@@ -36,8 +36,8 @@ class Baskets
$prices = Offers::getPrice($item->id, $item->quantity, $saleChannelId); $prices = Offers::getPrice($item->id, $item->quantity, $saleChannelId);
$weight = $offer->weight * $item->quantity; $weight = $offer->weight * $item->quantity;
$detail[] = self::getRowDetail($item, $offer, $prices, $weight); $detail[] = self::getRowDetail($item, $offer, $prices, $weight);
$total += self::getTotal($item->quantity, $prices->price); $total += $prices ? self::getTotal($item->quantity, $prices->price) : false;
$totalTaxed += self::getTotal($item->quantity, $prices->price_taxed); $totalTaxed += $prices ? self::getTotal($item->quantity, $prices->price_taxed) : false;
$totalWeight += $weight; $totalWeight += $weight;
} }
$shipping = DeliveryTypeCalculations::getPriceByDeliveryType($deliveryTypeId, $totalWeight); $shipping = DeliveryTypeCalculations::getPriceByDeliveryType($deliveryTypeId, $totalWeight);
@@ -52,6 +52,7 @@ class Baskets
'count' => ShopCart::count(), 'count' => ShopCart::count(),
'quantity' => ShopCart::getTotalQuantity(), 'quantity' => ShopCart::getTotalQuantity(),
'weight' => $totalWeight, 'weight' => $totalWeight,
'sale_channel' => SaleChannels::getArray($saleChannelId),
]; ];
return $data ?? false; return $data ?? false;
@@ -63,12 +64,12 @@ class Baskets
'offer_id' => (int) $item->id, 'offer_id' => (int) $item->id,
'name' => $offer->article->name.' ('.$offer->variation->name.')', 'name' => $offer->article->name.' ('.$offer->variation->name.')',
'quantity' => (int) $item->quantity, 'quantity' => (int) $item->quantity,
'price' => (float) $prices->price, 'price' => $prices ? (float) $prices->price : false,
'tax' => $prices->price_taxed - $prices->price, 'tax' => $prices ? $prices->price_taxed - $prices->price : false,
'price_taxed' => (float) $prices->price_taxed, 'price_taxed' => $prices ? (float) $prices->price_taxed : false,
'total' => self::getTotal($item->quantity, $prices->price), 'total' => $prices ? self::getTotal($item->quantity, $prices->price) : false,
'total_tax' => self::getTotal($item->quantity, $prices->price_taxed - $prices->price), 'total_tax' => $prices ? self::getTotal($item->quantity, $prices->price_taxed - $prices->price) : false,
'total_taxed' => self::getTotal($item->quantity, $prices->price_taxed), 'total_taxed' => $prices ? self::getTotal($item->quantity, $prices->price_taxed) : false,
'weight' => $weight, 'weight' => $weight,
]; ];
} }
@@ -110,6 +111,7 @@ class Baskets
'latin' => $offer->article->product->specie->latin ?? false, 'latin' => $offer->article->product->specie->latin ?? false,
]; ];
} }
$data['sale_channel'] = Customers::getSaleChannel();
return $data ?? false; return $data ?? false;
} }

View File

@@ -14,6 +14,18 @@ class Customers
{ {
use Basic; use Basic;
public static function getSaleChannel()
{
return SaleChannels::getDefault();
}
public static function getDeliveries()
{
$customer = self::getAuth();
return $customer ? $customer->deliveries : Deliveries::getDefault();
}
public static function getOptions() public static function getOptions()
{ {
return Customer::pluck('last_name', 'id'); return Customer::pluck('last_name', 'id');
@@ -23,13 +35,13 @@ class Customers
{ {
$id = $id ? $id : self::getId(); $id = $id ? $id : self::getId();
$datatableOrders = new CustomerOrdersDataTable(); $datatableOrders = new CustomerOrdersDataTable();
$data = [
return [
'customer' => self::get($id, ['addresses', 'deliveries'])->toArray(), 'customer' => self::get($id, ['addresses', 'deliveries'])->toArray(),
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(), 'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
'orders' => $datatableOrders->html(), 'orders' => $datatableOrders->html(),
]; ];
return $data;
} }
public static function getAvatar($id = false) public static function getAvatar($id = false)
@@ -48,7 +60,8 @@ class Customers
$filename = self::makeAvatarFilename($customer); $filename = self::makeAvatarFilename($customer);
$name = $customer->first_name.' '.$customer->last_name; $name = $customer->first_name.' '.$customer->last_name;
$avatar = new Avatar(); $avatar = new Avatar();
$ret = $avatar->create($name)
return $avatar->create($name)
->setBackground('#F2B90F') ->setBackground('#F2B90F')
->setForeground('#335012') ->setForeground('#335012')
->setBorder(1, '#28a745') ->setBorder(1, '#28a745')
@@ -56,8 +69,6 @@ class Customers
->setDimension(36) ->setDimension(36)
->setFontSize(16) ->setFontSize(16)
->save($filename); ->save($filename);
return $ret;
} }
public static function makeAvatarFilename($customer) public static function makeAvatarFilename($customer)
@@ -93,7 +104,7 @@ class Customers
{ {
$user = $id ? self::get($id) : self::getAuth(); $user = $id ? self::get($id) : self::getAuth();
return $user ? $user->first_name.' '.$user->last_name : ''; return $user ? $user->name : '';
} }
public static function getAuth() public static function getAuth()
@@ -162,7 +173,7 @@ class Customers
public static function create($data) public static function create($data)
{ {
$user = Customer::create([ return Customer::create([
'uuid' => Str::uuid(), 'uuid' => Str::uuid(),
'active' => true, 'active' => true,
'first_name' => $data['first_name'], 'first_name' => $data['first_name'],
@@ -177,8 +188,6 @@ class Customers
'email' => $data['email'], 'email' => $data['email'],
'password' => bcrypt($data['password']), 'password' => bcrypt($data['password']),
]); ]);
return $user;
} }
public static function getStorage($filename = false) public static function getStorage($filename = false)

View File

@@ -9,6 +9,16 @@ class Deliveries
{ {
use Basic; use Basic;
public static function getSaleChannelId($deliveryId)
{
return $deliveryId ? Deliveries::getField($deliveryId, 'sale_channel_id') : SaleChannels::getDefaultID();
}
public static function getDefault()
{
return Delivery::active()->atHouse()->first();
}
public static function getOptions() public static function getOptions()
{ {
return Delivery::orderBy('name', 'asc')->pluck('name', 'id')->toArray(); return Delivery::orderBy('name', 'asc')->pluck('name', 'id')->toArray();

View File

@@ -3,9 +3,12 @@
namespace App\Repositories\Shop; namespace App\Repositories\Shop;
use App\Models\Shop\Homepage; use App\Models\Shop\Homepage;
use App\Traits\Model\Basic;
class Homepages class Homepages
{ {
use Basic;
public static function getLast() public static function getLast()
{ {
$model = Homepage::latest('id')->first(); $model = Homepage::latest('id')->first();
@@ -28,34 +31,8 @@ class Homepages
return self::get(3)->text ?? ''; return self::get(3)->text ?? '';
} }
public static function get($id) public static function getModel()
{ {
return Homepage::find($id); return Homepage::query();
}
public static function store($data)
{
$item = ($data['id'] ?? false) ? self::update($data) : self::create($data);
return $item->id;
}
public static function create($data)
{
return Homepage::create($data);
}
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$item = self::get($id);
$item->update($data);
return $item;
}
public static function destroy($id)
{
return Homepage::destroy($id);
} }
} }

View File

@@ -28,6 +28,7 @@ class InvoicePayments
'CB', 'CB',
'CHEQUE', 'CHEQUE',
'VIREMENT', 'VIREMENT',
'PRELEVEMENT',
]; ];
} }

View File

@@ -3,6 +3,7 @@
namespace App\Repositories\Shop; namespace App\Repositories\Shop;
use App\Models\Shop\Offer; use App\Models\Shop\Offer;
use App\Models\Shop\PriceList;
use App\Traits\Model\Basic; use App\Traits\Model\Basic;
class Offers class Offers
@@ -36,7 +37,7 @@ class Offers
return Offer::with([ return Offer::with([
'variation', 'variation',
'article.article_nature', 'article.article_nature',
'article.product.Specie', 'article.product',
'article.image', 'article.image',
'price_lists.price_list_values', 'price_lists.price_list_values',
])->withPriceListsBySaleChannel($saleChannelId)->byIds($ids)->get(); ])->withPriceListsBySaleChannel($saleChannelId)->byIds($ids)->get();
@@ -67,8 +68,9 @@ class Offers
{ {
$saleChannelId = $saleChannelId ? $saleChannelId : SaleChannels::getDefaultID(); $saleChannelId = $saleChannelId ? $saleChannelId : SaleChannels::getDefaultID();
$offer = Offer::withPriceBySaleChannelByQuantity($saleChannelId, $quantity)->find($id); $offer = Offer::withPriceBySaleChannelByQuantity($saleChannelId, $quantity)->find($id);
$priceList = $offer->price_lists->first();
return $offer->price_lists->first()->price_list_values->first(); return $priceList ? $priceList->price_list_values->first() : false;
} }
public static function getOffersByArticles($article_ids, $saleChannelId = false) public static function getOffersByArticles($article_ids, $saleChannelId = false)

View File

@@ -3,9 +3,12 @@
namespace App\Repositories\Shop; namespace App\Repositories\Shop;
use App\Models\Shop\OrderDetail; use App\Models\Shop\OrderDetail;
use App\Traits\Model\Basic;
class OrderDetails class OrderDetails
{ {
use Basic;
public static function saveBasket($order_id, $data) public static function saveBasket($order_id, $data)
{ {
foreach ($data as $item) { foreach ($data as $item) {
@@ -16,32 +19,8 @@ class OrderDetails
return true; return true;
} }
public static function get($id, $relations = false) public static function getModel()
{ {
return $relations ? OrderDetail::with($relations)->findOrFail($id) : OrderDetail::findOrFail($id); return OrderDetail::query();
}
public static function store($data)
{
return ($data['id'] ?? false) ? self::update($data) : self::create($data);
}
public static function create($data)
{
return OrderDetail::create($data);
}
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$item = self::get($id);
$item->update($data);
return $item;
}
public static function delete($id)
{
return OrderDetail::destroy($id);
} }
} }

View File

@@ -3,9 +3,12 @@
namespace App\Repositories\Shop; namespace App\Repositories\Shop;
use App\Models\Shop\Package; use App\Models\Shop\Package;
use App\Traits\Model\Basic;
class Packages class Packages
{ {
use Basic;
public static function getOptions() public static function getOptions()
{ {
return Package::orderBy('value', 'asc')->pluck('value', 'id')->toArray(); return Package::orderBy('value', 'asc')->pluck('value', 'id')->toArray();
@@ -21,35 +24,8 @@ class Packages
return self::get($id)->value; return self::get($id)->value;
} }
public static function get($id) public static function getModel()
{ {
return Package::find($id); return Package::query();
}
public static function store($data)
{
$id = isset($data['id']) ? $data['id'] : false;
$item = $id ? self::update($data) : self::create($data);
return $item->id;
}
public static function create($data)
{
return Package::create($data);
}
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$item = self::get($id);
$item->update($data);
return $item;
}
public static function destroy($id)
{
return Package::destroy($id);
} }
} }

View File

@@ -4,9 +4,12 @@ namespace App\Repositories\Shop;
use App\Models\Shop\Offer; use App\Models\Shop\Offer;
use App\Models\Shop\PriceListValue; use App\Models\Shop\PriceListValue;
use App\Traits\Model\Basic;
class PriceListValues class PriceListValues
{ {
use Basic;
public static function getPriceByOffer($offer_id, $quantity = 1, $sale_channel_id = false) public static function getPriceByOffer($offer_id, $quantity = 1, $sale_channel_id = false)
{ {
$prices = self::getPricesByOffer($offer_id, $sale_channel_id); $prices = self::getPricesByOffer($offer_id, $sale_channel_id);
@@ -31,16 +34,6 @@ class PriceListValues
return PriceListValue::byPriceList($id)->get(); return PriceListValue::byPriceList($id)->get();
} }
public static function getAll()
{
return PriceListValue::orderBy('name', 'asc')->get();
}
public static function get($id)
{
return PriceListValue::find($id);
}
public static function storePrices($price_list_id, $values) public static function storePrices($price_list_id, $values)
{ {
foreach ($values as $value) { foreach ($values as $value) {
@@ -51,30 +44,8 @@ class PriceListValues
} }
} }
public static function store($data) public static function getModel()
{ {
$id = isset($data['id']) ? $data['id'] : false; return PriceListValue::query();
$price = $id ? self::update($data) : self::create($data);
return $price;
}
public static function create($data)
{
return PriceListValue::create($data);
}
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$item = self::get($id);
$item->update($data);
return $item;
}
public static function destroy($id)
{
return PriceListValue::destroy($id);
} }
} }

View File

@@ -3,9 +3,25 @@
namespace App\Repositories\Shop; namespace App\Repositories\Shop;
use App\Models\Shop\PriceList; use App\Models\Shop\PriceList;
use App\Traits\Model\Basic;
class PriceLists class PriceLists
{ {
use Basic;
public static function init($tariffId = false)
{
return [
'sale_channels' => SaleChannels::getOptions(),
'statuses' => Tariffs::getStatuses(),
'taxes' => Taxes::getOptions(),
'price_list' => [
'tariff_id' => $tariffId,
'price_list_values' => array_fill(0, 3, ''),
],
];
}
public static function getByOfferAndSaleChannel($offer_id, $sale_channel_id) public static function getByOfferAndSaleChannel($offer_id, $sale_channel_id)
{ {
return PriceList::bySaleChannel($sale_channel_id)->byOffer($offer_id)->get(); return PriceList::bySaleChannel($sale_channel_id)->byOffer($offer_id)->get();
@@ -31,15 +47,6 @@ class PriceLists
return PriceList::byTariff($id)->get(); return PriceList::byTariff($id)->get();
} }
public static function getOptions()
{
return PriceList::pluck('name', 'id')->toArray();
}
public static function getAll()
{
return PriceList::orderBy('name', 'asc')->get();
}
public static function edit($id) public static function edit($id)
{ {
@@ -52,11 +59,6 @@ class PriceLists
return $price_list; return $price_list;
} }
public static function get($id)
{
return PriceList::find($id);
}
public static function getPrices($id) public static function getPrices($id)
{ {
return PriceList::with('price_list_values')->find($id); return PriceList::with('price_list_values')->find($id);
@@ -78,22 +80,8 @@ class PriceLists
return $price_list; return $price_list;
} }
public static function create($data) public static function getModel()
{ {
return PriceList::create($data); return PriceList::query();
}
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$item = self::get($id);
$item->update($data);
return $item;
}
public static function destroy($id)
{
return PriceList::destroy($id);
} }
} }

View File

@@ -3,9 +3,12 @@
namespace App\Repositories\Shop; namespace App\Repositories\Shop;
use App\Models\Shop\SaleChannel; use App\Models\Shop\SaleChannel;
use App\Traits\Model\Basic;
class SaleChannels class SaleChannels
{ {
use Basic;
public static function getDefaultID() public static function getDefaultID()
{ {
$default = self::getDefault(); $default = self::getDefault();
@@ -23,45 +26,8 @@ class SaleChannels
return SaleChannel::byCode($code)->first(); return SaleChannel::byCode($code)->first();
} }
public static function getOptions() public static function getModel()
{ {
return SaleChannel::orderBy('name', 'asc')->pluck('name', 'id')->toArray(); return SaleChannel::query();
}
public static function getAll()
{
return SaleChannel::orderBy('name', 'asc')->get();
}
public static function get($id)
{
return SaleChannel::findOrFail($id);
}
public static function store($data)
{
$id = isset($data['id']) ? $data['id'] : false;
$item = $id ? self::update($data) : self::create($data);
return $item->id;
}
public static function create($data)
{
return SaleChannel::create($data);
}
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$item = self::get($id);
$item->update($data);
return $item;
}
public static function destroy($id)
{
return SaleChannel::destroy($id);
} }
} }

View File

@@ -2,10 +2,27 @@
namespace App\Repositories\Shop; namespace App\Repositories\Shop;
use App\Datatables\Admin\Shop\PriceListsDataTable;
use App\Models\Shop\Tariff; use App\Models\Shop\Tariff;
use App\Traits\Model\Basic;
class Tariffs class Tariffs
{ {
use Basic;
public static function init()
{
$model = new PriceListsDataTable();
return [
'sale_channels' => SaleChannels::getOptions(),
'statuses' => Tariffs::getStatuses(),
'tariff_unities' => TariffUnities::getOptions(),
'datatables' => [
'price_lists' => $model->html(),
],
];
}
public static function autocomplete($str) public static function autocomplete($str)
{ {
$data = Tariff::byAutocomplete($str)->orderBy('name')->limit(30)->get()->pluck('name', 'id'); $data = Tariff::byAutocomplete($str)->orderBy('name')->limit(30)->get()->pluck('name', 'id');
@@ -27,11 +44,6 @@ class Tariffs
return Tariff::with(['price_lists.price_list_values', 'price_lists.sale_channel'])->find($id); return Tariff::with(['price_lists.price_list_values', 'price_lists.sale_channel'])->find($id);
} }
public static function getOptions()
{
return Tariff::orderBy('name', 'asc')->get()->pluck('name', 'id')->toArray();
}
public static function getStatus($status_id) public static function getStatus($status_id)
{ {
return self::getStatuses()[$status_id]; return self::getStatuses()[$status_id];
@@ -42,40 +54,8 @@ class Tariffs
return ['Actif', 'Suspendu', 'Invisible', 'Obsolete']; return ['Actif', 'Suspendu', 'Invisible', 'Obsolete'];
} }
public static function getAll() public static function getModel()
{ {
return Tariff::orderBy('name', 'asc')->get(); return Tariff::query();
}
public static function get($id)
{
return Tariff::find($id);
}
public static function store($data)
{
$id = isset($data['id']) ? $data['id'] : false;
$item = $id ? self::update($data, $id) : self::create($data);
return $item->id;
}
public static function create($data)
{
return Tariff::create($data);
}
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$item = self::get($id);
$item->update($data);
return $item;
}
public static function destroy($id)
{
return Tariff::destroy($id);
} }
} }

View File

@@ -5,7 +5,6 @@
'classTitle' => 'mb-0', 'classTitle' => 'mb-0',
'outline' => false, 'outline' => false,
]) ])
@include('components.form.select', [ @include('components.form.select', [
'name' => 'offer_id', 'name' => 'offer_id',
'id_name' => $model . '-offer_id', 'id_name' => $model . '-offer_id',
@@ -19,7 +18,9 @@
'name' => 'quantity', 'name' => 'quantity',
'class' => 'quantity', 'class' => 'quantity',
'id_name' => $model . '-quantity', 'id_name' => $model . '-quantity',
'value' => 1, 'value' => (int) $data[0]['prices'][0]['quantity'],
'min' => $data[0]['prices'][0]['quantity'],
'step' => 1,
]) ])
</div> </div>
<div class="col-7 text-right"> <div class="col-7 text-right">
@@ -39,7 +40,6 @@
]) ])
</div> </div>
</div> </div>
@endcomponent @endcomponent
@push('js') @push('js')

View File

@@ -12,7 +12,8 @@
</div> </div>
<div class="col-8"> <div class="col-8">
Livraison à domicile ...<br> Livraison à domicile ...<br>
Commande en ligne et livraison par voie postale. Attention certains produits ne sont pas disponibles en livraison. Commande en ligne et livraison par voie postale. Attention certains produits ne sont pas disponibles
en livraison.
Les sachets disponibles en lignes sont disponibles à la livraison et uniquement quelques plants. Les sachets disponibles en lignes sont disponibles à la livraison et uniquement quelques plants.
</div> </div>
</div> </div>
@@ -73,7 +74,11 @@
} }
function updateBasket(offer_id, quantity, callback) { function updateBasket(offer_id, quantity, callback) {
var data = {offer_id: offer_id, quantity: quantity, update: true}; var data = {
offer_id: offer_id,
quantity: quantity,
update: true
};
$.post("{{ route('Shop.Basket.addBasket') }}", data, callback); $.post("{{ route('Shop.Basket.addBasket') }}", data, callback);
} }

View File

@@ -4,7 +4,7 @@
</div> </div>
<div class="col-6 text-right font-weight-bold"> <div class="col-6 text-right font-weight-bold">
<span id="basket_sale_channel"> <span id="basket_sale_channel">
{{ $sale_channel['name'] ?? null }} {{ $basket['sale_channel']['name'] ?? null }}
</span> </span>
</div> </div>
</div> </div>
@@ -18,7 +18,7 @@
</span> </span>
</div> </div>
</div> </div>
@if ($basket['shipping']) @if ($basket['shipping'] ?? false)
<div class="row mb-3"> <div class="row mb-3">
<div class="col-6"> <div class="col-6">
LIVRAISON LIVRAISON

View File

@@ -54,15 +54,6 @@
$('#personal_data').collapse('show'); $('#personal_data').collapse('show');
}); });
$('#delivery_mode .delivery_mode').click(function() {
var test = $(this).hasClass('at_house');
if ($(this).hasClass('at_house')) {
$('#delivery_addresses').closest('.card').removeClass('d-none');
} else {
$('#delivery_addresses').closest('.card').addClass('d-none');
}
});
function refreshBasketTotal(deliveryId, deliveryTypeId) { function refreshBasketTotal(deliveryId, deliveryTypeId) {
options = deliveryId + '/' + deliveryTypeId; options = deliveryId + '/' + deliveryTypeId;
$.get("{{ Route('Shop.Basket.getBasketTotal') }}/" + options, function(data) { $.get("{{ Route('Shop.Basket.getBasketTotal') }}/" + options, function(data) {

View File

@@ -3,10 +3,10 @@
<div class="row mb-3"> <div class="row mb-3">
<div class="col-1"> <div class="col-1">
@include('components.form.radios.icheck', [ @include('components.form.radios.icheck', [
'name' => 'address_id', 'name' => $prefix . '_address_id',
'val' => $address['id'], 'val' => $address['id'],
'id' => 'address_' . $address['id'], 'id' => $prefix . '_address_' . $address['id'],
'value' => count($addresses) === 1 ? $address['id'] : false, 'value' => $address['priority'] || count($addresses) === 1 ? $address['id'] : false,
]) ])
</div> </div>
<div class="col-11"> <div class="col-11">

View File

@@ -24,12 +24,21 @@ ci-contre
@push('js') @push('js')
<script> <script>
$('.delivery_mode').click(function() { function handleDeliveries() {
var deliveryTypeId = $(this).val(); $('#delivery_mode input.delivery_mode').change(function() {
var deliveryId = $('input[name=delivery_id]').val() if ($(this).hasClass('at_house')) {
$('#delivery_addresses').closest('.card').removeClass('d-none');
var deliveryTypeId = $('input[name=delivery_type_id]:checked').val()
} else {
$('#delivery_addresses').closest('.card').addClass('d-none');
}
var deliveryId = $(this).val();
console.log(deliveryId); console.log(deliveryId);
console.log(deliveryTypeId); console.log(deliveryTypeId);
refreshBasketTotal(deliveryId, deliveryTypeId) refreshBasketTotal(deliveryId, deliveryTypeId);
}); });
}
handleDeliveries();
</script> </script>
@endpush @endpush

View File

@@ -2,6 +2,7 @@
<x-layout.collapse id="invoice_addresses" title="Adresse de facturation" class="rounded-lg mb-3" uncollapsed=true> <x-layout.collapse id="invoice_addresses" title="Adresse de facturation" class="rounded-lg mb-3" uncollapsed=true>
@include('Shop.Orders.partials.addresses', [ @include('Shop.Orders.partials.addresses', [
'addresses' => $customer['invoice_addresses'] ?? false, 'addresses' => $customer['invoice_addresses'] ?? false,
'prefix' => 'invoice',
]) ])
</x-layout.collapse> </x-layout.collapse>
@@ -13,6 +14,7 @@
uncollapsed=true> uncollapsed=true>
@include('Shop.Orders.partials.addresses', [ @include('Shop.Orders.partials.addresses', [
'addresses' => $customer['delivery_addresses'] ?? false, 'addresses' => $customer['delivery_addresses'] ?? false,
'prefix' => 'delivery',
]) ])
@include('Shop.Orders.partials.shipping') @include('Shop.Orders.partials.shipping')
</x-layout.collapse> </x-layout.collapse>

View File

@@ -30,12 +30,15 @@
@push('js') @push('js')
<script> <script>
$('.delivery_type').click(function() { function handleDeliveryTypes() {
var deliveryId = $(this).val(); $('input.delivery_type').change(function() {
var deliveryTypeId = $('input[name=delivery_type_id]').val() var deliveryTypeId = $(this).val();
var deliveryId = $('input[name=delivery_id]').val()
console.log(deliveryId); console.log(deliveryId);
console.log(deliveryTypeId); console.log(deliveryTypeId);
refreshBasketTotal(deliveryId, deliveryTypeId); refreshBasketTotal(deliveryId, deliveryTypeId);
}); });
}
handleDeliveryTypes();
</script> </script>
@endpush @endpush

View File

@@ -1,4 +1,4 @@
<div class="icheck-{{ $color ?? 'success' }} {{ $class ?? '' }}"> <div class="icheck-{{ $color ?? 'success' }} {{ $class ?? '' }}">
@include('components.form.radio') @include('components.form.radio')
<label class="control-label light" for="{{ $id_name ?? $id ?? $name }}">{{ $label ?? '' }}</label> <label class="control-label light" for="{{ $id_name ?? ($id ?? $name) }}">{{ $label ?? '' }}</label>
</div> </div>