Beispiel #1
0
 public function getItemCount($userId)
 {
     $cartId = ShoppingCarts::where('user_id', $userId)->first();
     if (!$cartId) {
         return 0;
     }
     return ShoppingCartItems::where('shopping_cart_id', $cartId->id)->count();
 }
Beispiel #2
0
 public function updateSales(Request $request, $approved)
 {
     $userId = $request->session()->get('user_id');
     $roles = $request->session()->get('userRoles');
     $user = Users::find($userId);
     $shoppingCart = ShoppingCarts::where('user_id', $userId)->first();
     $items = $this->processApprovedItems($shoppingCart);
     $payPrice = $request->session()->get('transactionPayPrice');
     $salesTransaction = new SalesTransactions();
     $salesTransaction->date = $approved['date'];
     $salesTransaction->purchased_by = $userId;
     $salesTransaction->total_items = $request->session()->get('transactionTotalPrice');
     $shipping = $request->session()->get('transactionTotalWeightShipping') + $request->session()->get('transactionTotalShipping');
     $salesTransaction->total_shipping = $shipping;
     $salesTransaction->total_order = $request->session()->get('transactionGrandTotal');
     $salesTransaction->payment_method = 1;
     $salesTransaction->pay_bonus_on_amt = $request->session()->get('payPrice');
     $salesTransaction->credit_card_id = $approved['credit_card'];
     $salesTransaction->payment_type = $approved['pay_method'];
     $salesTransaction->transaction_approval_code = $approved['approval_code'];
     $salesTransaction->transaction_approval_date = $approved['date'];
     $salesTransaction->first_id = $user->sponsor_id;
     $salesTransaction->second_id = $user->second_id;
     $salesTransaction->third_id = $user->third_id;
     $salesTransaction->fourth_id = $user->fourth_id;
     $salesTransaction->fifth_id = $user->fifth_id;
     $salesTransaction->shipping_id = $request->session()->get('shippingId');
     $salesTransaction->save();
     $this->updateSalesDetails($salesTransaction, $items, $roles);
     $this->updateBonuses($salesTransaction, $user, $roles);
     $items = $this->processPaidItems($shoppingCart);
     return 1000000 + $salesTransaction->id;
 }