diff --git a/app/Http/Controllers/Shop/OrderController.php b/app/Http/Controllers/Shop/OrderController.php index a041c602..4b79fe3e 100644 --- a/app/Http/Controllers/Shop/OrderController.php +++ b/app/Http/Controllers/Shop/OrderController.php @@ -40,12 +40,13 @@ class OrderController extends Controller { if (ShopCart::count()) { $customer = Customers::getWithAddresses(); + $deliveries = Deliveries::getByCustomer(); $data = [ 'customer' => $customer ? $customer->toArray() : false, 'basket' => Baskets::getBasketTotal(), // 'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(), - 'deliveries' => Deliveries::getByCustomer()->toArray(), + 'deliveries' => $deliveries ? $deliveries->toArray() : [], 'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()), ]; diff --git a/app/Repositories/Shop/Invoices.php b/app/Repositories/Shop/Invoices.php index 71f73078..0d09c129 100644 --- a/app/Repositories/Shop/Invoices.php +++ b/app/Repositories/Shop/Invoices.php @@ -47,6 +47,7 @@ class Invoices public static function saveInvoice($orderId, $data) { $data['order_id'] = $orderId; + $data['date_invoice'] = date('Y-m-d'); return self::store($data); } diff --git a/app/Repositories/Shop/Orders.php b/app/Repositories/Shop/Orders.php index 5d45d36e..50409c4e 100644 --- a/app/Repositories/Shop/Orders.php +++ b/app/Repositories/Shop/Orders.php @@ -36,17 +36,26 @@ class Orders public static function saveOrder($data) { $basket = $data['basket']; - unset($data['basket']); + $invoice = $data['invoice']; + unset($data['basket'], $data['invoice']); + $data += self::getSummaryOfBasket($basket); $order = self::store($data); - $detail = OrderDetails::saveBasket($order->id, $basket['detail']); - $data['ref'] = $order->ref; - unset($data['comment']); - unset($data['agree']); - unset($data['delivery_address_id']); - unset($data['detail']); - unset($data['sale_channel_id']); + $detail = $order ? OrderDetails::saveBasket($order->id, $basket['detail']) : false; + unset($data['comment'], $data['agree'], $data['delivery_address_id'], $data['sale_channel_id']); + $invoice = $detail ? Invoices::saveInvoice($order->id, $data + $invoice) : false; - return ($order && $detail) ? Invoices::saveInvoice($order->id, $data) : false; + return $invoice ? $order : false; + } + + public static function getSummaryOfBasket($basket) + { + return [ + 'total' => $basket['total'], + 'taxes' => $basket['taxes'], + 'total_taxed' => $basket['total_taxed'], + 'shipping' => $basket['shipping'], + 'total_shipped' => $basket['total_shipped'], + ]; } public static function edit($id) diff --git a/app/Repositories/Shop/Paybox.php b/app/Repositories/Shop/Paybox.php index e93066c5..b92887ad 100644 --- a/app/Repositories/Shop/Paybox.php +++ b/app/Repositories/Shop/Paybox.php @@ -3,9 +3,9 @@ namespace App\Repositories\Shop; use App; -use Devpark\PayboxGateway\Requests\AuthorizationWithCapture; -use Devpark\PayboxGateway\Requests\Capture; -use Devpark\PayboxGateway\Responses\Verify; +use Bnb\PayboxGateway\Requests\AuthorizationWithCapture; +use Bnb\PayboxGateway\Requests\Capture; +use Bnb\PayboxGateway\Responses\Verify; class Paybox { diff --git a/resources/views/Shop/Orders/partials/addresses.blade.php b/resources/views/Shop/Orders/partials/addresses.blade.php index 59347069..83fc2b18 100644 --- a/resources/views/Shop/Orders/partials/addresses.blade.php +++ b/resources/views/Shop/Orders/partials/addresses.blade.php @@ -3,7 +3,7 @@