add shipping to order, methods to calculate, little refactoring
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Shop;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\Core\User\ShopCart;
|
||||
use App\Repositories\Shop\Baskets;
|
||||
use App\Repositories\Shop\Deliveries;
|
||||
use App\Repositories\Shop\DeliveryTypes;
|
||||
use App\Repositories\Shop\Offers;
|
||||
use App\Repositories\Shop\Orders;
|
||||
@@ -63,15 +64,9 @@ class BasketController extends Controller
|
||||
return ShopCart::count();
|
||||
}
|
||||
|
||||
public function getBasketTotal($deliveryTypeId = false)
|
||||
public function getBasketTotal($deliveryId = false, $deliveryTypeId = false)
|
||||
{
|
||||
$data = [
|
||||
'basket' => ShopCart::getSummary(),
|
||||
];
|
||||
|
||||
$weight = Baskets::getWeight();
|
||||
|
||||
$data['basket']['shipping'] = DeliveryTypes::getPrice($deliveryTypeId, $weight);
|
||||
$data['basket'] = Baskets::getBasketTotal($deliveryId, $deliveryTypeId);
|
||||
|
||||
return view('Shop.Baskets.partials.basketTotal', $data);
|
||||
}
|
||||
|
||||
@@ -40,15 +40,18 @@ class OrderController extends Controller
|
||||
{
|
||||
if (ShopCart::count()) {
|
||||
$customer = Customers::getWithAddresses();
|
||||
|
||||
|
||||
$data = [
|
||||
'customer' => $customer ? $customer->toArray() : false,
|
||||
'basket' => ShopCart::getSummary(),
|
||||
'basket' => Baskets::getBasketTotal(),
|
||||
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
|
||||
'sale_channel' => SaleChannels::getDefault()->toArray(),
|
||||
'delivery_types' => DeliveryTypes::getAll(),
|
||||
'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()),
|
||||
];
|
||||
|
||||
// dump($data);
|
||||
// exit;
|
||||
|
||||
return view('Shop.Orders.order', $data);
|
||||
} else {
|
||||
return redirect()->route('home');
|
||||
|
||||
Reference in New Issue
Block a user