Issue #191 fixed

This commit is contained in:
jitendra 2019-02-04 15:18:24 +05:30
parent 639d4b1581
commit 49ddcd0256
3 changed files with 24 additions and 4 deletions

View File

@ -20,8 +20,17 @@ class OrderDataGrid extends DataGrid
public function prepareQueryBuilder()
{
$queryBuilder = DB::table('orders')
->select('id', 'base_sub_total', 'base_grand_total', 'created_at', 'channel_name', 'status')
->addSelect(DB::raw('CONCAT(customer_first_name, " ", customer_last_name) as full_name'));
->leftJoin('order_address as order_address_shipping', function($leftJoin) {
$leftJoin->on('order_address_shipping.order_id', '=', 'orders.id')
->where('order_address_shipping.address_type', 'shipping');
})
->leftJoin('order_address as order_address_billing', function($leftJoin) {
$leftJoin->on('order_address_billing.order_id', '=', 'orders.id')
->where('order_address_billing.address_type', 'billing');
})
->addSelect('orders.id', 'base_sub_total', 'base_grand_total', 'orders.created_at', 'channel_name', 'status')
->addSelect(DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name) as billed_to'))
->addSelect(DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name) as shipped_to'));
$this->addFilter('full_name', DB::raw('CONCAT(customer_first_name, " ", customer_last_name)'));
@ -96,12 +105,20 @@ class OrderDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'full_name',
'index' => 'billed_to',
'label' => trans('admin::app.datagrid.billed-to'),
'type' => 'string',
'searchable' => true,
'sortable' => true,
]);
$this->addColumn([
'index' => 'shipped_to',
'label' => trans('admin::app.datagrid.shipped-to'),
'type' => 'string',
'searchable' => true,
'sortable' => true,
]);
}
public function prepareActions() {

View File

@ -130,6 +130,7 @@ return [
'order-date' => 'Order Date',
'channel-name' => 'Channel Name',
'billed-to' => 'Billed To',
'shipped-to' => 'Shipped To',
'order-id' => 'Order Id',
'invoice-date' => 'Invoice Date',
'total-qty' => 'Total Qty',

View File

@ -822,6 +822,7 @@ class Cart {
}
}
}
return true;
}
}
@ -833,7 +834,8 @@ class Cart {
*/
public function calculateItemsTax()
{
$cart = $this->getCart();
if (! $cart = $this->getCart())
return false;
if (! $shippingAddress = $cart->shipping_address)
return;