conflict resolve
This commit is contained in:
commit
ec03cbd63e
|
|
@ -67,4 +67,21 @@ class OrderController extends Controller
|
|||
|
||||
return view($this->_config['view'], compact('order'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel action for the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function cancel($id)
|
||||
{
|
||||
if($this->order->cancel($id)) {
|
||||
session()->flash('success', trans('Order canceled successfully.'));
|
||||
} else {
|
||||
session()->flash('error', trans('Order can not be canceled.'));
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ Route::group(['middleware' => ['web']], function () {
|
|||
'view' => 'admin::customers.review.index'
|
||||
])->name('admin.customer.review.index');
|
||||
|
||||
Route::get('reviews/edit/{id}', 'Webkul\Product\Http\Controllers\ReviewController@edit')->defaults('_config',[
|
||||
Route::get('reviews/edit/{id}', 'Webkul\Product\Http\Controllers\ReviewController@edit')->defaults('_config',[
|
||||
'view' => 'admin::customers.review.edit'
|
||||
])->name('admin.customer.review.edit');
|
||||
|
||||
|
|
@ -88,6 +88,10 @@ Route::group(['middleware' => ['web']], function () {
|
|||
'view' => 'admin::sales.orders.view'
|
||||
])->name('admin.sales.orders.view');
|
||||
|
||||
Route::get('/orders/cancel/{order_id}', 'Webkul\Admin\Http\Controllers\Sales\OrderController@cancel')->defaults('_config', [
|
||||
'view' => 'admin::sales.orders.cancel'
|
||||
])->name('admin.sales.orders.cancel');
|
||||
|
||||
|
||||
// Sales Invoices Routes
|
||||
Route::get('/invoices', 'Webkul\Admin\Http\Controllers\Sales\InvoiceController@index')->defaults('_config', [
|
||||
|
|
|
|||
|
|
@ -586,6 +586,17 @@ body {
|
|||
}
|
||||
}
|
||||
|
||||
.table {
|
||||
.qty-row {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sale-summary {
|
||||
margin-top: 2%;
|
||||
height: 130px;
|
||||
|
|
@ -594,11 +605,18 @@ body {
|
|||
tr {
|
||||
|
||||
td {
|
||||
padding: 3px 8px;
|
||||
padding: 5px 8px;
|
||||
}
|
||||
|
||||
&.bold {
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
&.border {
|
||||
td {
|
||||
border-bottom: 1px solid $border-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ return [
|
|||
'orders' => [
|
||||
'title' => 'Orders',
|
||||
'view-title' => 'Order #:order_id',
|
||||
'cancel-btn-title' => 'Cancel',
|
||||
'shipment-btn-title' => 'Ship',
|
||||
'invoice-btn-title' => 'Invoice',
|
||||
'info' => 'Information',
|
||||
|
|
@ -102,6 +103,9 @@ return [
|
|||
'product-name' => 'Product Name',
|
||||
'qty' => 'Qty',
|
||||
'item-status' => 'Item Status',
|
||||
'item-invoice' => 'Invoiced (:qty_invoiced)',
|
||||
'item-shipped' => 'shipped (:qty_shipped)',
|
||||
'item-canceled' => 'Canceled (:qty_canceled)',
|
||||
'price' => 'Price',
|
||||
'total' => 'Total',
|
||||
'subtotal' => 'Subtotal',
|
||||
|
|
@ -110,7 +114,11 @@ return [
|
|||
'tax-percent' => 'Tax Percent',
|
||||
'tax-amount' => 'Tax Amount',
|
||||
'discount-amount' => 'Discount Amount',
|
||||
'grand-total' => 'Grand Total'
|
||||
'grand-total' => 'Grand Total',
|
||||
'total-paid' => 'Total Paid',
|
||||
'total-refunded' => 'Total Refunded',
|
||||
'total-due' => 'Total Due',
|
||||
'cancel-confirm-msg' => 'Are you sure you want to cancel this order ?'
|
||||
],
|
||||
'invoices' => [
|
||||
'id' => 'Id',
|
||||
|
|
|
|||
|
|
@ -2,10 +2,24 @@
|
|||
|
||||
<?php $selectedOption = old($attribute->code) ?: $product[$attribute->code] ?>
|
||||
|
||||
@foreach($attribute->options as $option)
|
||||
<option value="{{ $option->id }}" {{ $option->id == $selectedOption ? 'selected' : ''}}>
|
||||
{{ $option->admin_name }}
|
||||
</option>
|
||||
@endforeach
|
||||
@if($attribute->code != 'tax_category_id')
|
||||
|
||||
@foreach($attribute->options as $option)
|
||||
<option value="{{ $option->id }}" {{ $option->id == $selectedOption ? 'selected' : ''}}>
|
||||
{{ $option->admin_name }}
|
||||
</option>
|
||||
@endforeach
|
||||
|
||||
@else
|
||||
|
||||
<option value=""></option>
|
||||
|
||||
@foreach(app('Webkul\Tax\Repositories\TaxCategoryRepository')->all() as $taxCategory)
|
||||
<option value="{{ $taxCategory->id }}" {{ $taxCategory->id == $selectedOption ? 'selected' : ''}}>
|
||||
{{ $taxCategory->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
|
||||
@endif
|
||||
|
||||
</select>
|
||||
|
|
@ -15,6 +15,12 @@
|
|||
</div>
|
||||
|
||||
<div class="page-action">
|
||||
@if($order->canCancel())
|
||||
<a href="{{ route('admin.sales.orders.cancel', $order->id) }}" class="btn btn-lg btn-primary" v-alert:message="'{{ __('admin::app.sales.orders.cancel-confirm-msg') }}'">
|
||||
{{ __('admin::app.sales.orders.cancel-btn-title') }}
|
||||
</a>
|
||||
@endif
|
||||
|
||||
@if($order->canInvoice())
|
||||
<a href="{{ route('admin.sales.invoices.create', $order->id) }}" class="btn btn-lg btn-primary">
|
||||
{{ __('admin::app.sales.orders.invoice-btn-title') }}
|
||||
|
|
@ -229,7 +235,19 @@
|
|||
<td>{{ $item->name }}</td>
|
||||
<td>{{ core()->formatBasePrice($item->base_price) }}</td>
|
||||
<td>{{ $item->qty_ordered }}</td>
|
||||
<td>Packed (2)</td>
|
||||
<td>
|
||||
<span class="qty-row">
|
||||
{{ $item->qty_invoiced ? __('admin::app.sales.orders.item-invoice', ['qty_invoiced' => $item->qty_invoiced]) : '' }}
|
||||
</span>
|
||||
|
||||
<span class="qty-row">
|
||||
{{ $item->qty_shipped ? __('admin::app.sales.orders.item-shipped', ['qty_shipped' => $item->qty_shipped]) : '' }}
|
||||
</span>
|
||||
|
||||
<span class="qty-row">
|
||||
{{ $item->qty_canceled ? __('admin::app.sales.orders.item-canceled', ['qty_canceled' => $item->qty_canceled]) : '' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ core()->formatBasePrice($item->base_total) }}</td>
|
||||
<td>{{ $item->tax_percent }}%</td>
|
||||
<td>{{ core()->formatBasePrice($item->base_tax_amount) }}</td>
|
||||
|
|
@ -252,7 +270,7 @@
|
|||
<td>{{ core()->formatBasePrice($order->base_shipping_amount) }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<tr class="border">
|
||||
<td>{{ __('admin::app.sales.orders.tax') }}</td>
|
||||
<td>-</td>
|
||||
<td>{{ core()->formatBasePrice($order->base_tax_amount) }}</td>
|
||||
|
|
@ -263,6 +281,24 @@
|
|||
<td>-</td>
|
||||
<td>{{ core()->formatBasePrice($order->base_grand_total) }}</td>
|
||||
</tr>
|
||||
|
||||
<tr class="bold">
|
||||
<td>{{ __('admin::app.sales.orders.total-paid') }}</td>
|
||||
<td>-</td>
|
||||
<td>{{ core()->formatBasePrice($order->base_grand_total_invoiced) }}</td>
|
||||
</tr>
|
||||
|
||||
<tr class="bold">
|
||||
<td>{{ __('admin::app.sales.orders.total-refunded') }}</td>
|
||||
<td>-</td>
|
||||
<td>{{ core()->formatBasePrice($order->base_grand_total_refunded) }}</td>
|
||||
</tr>
|
||||
|
||||
<tr class="bold">
|
||||
<td>{{ __('admin::app.sales.orders.total-due') }}</td>
|
||||
<td>-</td>
|
||||
<td>{{ core()->formatBasePrice($order->base_total_due) }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@
|
|||
<div class="control-group" :class="[errors.has('taxrates') ? 'has-error' : '']">
|
||||
<label for="taxrates" class="required">{{ __('admin::app.configuration.tax-categories.select-taxrates') }}</label>
|
||||
|
||||
@inject('taxRates', 'Webkul\Core\Repositories\TaxRatesRepository')
|
||||
@inject('taxRates', 'Webkul\Tax\Repositories\TaxRateRepository')
|
||||
|
||||
<select multiple="multiple" class="control" id="taxrates" name="taxrates[]" v-validate="'required'">
|
||||
@foreach($taxRates->all() as $taxRate)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class AttributeTableSeeder extends Seeder
|
|||
'en' => [
|
||||
'name' => 'Tax Category'
|
||||
],
|
||||
'type' => 'text',
|
||||
'type' => 'select',
|
||||
'position' => 4,
|
||||
'is_unique' => 0,
|
||||
'is_required' => 0,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Attribute extends TranslatableModel
|
|||
{
|
||||
public $translatedAttributes = ['name'];
|
||||
|
||||
protected $fillable = ['code', 'admin_name', 'type', 'position', 'is_required', 'is_unique', 'value_per_locale', 'value_per_channel', 'is_filterable', 'is_configurable', 'is_visible_on_front'];
|
||||
protected $fillable = ['code', 'admin_name', 'type', 'position', 'is_required', 'is_unique', 'value_per_locale', 'value_per_channel', 'is_filterable', 'is_configurable', 'is_visible_on_front', 'is_user_defined'];
|
||||
|
||||
protected $with = ['options'];
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use Webkul\Checkout\Repositories\CartItemRepository;
|
|||
use Webkul\Checkout\Repositories\CartAddressRepository;
|
||||
use Webkul\Customer\Repositories\CustomerRepository;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
use Webkul\Tax\Repositories\TaxCategoryRepository;
|
||||
use Webkul\Checkout\Models\CartPayment;
|
||||
|
||||
/**
|
||||
|
|
@ -54,6 +55,13 @@ class Cart {
|
|||
*/
|
||||
protected $product;
|
||||
|
||||
/**
|
||||
* TaxCategoryRepository model
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $taxCategory;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
|
|
@ -62,6 +70,7 @@ class Cart {
|
|||
* @param Webkul\Checkout\Repositories\CartAddressRepository $cartAddress
|
||||
* @param Webkul\Customer\Repositories\CustomerRepository $customer
|
||||
* @param Webkul\Product\Repositories\ProductRepository $product
|
||||
* @param Webkul\Product\Repositories\TaxCategoryRepository $taxCategory
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
|
|
@ -69,7 +78,9 @@ class Cart {
|
|||
CartItemRepository $cartItem,
|
||||
CartAddressRepository $cartAddress,
|
||||
CustomerRepository $customer,
|
||||
ProductRepository $product)
|
||||
ProductRepository $product,
|
||||
TaxCategoryRepository $taxCategory
|
||||
)
|
||||
{
|
||||
$this->customer = $customer;
|
||||
|
||||
|
|
@ -80,6 +91,8 @@ class Cart {
|
|||
$this->cartAddress = $cartAddress;
|
||||
|
||||
$this->product = $product;
|
||||
|
||||
$this->taxCategory = $taxCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -564,7 +577,11 @@ class Cart {
|
|||
$cart = null;
|
||||
|
||||
if(auth()->guard('customer')->check()) {
|
||||
$cart = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id);
|
||||
$cart = $this->cart->findOneWhere([
|
||||
'customer_id' => auth()->guard('customer')->user()->id,
|
||||
'is_active' => 1
|
||||
]);
|
||||
|
||||
} elseif(session()->has('cart')) {
|
||||
$cart = $this->cart->find(session()->get('cart')->id);
|
||||
}
|
||||
|
|
@ -659,6 +676,8 @@ class Cart {
|
|||
}
|
||||
}
|
||||
|
||||
// If customer is guest, than save shipping address's email and name in cart as customer details
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -718,20 +737,15 @@ class Cart {
|
|||
if(!$cart = $this->getCart())
|
||||
return false;
|
||||
|
||||
$this->calulateItemsTax();
|
||||
$this->calculateItemsTax();
|
||||
|
||||
$cart->grand_total = 0;
|
||||
$cart->base_grand_total = 0;
|
||||
|
||||
$cart->sub_total = 0;
|
||||
$cart->base_sub_total = 0;
|
||||
|
||||
$cart->tax_total = 0;
|
||||
$cart->base_tax_total = 0;
|
||||
$cart->grand_total = $cart->base_grand_total = 0;
|
||||
$cart->sub_total = $cart->base_sub_total = 0;
|
||||
$cart->tax_total = $cart->base_tax_total = 0;
|
||||
|
||||
foreach ($cart->items()->get() as $item) {
|
||||
$cart->grand_total = (float) $cart->grand_total + $item->total;
|
||||
$cart->base_grand_total = (float) $cart->base_grand_total + $item->base_total;
|
||||
$cart->grand_total = (float) $cart->grand_total + $item->total + $item->tax_amount;
|
||||
$cart->base_grand_total = (float) $cart->base_grand_total + $item->base_total + $item->base_tax_amount;
|
||||
|
||||
$cart->sub_total = (float) $cart->sub_total + $item->total;
|
||||
$cart->base_sub_total = (float) $cart->base_sub_total + $item->base_total;
|
||||
|
|
@ -762,12 +776,46 @@ class Cart {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function calulateItemsTax()
|
||||
public function calculateItemsTax()
|
||||
{
|
||||
$cart = $this->getCart();
|
||||
|
||||
if(!$shippingAddress = $cart->shipping_address)
|
||||
return;
|
||||
|
||||
foreach ($cart->items()->get() as $item) {
|
||||
$product = $item->product;
|
||||
$taxCategory = $this->taxCategory->find($item->product->tax_category_id);
|
||||
|
||||
if(!$taxCategory)
|
||||
continue;
|
||||
|
||||
$taxRates = $taxCategory->tax_rates()->where([
|
||||
'state' => $shippingAddress->state,
|
||||
'country' => $shippingAddress->country,
|
||||
])->orderBy('tax_rate', 'desc')->get();
|
||||
|
||||
foreach($taxRates as $rate) {
|
||||
$haveTaxRate = false;
|
||||
|
||||
if(!$rate->is_zip) {
|
||||
if($rate->zip_code == '*' || $rate->zip_code == $shippingAddress->postcode) {
|
||||
$haveTaxRate = true;
|
||||
}
|
||||
} else {
|
||||
if($shippingAddress->postcode >= $rate->zip_code && $shippingAddress->postcode <= $rate->zip_code) {
|
||||
$haveTaxRate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if($haveTaxRate) {
|
||||
$item->tax_percent = $rate->tax_rate;
|
||||
$item->tax_amount = ($item->total * $rate->tax_rate) / 100;
|
||||
$item->base_tax_amount = ($item->base_total * $rate->tax_rate) / 100;
|
||||
|
||||
$item->save();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -848,7 +896,7 @@ class Cart {
|
|||
'customer_email' => $data['customer_email'],
|
||||
'customer_first_name' => $data['customer_first_name'],
|
||||
'customer_last_name' => $data['customer_last_name'],
|
||||
'customer' => auth()->guard('customer')->check() ? auth()->guard('customer')->user : null,
|
||||
'customer' => auth()->guard('customer')->check() ? auth()->guard('customer')->user() : null,
|
||||
|
||||
'shipping_method' => $data['selected_shipping_rate']['method'],
|
||||
'shipping_title' => $data['selected_shipping_rate']['carrier_title'] . ' - ' . $data['selected_shipping_rate']['method_title'],
|
||||
|
|
|
|||
|
|
@ -46,6 +46,42 @@ abstract class Repository extends BaseRepository {
|
|||
return $model->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find data by id
|
||||
*
|
||||
* @param $id
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function find($id, $columns = ['*'])
|
||||
{
|
||||
$this->applyCriteria();
|
||||
$this->applyScope();
|
||||
$model = $this->model->find($id, $columns);
|
||||
$this->resetModel();
|
||||
|
||||
return $this->parserResult($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find data by id
|
||||
*
|
||||
* @param $id
|
||||
* @param array $columns
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function findOrFail($id, $columns = ['*'])
|
||||
{
|
||||
$this->applyCriteria();
|
||||
$this->applyScope();
|
||||
$model = $this->model->findOrFail($id, $columns);
|
||||
$this->resetModel();
|
||||
|
||||
return $this->parserResult($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -159,9 +159,9 @@ class ProductRepository extends Repository
|
|||
$attributes = $product->attribute_family->custom_attributes;
|
||||
|
||||
foreach ($attributes as $attribute) {
|
||||
if(!isset($data[$attribute->code]) || !$data[$attribute->code])
|
||||
if(!isset($data[$attribute->code]) || ($attribute->code == 'boolean' && !$data[$attribute->code]))
|
||||
continue;
|
||||
|
||||
|
||||
$attributeValue = $this->attributeValue->findOneWhere([
|
||||
'product_id' => $product->id,
|
||||
'attribute_id' => $attribute->id,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class CreateOrderItemsTable extends Migration
|
|||
$table->integer('qty_ordered')->default(0)->nullable();
|
||||
$table->integer('qty_shipped')->default(0)->nullable();
|
||||
$table->integer('qty_invoiced')->default(0)->nullable();
|
||||
$table->integer('qty_canceled')->default(0)->nullable();
|
||||
$table->integer('qty_refunded')->default(0)->nullable();
|
||||
|
||||
$table->decimal('price', 12,4)->default(0);
|
||||
|
|
|
|||
|
|
@ -7,11 +7,12 @@ use Webkul\Sales\Contracts\Order as OrderContract;
|
|||
|
||||
class Order extends Model implements OrderContract
|
||||
{
|
||||
protected $guarded = ['id', 'items', 'shipping_address', 'billing_address', 'channel', 'payment', 'created_at', 'updated_at'];
|
||||
protected $guarded = ['id', 'items', 'shipping_address', 'billing_address', 'customer', 'channel', 'payment', 'created_at', 'updated_at'];
|
||||
|
||||
protected $statusLabel = [
|
||||
'pending' => 'Pending',
|
||||
'processing' => 'Processing',
|
||||
'completed' => 'Completed',
|
||||
'canceled' => 'Canceled',
|
||||
'closed' => 'Closed',
|
||||
];
|
||||
|
|
@ -31,6 +32,22 @@ class Order extends Model implements OrderContract
|
|||
return $this->statusLabel[$this->status];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return base total due amount
|
||||
*/
|
||||
public function getBaseTotalDueAttribute()
|
||||
{
|
||||
return $this->base_grand_total - $this->base_grand_total_invoiced;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return total due amount
|
||||
*/
|
||||
public function getTotalDueAttribute()
|
||||
{
|
||||
return $this->grand_total - $this->base_total_invoiced;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the order items record associated with the order.
|
||||
*/
|
||||
|
|
@ -143,4 +160,18 @@ class Order extends Model implements OrderContract
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if order could can canceled on not
|
||||
*/
|
||||
public function canCancel()
|
||||
{
|
||||
foreach($this->items as $item) {
|
||||
if ($item->qty_to_cancel > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -13,14 +13,21 @@ class OrderItem extends Model implements OrderItemContract
|
|||
* Get remaining qty for shipping.
|
||||
*/
|
||||
public function getQtyToShipAttribute() {
|
||||
return $this->qty_ordered - $this->qty_shipped - $this->qty_refunded;
|
||||
return $this->qty_ordered - $this->qty_shipped - $this->qty_refunded - $this->qty_canceled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get remaining qty for invoice.
|
||||
*/
|
||||
public function getQtyToInvoiceAttribute() {
|
||||
return $this->qty_ordered - $this->qty_invoiced - $this->qty_refunded;
|
||||
return $this->qty_ordered - $this->qty_invoiced - $this->qty_canceled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get remaining qty for cancel.
|
||||
*/
|
||||
public function getQtyToCancelAttribute() {
|
||||
return $this->qty_ordered - $this->qty_canceled - $this->qty_invoiced;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -138,8 +138,8 @@ class InvoiceRepository extends Repository
|
|||
'base_price' => $childOrderItem->base_price,
|
||||
'total' => $childOrderItem->price * $qty,
|
||||
'base_total' => $childOrderItem->base_price * $qty,
|
||||
'tax_amount' => ( ($childOrderItem->tax_amount / $childOrderItem->qty_ordered) * $qty ),
|
||||
'base_tax_amount' => ( ($childOrderItem->base_tax_amount / $childOrderItem->qty_ordered) * $qty ),
|
||||
'tax_amount' => 0,
|
||||
'base_tax_amount' => 0,
|
||||
'product_id' => $childOrderItem->product_id,
|
||||
'product_type' => $childOrderItem->product_type,
|
||||
'additional' => $childOrderItem->additional,
|
||||
|
|
@ -153,7 +153,7 @@ class InvoiceRepository extends Repository
|
|||
|
||||
$this->order->collectTotals($order);
|
||||
|
||||
$this->order->updateOrderStatus($order->id);
|
||||
$this->order->updateOrderStatus($order);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,30 @@ class OrderRepository extends Repository
|
|||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $orderId
|
||||
* @return mixed
|
||||
*/
|
||||
public function cancel($orderId)
|
||||
{
|
||||
$order = $this->findOrFail($orderId);
|
||||
|
||||
if(!$order->canCancel())
|
||||
return false;
|
||||
|
||||
foreach($order->items as $item) {
|
||||
if($item->qty_to_cancel) {
|
||||
$item->qty_canceled += $item->qty_to_cancel;
|
||||
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
||||
$this->updateOrderStatus($order);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
|
@ -135,12 +159,94 @@ class OrderRepository extends Repository
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $orderId
|
||||
* @param mixed $order
|
||||
* @return void
|
||||
*/
|
||||
public function updateOrderStatus(int $orderId)
|
||||
public function isInCompletedState($order)
|
||||
{
|
||||
$order = $this->find($orderId);
|
||||
$totalQtyOrdered = 0;
|
||||
$totalQtyInvoiced = 0;
|
||||
$totalQtyShipped = 0;
|
||||
$totalQtyRefunded = 0;
|
||||
$totalQtyCanceled = 0;
|
||||
|
||||
foreach($order->items as $item) {
|
||||
$totalQtyOrdered += $item->qty_ordered;
|
||||
$totalQtyInvoiced += $item->qty_invoiced;
|
||||
$totalQtyShipped += $item->qty_shipped;
|
||||
$totalQtyRefunded += $item->qty_refunded;
|
||||
$totalQtyCanceled += $item->qty_canceled;
|
||||
}
|
||||
|
||||
if($totalQtyOrdered != ($totalQtyRefunded + $totalQtyCanceled) &&
|
||||
$totalQtyOrdered == $totalQtyInvoiced + $totalQtyRefunded + $totalQtyCanceled &&
|
||||
$totalQtyOrdered == $totalQtyShipped + $totalQtyRefunded + $totalQtyCanceled)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $order
|
||||
* @return void
|
||||
*/
|
||||
public function isInCanceledState($order)
|
||||
{
|
||||
$totalQtyOrdered = 0;
|
||||
$totalQtyCanceled = 0;
|
||||
|
||||
foreach($order->items as $item) {
|
||||
$totalQtyOrdered += $item->qty_ordered;
|
||||
$totalQtyCanceled += $item->qty_canceled;
|
||||
}
|
||||
|
||||
if($totalQtyOrdered == $totalQtyCanceled)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $order
|
||||
* @return void
|
||||
*/
|
||||
public function isInClosedState($order)
|
||||
{
|
||||
$totalQtyOrdered = 0;
|
||||
$totalQtyRefunded = 0;
|
||||
$totalQtyCanceled = 0;
|
||||
|
||||
foreach($order->items as $item) {
|
||||
$totalQtyOrdered += $item->qty_ordered;
|
||||
$totalQtyRefunded += $item->qty_refunded;
|
||||
$totalQtyCanceled += $item->qty_canceled;
|
||||
}
|
||||
|
||||
if($totalQtyOrdered == $totalQtyRefunded + $totalQtyCanceled)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $order
|
||||
* @return void
|
||||
*/
|
||||
public function updateOrderStatus($order)
|
||||
{
|
||||
$status = 'processing';
|
||||
|
||||
if($this->isInCompletedState($order))
|
||||
$status = 'completed';
|
||||
|
||||
if($this->isInCanceledState($order))
|
||||
$status = 'canceled';
|
||||
|
||||
if($this->isInClosedState($order))
|
||||
$status = 'closed';
|
||||
|
||||
$order->status = $status;
|
||||
$order->save();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class ShipmentRepository extends Repository
|
|||
$this->orderItem->update(['qty_shipped' => $orderItem->qty_shipped + $qty], $orderItem->id);
|
||||
}
|
||||
|
||||
$this->order->updateOrderStatus($order->id);
|
||||
$this->order->updateOrderStatus($order);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
@section('content-wrapper')
|
||||
|
||||
<div class="order-success-content">
|
||||
<div class="order-success-content" style="min-height: 300px;">
|
||||
|
||||
<h1>{{ __('shop::app.checkout.success.thanks') }}</h1>
|
||||
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
<p>{{ __('shop::app.checkout.success.info') }}</p>
|
||||
|
||||
<div class="misc-controls">
|
||||
<a href="{{ route('shop.home.index') }}" class="btn btn-lg btn-primary">
|
||||
<a style="display: inline-block" href="{{ route('shop.home.index') }}" class="btn btn-lg btn-primary">
|
||||
{{ __('shop::app.checkout.cart.continue-shopping') }}
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ namespace Webkul\Tax\Http\Controllers;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Channel as Channel;
|
||||
use Webkul\Tax\Repositories\TaxCategoriesRepository as TaxRule;
|
||||
use Webkul\Tax\Repositories\TaxRatesRepository as TaxRate;
|
||||
use Webkul\Tax\Repositories\TaxCategoryRepository as TaxRule;
|
||||
use Webkul\Tax\Repositories\TaxRateRepository as TaxRate;
|
||||
use Webkul\Tax\Repositories\TaxMapRepository as TaxMap;
|
||||
|
||||
/**
|
||||
|
|
@ -34,7 +34,7 @@ class TaxCategoryController extends Controller
|
|||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Tax\Repositories\TaxCategoriesRepository $taxRule
|
||||
* @param Webkul\Tax\Repositories\TaxCategoryRepository $taxRule
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TaxRule $taxRule, TaxRate $taxRate, TaxMap $taxMap)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ namespace Webkul\Tax\Http\Controllers;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Core\Repositories\ChannelRepository as Channel;
|
||||
use Webkul\Tax\Repositories\TaxCategoriesRepository as TaxRule;
|
||||
use Webkul\Tax\Repositories\TaxRatesRepository as TaxRate;
|
||||
use Webkul\Tax\Repositories\TaxCategoryRepository as TaxRule;
|
||||
use Webkul\Tax\Repositories\TaxRateRepository as TaxRate;
|
||||
use Webkul\Tax\Repositories\TaxMapRepository as TaxMap;
|
||||
|
||||
|
||||
|
|
@ -57,8 +57,8 @@ class TaxController extends Controller
|
|||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Core\Repositories\ChannelRepository $channel
|
||||
* @param Webkul\Tax\Repositories\TaxCategoriesRepository $taxRule
|
||||
* @param Webkul\Tax\Repositories\TaxRatesRepository $taxRate
|
||||
* @param Webkul\Tax\Repositories\TaxCategoryRepository $taxRule
|
||||
* @param Webkul\Tax\Repositories\TaxRateRepository $taxRate
|
||||
* @param Webkul\Tax\Repositories\TaxMapRepository $taxMap
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace Webkul\Tax\Http\Controllers;
|
|||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Tax\Repositories\TaxRatesRepository as TaxRate;
|
||||
use Webkul\Tax\Repositories\TaxRateRepository as TaxRate;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -32,7 +32,7 @@ class TaxRateController extends Controller
|
|||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Tax\Repositories\TaxRatesRepository $taxRate
|
||||
* @param Webkul\Tax\Repositories\TaxRateRepository $taxRate
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TaxRate $taxRate)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use Webkul\Core\Eloquent\Repository;
|
|||
* @author Prashant Singh <prashant.singh852@webkul.com>
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class TaxCategoriesRepository extends Repository
|
||||
class TaxCategoryRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* Specify Model class name
|
||||
|
|
@ -10,7 +10,7 @@ use Webkul\Core\Eloquent\Repository;
|
|||
* @author Prashant Singh <prashant.singh852@webkul.com>
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class TaxRatesRepository extends Repository
|
||||
class TaxRateRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* Specify Model class name
|
||||
|
|
@ -13,3 +13,4 @@ Vue.component("image-wrapper", require("./components/image/image-wrapper"));
|
|||
Vue.component("image-item", require("./components/image/image-item"));
|
||||
Vue.directive("slugify", require("./directives/slugify"));
|
||||
Vue.directive("code", require("./directives/code"));
|
||||
Vue.directive("alert", require("./directives/alert"));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
<script>
|
||||
export default {
|
||||
bind(el, binding, vnode) {
|
||||
el.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var message = "Are your sure you want to perform this action ?";
|
||||
|
||||
if(binding.value && binding.value != '')
|
||||
message = binding.value;
|
||||
|
||||
if (confirm(message)) {
|
||||
window.location.href = el.href;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
export default {
|
||||
bind(el, binding, vnode) {
|
||||
let handler = function(e) {
|
||||
setTimeout(function(){
|
||||
setTimeout(function() {
|
||||
e.target.value = e.target.value.toString().toLowerCase()
|
||||
.replace(/[^\w_ ]+/g,'')
|
||||
.trim()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
export default {
|
||||
bind(el, binding, vnode) {
|
||||
let handler = function(e) {
|
||||
setTimeout(function(){
|
||||
setTimeout(function() {
|
||||
e.target.value = e.target.value.toString().toLowerCase()
|
||||
.replace(/[^\w- ]+/g,'')
|
||||
.trim()
|
||||
|
|
|
|||
Loading…
Reference in New Issue