Issues fixed

This commit is contained in:
jitendra 2019-01-18 16:40:40 +05:30
parent 00b9007d99
commit fbbf1fe99f
7 changed files with 34 additions and 22 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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)

View File

@ -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;
}
}
?>

View File

@ -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();
});
}

View File

@ -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 {

View File

@ -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');