Merge branch 'master' of https://github.com/bagisto/bagisto into development
This commit is contained in:
commit
3289ab8a4a
|
|
@ -157,12 +157,11 @@ class ShipmentController extends Controller
|
|||
? $orderItem->child->product
|
||||
: $orderItem->product;
|
||||
|
||||
$inventory = $product->inventories()
|
||||
$availableQty = $product->inventories()
|
||||
->where('inventory_source_id', $data['shipment']['source'])
|
||||
->where('vendor_id', 0)
|
||||
->first();
|
||||
->sum('qty');
|
||||
|
||||
if ($orderItem->qty_to_ship < $qty || $inventory->qty < $qty) {
|
||||
if ($orderItem->qty_to_ship < $qty || $availableQty < $qty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
$qty = 0;
|
||||
foreach ($product->inventories as $inventory) {
|
||||
if ($inventory->inventory_source_id == $inventorySource->id && ! $inventory->vendor_id) {
|
||||
if ($inventory->inventory_source_id == $inventorySource->id) {
|
||||
$qty = $inventory->qty;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@
|
|||
|
||||
sourceInventoryQty (inventorySourceId) {
|
||||
var inventories = this.variant.inventories.filter(function(inventory) {
|
||||
return inventorySourceId === inventory.inventory_source_id && !inventory.vendor_id;
|
||||
return inventorySourceId === inventory.inventory_source_id;
|
||||
})
|
||||
|
||||
if (inventories.length)
|
||||
|
|
|
|||
|
|
@ -312,9 +312,8 @@
|
|||
$product = $item->type == 'configurable' ? $item->child->product : $item->product;
|
||||
|
||||
foreach ($product->inventories as $inventory) {
|
||||
if ($inventory->inventory_source_id == $inventorySource->id && !$inventory->vendor_id) {
|
||||
$sourceQty = $inventory->qty;
|
||||
break;
|
||||
if ($inventory->inventory_source_id == $inventorySource->id) {
|
||||
$sourceQty += $inventory->qty;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class CreateOrderPaymentTable extends Migration
|
|||
$table->string('method');
|
||||
$table->string('method_title')->nullable();
|
||||
$table->integer('order_id')->nullable()->unsigned();
|
||||
$table->foreign('order_id')->references('id')->on('orders');
|
||||
$table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ class ShipmentItemRepository extends Repository
|
|||
*/
|
||||
public function updateProductInventory($data)
|
||||
{
|
||||
if (! $data['product'])
|
||||
return;
|
||||
|
||||
$orderedInventory = $data['product']->ordered_inventories()
|
||||
->where('channel_id', $data['shipment']->order->channel->id)
|
||||
->first();
|
||||
|
|
@ -54,6 +57,9 @@ class ShipmentItemRepository extends Repository
|
|||
->where('inventory_source_id', $data['shipment']->inventory_source_id)
|
||||
->first();
|
||||
|
||||
if (!$inventory)
|
||||
return;
|
||||
|
||||
if (($qty = $inventory->qty - $data['qty']) < 0) {
|
||||
$qty = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,9 @@ class ShipmentRepository extends Repository
|
|||
|
||||
$orderItem = $this->orderItem->find($itemId);
|
||||
|
||||
if ($qty > $orderItem->qty_to_ship)
|
||||
$qty = $orderItem->qty_to_ship;
|
||||
|
||||
$totalQty += $qty;
|
||||
|
||||
$shipmentItem = $this->shipmentItem->create([
|
||||
|
|
|
|||
|
|
@ -89,21 +89,28 @@ class CartController extends Controller
|
|||
*/
|
||||
public function add($id)
|
||||
{
|
||||
Event::fire('checkout.cart.add.before', $id);
|
||||
try {
|
||||
Event::fire('checkout.cart.add.before', $id);
|
||||
|
||||
$result = Cart::add($id, request()->except('_token'));
|
||||
$result = Cart::add($id, request()->except('_token'));
|
||||
|
||||
Event::fire('checkout.cart.add.after', $result);
|
||||
Event::fire('checkout.cart.add.after', $result);
|
||||
|
||||
if ($result) {
|
||||
session()->flash('success', trans('shop::app.checkout.cart.item.success'));
|
||||
} else {
|
||||
session()->flash('warning', trans('shop::app.checkout.cart.item.error-add'));
|
||||
if ($result) {
|
||||
session()->flash('success', trans('shop::app.checkout.cart.item.success'));
|
||||
} else {
|
||||
session()->flash('warning', trans('shop::app.checkout.cart.item.error-add'));
|
||||
}
|
||||
|
||||
Cart::collectTotals();
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
|
||||
} catch(\Exception $e) {
|
||||
session()->flash('error', trans($e->getMessage()));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
Cart::collectTotals();
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -176,10 +183,15 @@ class CartController extends Controller
|
|||
|
||||
public function buyNow($id)
|
||||
{
|
||||
Event::fire('checkout.cart.add.before', $id);
|
||||
|
||||
$result = Cart::proceedToBuyNow($id);
|
||||
|
||||
Event::fire('checkout.cart.add.after', $result);
|
||||
|
||||
Cart::collectTotals();
|
||||
|
||||
|
||||
if (! $result) {
|
||||
return redirect()->back();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ Route::group(['middleware' => ['web', 'theme', 'locale', 'currency']], function
|
|||
])->name('shop.checkout.cart.index');
|
||||
|
||||
//Cart Items Add
|
||||
Route::post('checkout/cart/add/{id}', 'Webkul\Shop\Http\Controllers\CartController@add')->name('cart.add');
|
||||
Route::post('checkout/cart/add/{id}', 'Webkul\Shop\Http\Controllers\CartController@add')->defaults('_config',[
|
||||
'redirect' => 'shop.checkout.cart.index'
|
||||
])->name('cart.add');
|
||||
|
||||
//Cart Items Add Configurable for more
|
||||
Route::get('checkout/cart/addconfigurable/{slug}', 'Webkul\Shop\Http\Controllers\CartController@addConfigurable')->name('cart.add.configurable');
|
||||
|
|
|
|||
|
|
@ -33,16 +33,28 @@
|
|||
|
||||
<div class="item-details">
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart.item.name.before', ['item' => $item]) !!}
|
||||
|
||||
<div class="item-title">
|
||||
<a href="{{ url()->to('/').'/products/'.$item->product->url_key }}">
|
||||
{{ $item->product->name }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart.item.name.after', ['item' => $item]) !!}
|
||||
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart.item.price.before', ['item' => $item]) !!}
|
||||
|
||||
<div class="price">
|
||||
{{ core()->currency($item->base_price) }}
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart.item.price.after', ['item' => $item]) !!}
|
||||
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart.item.options.before', ['item' => $item]) !!}
|
||||
|
||||
@if ($item->type == 'configurable')
|
||||
|
||||
<div class="summary">
|
||||
|
|
@ -51,6 +63,12 @@
|
|||
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart.item.options.after', ['item' => $item]) !!}
|
||||
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart.item.quantity.before', ['item' => $item]) !!}
|
||||
|
||||
<div class="misc">
|
||||
<div class="control-group" :class="[errors.has('qty[{{$item->id}}]') ? 'has-error' : '']">
|
||||
<div class="wrap">
|
||||
|
|
@ -76,6 +94,8 @@
|
|||
@endauth
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart.item.quantity.after', ['item' => $item]) !!}
|
||||
|
||||
@if (! cart()->isItemHaveQuantity($item))
|
||||
<div class="error-message mt-15">
|
||||
* {{ __('shop::app.checkout.cart.quantity-error') }}
|
||||
|
|
@ -87,6 +107,8 @@
|
|||
@endforeach
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart.controls.after', ['cart' => $cart]) !!}
|
||||
|
||||
<div class="misc-controls">
|
||||
<a href="{{ route('shop.home.index') }}" class="link">{{ __('shop::app.checkout.cart.continue-shopping') }}</a>
|
||||
|
||||
|
|
@ -102,11 +124,17 @@
|
|||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart.controls.after', ['cart' => $cart]) !!}
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="right-side">
|
||||
{!! view_render_event('bagisto.shop.checkout.cart.summary.after', ['cart' => $cart]) !!}
|
||||
|
||||
@include('shop::checkout.total.summary', ['cart' => $cart])
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart.summary.after', ['cart' => $cart]) !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -22,42 +22,63 @@
|
|||
<div class="dropdown-header">
|
||||
<p class="heading">
|
||||
{{ __('shop::app.checkout.cart.cart-subtotal') }} -
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.subtotal.before', ['cart' => $cart]) !!}
|
||||
|
||||
{{ core()->currency($cart->base_sub_total) }}
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.subtotal.after', ['cart' => $cart]) !!}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="dropdown-content">
|
||||
@foreach ($items as $item)
|
||||
{{-- @if ($item->type == "configurable") --}}
|
||||
<div class="item">
|
||||
<div class="item-image" >
|
||||
<?php
|
||||
if ($item->type == "configurable")
|
||||
$images = $productImageHelper->getProductBaseImage($item->child->product);
|
||||
else
|
||||
$images = $productImageHelper->getProductBaseImage($item->product);
|
||||
?>
|
||||
<img src="{{ $images['small_image_url'] }}" />
|
||||
</div>
|
||||
|
||||
<div class="item-details">
|
||||
{{-- @if ($item->type == "configurable")
|
||||
<div class="item-name">{{ $item->child->name }}</div>
|
||||
@else --}}
|
||||
<div class="item-name">{{ $item->name }}</div>
|
||||
{{-- @endif --}}
|
||||
|
||||
@if ($item->type == "configurable")
|
||||
<div class="item-options">
|
||||
{{ trim(Cart::getProductAttributeOptionDetails($item->child->product)['html']) }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="item-price">{{ core()->currency($item->base_total) }}</div>
|
||||
|
||||
<div class="item-qty">Quantity - {{ $item->quantity }}</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<div class="item-image" >
|
||||
<?php
|
||||
if ($item->type == "configurable")
|
||||
$images = $productImageHelper->getProductBaseImage($item->child->product);
|
||||
else
|
||||
$images = $productImageHelper->getProductBaseImage($item->product);
|
||||
?>
|
||||
<img src="{{ $images['small_image_url'] }}" />
|
||||
</div>
|
||||
|
||||
<div class="item-details">
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.name.before', ['item' => $item]) !!}
|
||||
|
||||
<div class="item-name">{{ $item->name }}</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.name.after', ['item' => $item]) !!}
|
||||
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.options.before', ['item' => $item]) !!}
|
||||
|
||||
@if ($item->type == "configurable")
|
||||
<div class="item-options">
|
||||
{{ trim(Cart::getProductAttributeOptionDetails($item->child->product)['html']) }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.options.after', ['item' => $item]) !!}
|
||||
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.price.before', ['item' => $item]) !!}
|
||||
|
||||
<div class="item-price">{{ core()->currency($item->base_total) }}</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.price.after', ['item' => $item]) !!}
|
||||
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.quantity.before', ['item' => $item]) !!}
|
||||
|
||||
<div class="item-qty">Quantity - {{ $item->quantity }}</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.cart-mini.item.quantity.after', ['item' => $item]) !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -61,10 +61,17 @@
|
|||
|
||||
<div class="item-details">
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.name.before', ['item' => $item]) !!}
|
||||
|
||||
<div class="item-title">
|
||||
{{ $product->name }}
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.name.after', ['item' => $item]) !!}
|
||||
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.price.before', ['item' => $item]) !!}
|
||||
|
||||
<div class="row">
|
||||
<span class="title">
|
||||
{{ __('shop::app.checkout.onepage.price') }}
|
||||
|
|
@ -74,6 +81,11 @@
|
|||
</span>
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.price.after', ['item' => $item]) !!}
|
||||
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.quantity.before', ['item' => $item]) !!}
|
||||
|
||||
<div class="row">
|
||||
<span class="title">
|
||||
{{ __('shop::app.checkout.onepage.quantity') }}
|
||||
|
|
@ -83,13 +95,19 @@
|
|||
</span>
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.quantity.after', ['item' => $item]) !!}
|
||||
|
||||
|
||||
@if ($product->type == 'configurable')
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.options.after', ['item' => $item]) !!}
|
||||
|
||||
<div class="summary" >
|
||||
|
||||
{{ Cart::getProductAttributeOptionDetails($item->child->product)['html'] }}
|
||||
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.checkout.options.after', ['item' => $item]) !!}
|
||||
@endif
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue