add shipping cost
This commit is contained in:
@@ -1,42 +1,49 @@
|
||||
<?php namespace App\Http\Controllers\paypal;
|
||||
<?php
|
||||
|
||||
use App\Http\Requests;
|
||||
namespace App\Http\Controllers\paypal;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Paypal;
|
||||
// use Paypal;
|
||||
use Netshell\Paypal\Facades\Paypal;
|
||||
use App\Models\teamstore\TeamStoreModel;
|
||||
use App\Models\user\UserModel;
|
||||
use App\Models\paypal\PayPalModel;
|
||||
use Auth;
|
||||
use Session;
|
||||
use Redirect;
|
||||
use Mail;
|
||||
// use Auth;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
// use Session;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
// use Redirect;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
// use Mail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
|
||||
class PaypalController extends Controller {
|
||||
class PaypalController extends Controller
|
||||
{
|
||||
|
||||
private $_apiContext;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->_apiContext = PayPal::ApiContext(
|
||||
config('services.paypal.client_id'),
|
||||
config('services.paypal.secret'));
|
||||
public function __construct()
|
||||
{
|
||||
$this->_apiContext = PayPal::ApiContext(
|
||||
config('services.paypal.client_id'),
|
||||
config('services.paypal.secret')
|
||||
);
|
||||
|
||||
|
||||
/* $this->_apiContext->setConfig(array(
|
||||
'mode' => 'sandbox',
|
||||
'service.EndPoint' => 'https://api.sandbox.paypal.com',
|
||||
'http.ConnectionTimeOut' => 30,
|
||||
'log.LogEnabled' => true,
|
||||
'log.FileName' => storage_path('logs/paypal.log'),
|
||||
'log.LogLevel' => 'FINE'
|
||||
)); */
|
||||
|
||||
// live
|
||||
// $this->_apiContext->setConfig(array(
|
||||
// 'mode' => 'sandbox',
|
||||
// 'service.EndPoint' => 'https://api.sandbox.paypal.com',
|
||||
// 'http.ConnectionTimeOut' => 30,
|
||||
// 'log.LogEnabled' => true,
|
||||
// 'log.FileName' => storage_path('logs/paypal.log'),
|
||||
// 'log.LogLevel' => 'FINE'
|
||||
// ));
|
||||
|
||||
// live
|
||||
$this->_apiContext->setConfig(array(
|
||||
'mode' => 'live',
|
||||
'service.EndPoint' => 'https://api.paypal.com',
|
||||
@@ -45,85 +52,106 @@ class PaypalController extends Controller {
|
||||
'log.FileName' => storage_path('logs/paypal.log'),
|
||||
'log.LogLevel' => 'FINE'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function payPremium()
|
||||
{
|
||||
return view('payPremium');
|
||||
}
|
||||
public function payPremium()
|
||||
{
|
||||
return view('payPremium');
|
||||
}
|
||||
|
||||
|
||||
public function getCheckout(Request $request)
|
||||
public function getCheckout(Request $request)
|
||||
{
|
||||
|
||||
if(Auth::guest()){
|
||||
if (Auth::guest()) {
|
||||
|
||||
$message = 'Please <a href="'. url('auth/login'). '">Sign in</a> to your account to proceed.';
|
||||
$message = 'Please <a href="' . url('auth/login') . '">Sign in</a> to your account to proceed.';
|
||||
Session::flash('msg', $message);
|
||||
return Redirect::back();
|
||||
}
|
||||
|
||||
$payer = PayPal::Payer();
|
||||
$payer->setPaymentMethod('paypal');
|
||||
$payer = PayPal::Payer();
|
||||
$payer->setPaymentMethod('paypal');
|
||||
|
||||
|
||||
|
||||
|
||||
$m = new TeamStoreModel;
|
||||
$paypal_model = new PayPalModel;
|
||||
$last_id = $paypal_model->getLastIdPaymentDetails();
|
||||
$invoice_num = str_pad($last_id[0]->Id, 4,'0',STR_PAD_LEFT);
|
||||
$invoice_num = str_pad($last_id[0]->Id, 4, '0', STR_PAD_LEFT);
|
||||
$cartKey = $request->session()->get('cartkey');
|
||||
|
||||
|
||||
$items = $m->myCart($cartKey);
|
||||
|
||||
|
||||
$getSubtotal = $m->getSubtotal($cartKey);
|
||||
$grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey);
|
||||
$store_array = $m->selectTeamStore('Id', $grouped_item[0]->StoreId);
|
||||
|
||||
|
||||
foreach($items as $item){
|
||||
if($item->VoucherId != null){
|
||||
$getSmallItemQty = 0;
|
||||
$getBulkyItemQty = 0;
|
||||
$getMaskItemQty = 0;
|
||||
$shippingFee = 0;
|
||||
|
||||
|
||||
foreach ($items as $item) {
|
||||
if ($item->VoucherId != null) {
|
||||
$voucherIds[] = $item->VoucherId;
|
||||
$voucher = $m->selectVoucherWhereIn($voucherIds);
|
||||
$item_id = $item->Id;
|
||||
$totalValue = $voucher[0]->VoucherValue;
|
||||
if($voucher[0]->VoucherType == "Percentage"){
|
||||
if ($voucher[0]->VoucherType == "Percentage") {
|
||||
$getPercentageValue = $totalValue / 100;
|
||||
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
|
||||
$data = array(
|
||||
'Price' => round($getDiscountValue * -1, 2)
|
||||
'Price' => round($getDiscountValue * -1, 2)
|
||||
);
|
||||
|
||||
$m->updateVoucherValueInCart($data, $item_id);
|
||||
}else{
|
||||
} else {
|
||||
$voucherData = array(
|
||||
'totalValue'=> $totalValue,
|
||||
'type'=>'Flat'
|
||||
'totalValue' => $totalValue,
|
||||
'type' => 'Flat'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if($item->ShippingCostId == 1){
|
||||
$getSmallItemQty += $item->Quantity;
|
||||
}else if($item->ShippingCostId == 2){
|
||||
$getBulkyItemQty += $item->Quantity;
|
||||
}else if($item->ShippingCostId == 3){
|
||||
$getMaskItemQty += $item->Quantity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$getSmallItemQty = ceil($getSmallItemQty / 3) * 8;
|
||||
$getBulkyItemQty = ceil($getBulkyItemQty / 1) * 8;
|
||||
$getMaskItemQty = ceil($getMaskItemQty / 25) * 8;
|
||||
$shippingFee = $getSmallItemQty + $getBulkyItemQty + $getMaskItemQty;
|
||||
// var_dump($shippingFee);
|
||||
|
||||
$order_items = array();
|
||||
$updated_items = $m->myCart($cartKey);
|
||||
$updated_getSubtotal = $m->getSubtotal($cartKey);
|
||||
|
||||
// $order_subtotal = $updated_getSubtotal[0]->Subtotal;
|
||||
$order_grandtotal = $updated_getSubtotal[0]->Subtotal;
|
||||
|
||||
if($grouped_item[0]->StoreId == 76 || $grouped_item[0]->StoreId == 78 || $grouped_item[0]->StoreId == 111 || $grouped_item[0]->StoreId == 131 || $grouped_item[0]->StoreId == 30 || $grouped_item[0]->StoreId == 141 || $grouped_item[0]->StoreId == 162){
|
||||
|
||||
if ($grouped_item[0]->StoreId == 76 || $grouped_item[0]->StoreId == 78 || $grouped_item[0]->StoreId == 111 || $grouped_item[0]->StoreId == 131 || $grouped_item[0]->StoreId == 30 || $grouped_item[0]->StoreId == 141 || $grouped_item[0]->StoreId == 162) {
|
||||
$tax_value = 0;
|
||||
}else{
|
||||
} else {
|
||||
$tax_value = 0.10;
|
||||
}
|
||||
|
||||
|
||||
$tax = $order_grandtotal * $tax_value;
|
||||
|
||||
foreach($updated_items as $key => $item){
|
||||
foreach ($updated_items as $key => $item) {
|
||||
|
||||
// $descriptions = "Name: " . $item->Name . " Number: " . $item->Number . " Size: " . $item->Size;"?"
|
||||
|
||||
|
||||
$order_items[$key] = PayPal::Item();
|
||||
$order_items[$key]->setName($item->ProductName);
|
||||
$order_items[$key]->setCurrency($store_array[0]->StoreCurrency);
|
||||
@@ -131,44 +159,44 @@ class PaypalController extends Controller {
|
||||
// $order_items[$key]->setDescription($descriptions);
|
||||
// $order_items[$key]->setTax(10);
|
||||
$order_items[$key]->setPrice($item->Price);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$item_list = PayPal::ItemList();
|
||||
$item_list->setItems($order_items);
|
||||
$amount_details = PayPal::Details();
|
||||
$amount_details->setSubtotal($order_grandtotal);
|
||||
$amount_details->setTax($tax);
|
||||
$amount_details->setShipping($shippingFee);
|
||||
|
||||
$amount = PayPal::Amount();
|
||||
$amount->setCurrency($store_array[0]->StoreCurrency);
|
||||
$amount->setDetails($amount_details);
|
||||
$amount->setTotal($order_grandtotal + $tax);
|
||||
|
||||
$amount->setTotal($order_grandtotal + $tax + $shippingFee);
|
||||
|
||||
$transaction = PayPal::Transaction();
|
||||
$transaction->setAmount($amount);
|
||||
$transaction->setItemList($item_list);
|
||||
|
||||
|
||||
// $transaction->setDescription('Your transaction description');
|
||||
$transaction->setInvoiceNumber(date('Ymd') . '-' . $invoice_num);
|
||||
|
||||
$redirectUrls = PayPal:: RedirectUrls();
|
||||
$redirectUrls->setReturnUrl(route('getDone'));
|
||||
$redirectUrls->setCancelUrl(route('getCancel'));
|
||||
|
||||
$redirectUrls = PayPal::RedirectUrls();
|
||||
$redirectUrls->setReturnUrl(route('getDone'));
|
||||
$redirectUrls->setCancelUrl(route('getCancel'));
|
||||
|
||||
|
||||
$payment = PayPal::Payment();
|
||||
$payment->setIntent('sale');
|
||||
$payment->setPayer($payer);
|
||||
$payment->setRedirectUrls($redirectUrls);
|
||||
$payment->setTransactions(array($transaction));
|
||||
$payment = PayPal::Payment();
|
||||
$payment->setIntent('sale');
|
||||
$payment->setPayer($payer);
|
||||
$payment->setRedirectUrls($redirectUrls);
|
||||
$payment->setTransactions(array($transaction));
|
||||
|
||||
|
||||
$response = $payment->create($this->_apiContext);
|
||||
$redirectUrl = $response->links[1]->href;
|
||||
$response = $payment->create($this->_apiContext);
|
||||
$redirectUrl = $response->links[1]->href;
|
||||
|
||||
|
||||
return redirect()->to( $redirectUrl );
|
||||
return redirect()->to($redirectUrl);
|
||||
}
|
||||
|
||||
public function getDoneTest()
|
||||
@@ -193,38 +221,38 @@ class PaypalController extends Controller {
|
||||
// echo $ex;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getDone(Request $request)
|
||||
{
|
||||
$id = $request->get('paymentId');
|
||||
$token = $request->get('token');
|
||||
$payer_id = $request->get('PayerID');
|
||||
$id = $request->get('paymentId');
|
||||
$token = $request->get('token');
|
||||
$payer_id = $request->get('PayerID');
|
||||
|
||||
|
||||
$payment = PayPal::getById($id, $this->_apiContext);
|
||||
$payment = PayPal::getById($id, $this->_apiContext);
|
||||
|
||||
$paymentExecution = PayPal::PaymentExecution();
|
||||
|
||||
$paymentExecution->setPayerId($payer_id);
|
||||
$executePayment = $payment->execute($paymentExecution, $this->_apiContext);
|
||||
$paymentExecution->setPayerId($payer_id);
|
||||
$executePayment = $payment->execute($paymentExecution, $this->_apiContext);
|
||||
|
||||
// print_r($executePayment);
|
||||
// if ($executePayment->getState() == 'approved') {
|
||||
|
||||
// /** it's all right **/
|
||||
// /** Here Write your database logic like that insert record or value in database if you want **/
|
||||
|
||||
// // \Session::put('success','Payment success');
|
||||
// /** it's all right **/
|
||||
// /** Here Write your database logic like that insert record or value in database if you want **/
|
||||
|
||||
// // \Session::put('success','Payment success');
|
||||
// // return Redirect::route('paywithpaypal');
|
||||
// echo 'Payment success';
|
||||
// }
|
||||
$obj = json_decode($executePayment);
|
||||
|
||||
|
||||
|
||||
$line2 = null;
|
||||
|
||||
|
||||
//details
|
||||
$total = $obj->transactions[0]->amount->total;
|
||||
$sub_total = $obj->transactions[0]->amount->details->subtotal;
|
||||
@@ -236,7 +264,7 @@ class PaypalController extends Controller {
|
||||
//shipping address details
|
||||
$recipient_name = $obj->transactions[0]->item_list->shipping_address->recipient_name;
|
||||
$line1 = $obj->transactions[0]->item_list->shipping_address->line1;
|
||||
if(isset($obj->transactions[0]->item_list->shipping_address->line2)){
|
||||
if (isset($obj->transactions[0]->item_list->shipping_address->line2)) {
|
||||
$line2 = $obj->transactions[0]->item_list->shipping_address->line2;
|
||||
}
|
||||
$city = $obj->transactions[0]->item_list->shipping_address->city;
|
||||
@@ -250,7 +278,7 @@ class PaypalController extends Controller {
|
||||
$first_name = $obj->payer->payer_info->first_name;
|
||||
$last_name = $obj->payer->payer_info->last_name;
|
||||
$_payer_id = $obj->payer->payer_info->payer_id;
|
||||
|
||||
|
||||
/// end paypal codes
|
||||
|
||||
$paypal_model = new PayPalModel;
|
||||
@@ -264,22 +292,22 @@ class PaypalController extends Controller {
|
||||
|
||||
$payment_details = array(
|
||||
|
||||
'UserId' => $userId,
|
||||
'CartKey' => $cartKey,
|
||||
'PaymentId' => $id,
|
||||
'Token' => $token,
|
||||
'PayerId' => $payer_id,
|
||||
'InvoiceNumber' => $invoice_number,
|
||||
'Currency' => $currency,
|
||||
'Total' => $total,
|
||||
'SubTotal' => $sub_total,
|
||||
'Tax' => $tax,
|
||||
'Payer_Email' => $email,
|
||||
'Payer_Firstname' => $first_name,
|
||||
'Payer_Lastname' => $last_name,
|
||||
'PaymentMethod' =>$payment_method
|
||||
'UserId' => $userId,
|
||||
'CartKey' => $cartKey,
|
||||
'PaymentId' => $id,
|
||||
'Token' => $token,
|
||||
'PayerId' => $payer_id,
|
||||
'InvoiceNumber' => $invoice_number,
|
||||
'Currency' => $currency,
|
||||
'Total' => $total,
|
||||
'SubTotal' => $sub_total,
|
||||
'Tax' => $tax,
|
||||
'Payer_Email' => $email,
|
||||
'Payer_Firstname' => $first_name,
|
||||
'Payer_Lastname' => $last_name,
|
||||
'PaymentMethod' => $payment_method
|
||||
|
||||
);
|
||||
);
|
||||
|
||||
$p_id = $paypal_model->insertToPaypalDetails($payment_details);
|
||||
|
||||
@@ -295,7 +323,7 @@ class PaypalController extends Controller {
|
||||
);
|
||||
// iinsert shipping address
|
||||
$paypal_model->insertShippingAddress($shipping_address);
|
||||
|
||||
|
||||
// insert order from cart_tmp to orders table
|
||||
$l = $paypal_model->insertToOrders($cartKey); // insert to orders table
|
||||
|
||||
@@ -306,30 +334,30 @@ class PaypalController extends Controller {
|
||||
$item_thumbs = $newUserModel->selectDisplayItemThumb();
|
||||
$array_payment_details = $newUserModel->selectPaymentDetails('CartKey', $cartKey);
|
||||
$array_storename = $newUserModel->selectTeamStoreName($cartKey); // email subject
|
||||
|
||||
|
||||
foreach($array_storename as $storname){
|
||||
|
||||
|
||||
|
||||
foreach ($array_storename as $storname) {
|
||||
|
||||
$sName[] = $storname->StoreName;
|
||||
$sid[] = $storname->Id;
|
||||
}
|
||||
$sName = implode (", ", $sName);
|
||||
$sName = implode(", ", $sName);
|
||||
|
||||
|
||||
$user_loginsArray = $newUserModel->selectUserLoginsWhereIn($sid);
|
||||
|
||||
foreach($user_loginsArray as $userdata){
|
||||
|
||||
foreach ($user_loginsArray as $userdata) {
|
||||
|
||||
$other_email[] = $userdata->other_email;
|
||||
}
|
||||
|
||||
if($other_email[0] != null){
|
||||
$other_email = implode (", ", $other_email);
|
||||
if ($other_email[0] != null) {
|
||||
$other_email = implode(", ", $other_email);
|
||||
$email_cc = "orders@crewsportswear.com" . "," . $other_email;
|
||||
}else{
|
||||
} else {
|
||||
$email_cc = "orders@crewsportswear.com";
|
||||
}
|
||||
|
||||
|
||||
$explode_other_email = explode(",", $email_cc);
|
||||
|
||||
$data = array(
|
||||
@@ -341,8 +369,8 @@ class PaypalController extends Controller {
|
||||
'email_cc' => $explode_other_email,
|
||||
'subject' => $sName . ' ORDERS',
|
||||
);
|
||||
|
||||
Mail::send('emails.orders', $data, function($message) use ($data) {
|
||||
|
||||
Mail::send('emails.orders', $data, function ($message) use ($data) {
|
||||
$message->from('no-reply@crewsportswear.com', 'CREW Sportswear');
|
||||
$message->bcc($data['email_cc'], 'Orders From CREW Sportswear');
|
||||
$message->to($data['receiver'])->subject($data['subject']);
|
||||
@@ -350,12 +378,11 @@ class PaypalController extends Controller {
|
||||
// end email sending
|
||||
|
||||
$request->session()->forget('cartkey'); // clear session for cartkey
|
||||
|
||||
|
||||
// redirect to thank you page.
|
||||
return view('paypal.get_done')
|
||||
->with('currency', $currency)
|
||||
->with('total', $total);
|
||||
|
||||
->with('currency', $currency)
|
||||
->with('total', $total);
|
||||
}
|
||||
|
||||
|
||||
@@ -363,31 +390,30 @@ class PaypalController extends Controller {
|
||||
{
|
||||
$m = new TeamStoreModel;
|
||||
$cartKey = $request->session()->get('cartkey');
|
||||
|
||||
|
||||
$items = $m->myCart($cartKey);
|
||||
$getSubtotal = $m->getSubtotal($cartKey);
|
||||
|
||||
foreach($items as $item){
|
||||
if($item->VoucherId != null){
|
||||
foreach ($items as $item) {
|
||||
if ($item->VoucherId != null) {
|
||||
$voucherIds[] = $item->VoucherId;
|
||||
$voucher = $m->selectVoucherWhereIn($voucherIds);
|
||||
$item_id = $item->Id;
|
||||
$totalValue = $voucher[0]->VoucherValue;
|
||||
if($voucher[0]->VoucherType == "Percentage"){
|
||||
if ($voucher[0]->VoucherType == "Percentage") {
|
||||
$data = array(
|
||||
'Price' => '00.00'
|
||||
);
|
||||
$m->updateVoucherValueInCart($data, $item_id);
|
||||
}else{
|
||||
} else {
|
||||
$voucherData = array(
|
||||
'totalValue'=> $totalValue,
|
||||
'type'=>'Flat'
|
||||
'totalValue' => $totalValue,
|
||||
'type' => 'Flat'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('cart');
|
||||
return redirect()->route('cart');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
// use Auth;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\teamstore\TeamStoreModel;
|
||||
use App\Models\user\UserModel;
|
||||
use Mail;
|
||||
// use Mail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Analytics;
|
||||
|
||||
|
||||
@@ -251,7 +253,7 @@ class TeamStoreController extends Controller {
|
||||
}
|
||||
|
||||
if($item[0]->ProductAvailableQty != null){
|
||||
$soldQty = $m->getSoldQty($product_array[0]->Id);
|
||||
$soldQty = $TeamStoreModel->getSoldQty($item[0]->Id);
|
||||
$availableQty = $item[0]->ProductAvailableQty - $soldQty[0]->SoldQty;
|
||||
}else{
|
||||
// echo 'no qty';
|
||||
@@ -288,7 +290,8 @@ class TeamStoreController extends Controller {
|
||||
$ProductURL = $product_array[0]->ProductURL;
|
||||
$product_form = $product_array[0]->ProductForm;
|
||||
$design_code = $product_array[0]->DesignCode;
|
||||
$product_name = $product_array[0]->ProductName;
|
||||
$product_name = $product_array[0]->ProductName;
|
||||
$shipping_cost_id = $product_array[0]->ShippingCostId;
|
||||
|
||||
$teamstore_array = $m->selectTeamStore('Id', $TeamStoreId);
|
||||
|
||||
@@ -323,7 +326,8 @@ class TeamStoreController extends Controller {
|
||||
'JerseySize' => $order_jersey_size[$key],
|
||||
'ShortsSize' => $order_shorts_size[$key],
|
||||
'Price' => $final_price,
|
||||
'Quantity' => 1
|
||||
'Quantity' => 1,
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
}
|
||||
}elseif($product_form == "tshirt-form"){
|
||||
@@ -339,7 +343,8 @@ class TeamStoreController extends Controller {
|
||||
'ProductName' => $product_name,
|
||||
'Size' => $post['uniformSize'],
|
||||
'Price' => $ProductPrice,
|
||||
'Quantity' => $post['quantity']
|
||||
'Quantity' => $post['quantity'],
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
}elseif($product_form == "quantity-form"){
|
||||
|
||||
@@ -353,7 +358,8 @@ class TeamStoreController extends Controller {
|
||||
'ProductURL' => $ProductURL,
|
||||
'ProductName' => $product_name,
|
||||
'Price' => $ProductPrice,
|
||||
'Quantity' => $post['quantity']
|
||||
'Quantity' => $post['quantity'],
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
|
||||
|
||||
@@ -375,7 +381,8 @@ class TeamStoreController extends Controller {
|
||||
'Name' => $order_names[$key],
|
||||
'Number' => $order_number[$key],
|
||||
'Price' => $ProductPrice,
|
||||
'Quantity' => 1
|
||||
'Quantity' => 1,
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
}
|
||||
}elseif($product_form == "name-number-size-form"){
|
||||
@@ -398,7 +405,8 @@ class TeamStoreController extends Controller {
|
||||
'Size' => $order_size[$key],
|
||||
'Number' => $order_number[$key],
|
||||
'Price' => $ProductPrice,
|
||||
'Quantity' => 1
|
||||
'Quantity' => 1,
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
}
|
||||
|
||||
@@ -418,7 +426,8 @@ class TeamStoreController extends Controller {
|
||||
'ProductName' => $product_name,
|
||||
'Number' => $order_number[$key],
|
||||
'Price' => $ProductPrice,
|
||||
'Quantity' => 1
|
||||
'Quantity' => 1,
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
}
|
||||
}elseif($product_form == "name-name2-size-form"){
|
||||
@@ -441,7 +450,8 @@ class TeamStoreController extends Controller {
|
||||
'Name2' => $order_names2[$key],
|
||||
'Size' => $order_size[$key],
|
||||
'Price' => $ProductPrice,
|
||||
'Quantity' => 1
|
||||
'Quantity' => 1,
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
}
|
||||
}elseif($product_form == "name-size-form"){
|
||||
@@ -462,7 +472,8 @@ class TeamStoreController extends Controller {
|
||||
'Name' => $order_names[$key],
|
||||
'Size' => $order_size[$key],
|
||||
'Price' => $ProductPrice,
|
||||
'Quantity' => 1
|
||||
'Quantity' => 1,
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
}
|
||||
}elseif($product_form == "jersey-and-shorts-quantity-form"){
|
||||
@@ -492,7 +503,8 @@ class TeamStoreController extends Controller {
|
||||
'JerseySize' => $order_jersey_size[$key],
|
||||
'ShortsSize' => $order_shorts_size[$key],
|
||||
'Price' => $final_price,
|
||||
'Quantity' => $quantity[$key]
|
||||
'Quantity' => $quantity[$key],
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
}
|
||||
|
||||
@@ -524,11 +536,12 @@ class TeamStoreController extends Controller {
|
||||
'JerseySize' => $order_jersey_size[$key],
|
||||
'ShortsSize' => $order_shorts_size[$key],
|
||||
'Price' => $final_price,
|
||||
'Quantity' => 1
|
||||
'Quantity' => 1,
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$i = $m->insertToCart($items);
|
||||
|
||||
if($i['i']){
|
||||
|
||||
@@ -4,44 +4,18 @@ use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Models\user\UserModel;
|
||||
use App\Models\teamstore\TeamStoreModel;
|
||||
use App\Models\MainModel;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Paypal;
|
||||
use View;
|
||||
use Mail;
|
||||
use Validator;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
||||
class UserController extends Controller {
|
||||
|
||||
// private $_apiContext;
|
||||
|
||||
// public function __construct()
|
||||
// {
|
||||
// $this->_apiContext = PayPal::ApiContext(
|
||||
// config('services.paypal.client_id'),
|
||||
// config('services.paypal.secret'));
|
||||
|
||||
|
||||
// $this->_apiContext->setConfig(array(
|
||||
// 'mode' => 'sandbox',
|
||||
// 'service.EndPoint' => 'https://api.sandbox.paypal.com',
|
||||
// 'http.ConnectionTimeOut' => 30,
|
||||
// 'log.LogEnabled' => true,
|
||||
// 'log.FileName' => storage_path('logs/paypal.log'),
|
||||
// 'log.LogLevel' => 'FINE'
|
||||
// ));
|
||||
|
||||
|
||||
// // view()->share('datas', [1, 2, 3]);
|
||||
|
||||
// }
|
||||
|
||||
//
|
||||
public function index(){
|
||||
|
||||
return view('user-layouts.index');
|
||||
@@ -333,10 +307,12 @@ class UserController extends Controller {
|
||||
$product_array = $newTeamStoreModel->selectTeamStoreProducts('ProductURL', $url);
|
||||
$thumbnails_array = $newTeamStoreModel->getThumbnails($product_array[0]->Id);
|
||||
$available_size = explode(",", $product_array[0]->AvailableSizes);
|
||||
// var_dump($product_array);
|
||||
$shipping_cost = $newUserModel->selectShippingCost();
|
||||
|
||||
return view('user-layouts.view-store-item')->with('product_array', $product_array)
|
||||
->with('available_size', $available_size)
|
||||
->with('thumbnails_array', $thumbnails_array);
|
||||
->with('thumbnails_array', $thumbnails_array)
|
||||
->with('shipping_cost', $shipping_cost);
|
||||
|
||||
|
||||
}
|
||||
@@ -346,6 +322,12 @@ class UserController extends Controller {
|
||||
$post = $request->all();
|
||||
$newTeamStoreModel = new TeamStoreModel;
|
||||
|
||||
if($post['shipping_cost'] == 0){
|
||||
$shipping_cost_id = null;
|
||||
}else{
|
||||
$shipping_cost_id = $post['shipping_cost'];
|
||||
}
|
||||
|
||||
$item_url = $post['item_url'];
|
||||
$data = array(
|
||||
'ProductName' => $post['itemName'],
|
||||
@@ -353,7 +335,9 @@ class UserController extends Controller {
|
||||
'ProductDescription' => $post['itemDescription'],
|
||||
'PrivacyStatus' => $post['item_privacy'],
|
||||
'ProductForm' => $post['itemForm'],
|
||||
'AvailableSizes' => implode(",", $post['available_size'])
|
||||
'AvailableSizes' => implode(",", $post['available_size']),
|
||||
'ShippingCostId' => $shipping_cost_id
|
||||
|
||||
);
|
||||
|
||||
$i = $newTeamStoreModel->updateStoreItem($data, $item_url);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
// use Spatie\LaravelAnalytics\LaravelAnalytics;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Routes
|
||||
@@ -175,6 +177,6 @@ Route::group(['middleware' => 'admin'], function () {
|
||||
|
||||
Route::get('cliparts/index', 'cliparts\ClipartsController@index');
|
||||
|
||||
Route::get('analytics', function (){
|
||||
$analyticsData = LaravelAnalytics::getVisitorsAndPageViews(7);
|
||||
});
|
||||
// Route::get('analytics', function (){
|
||||
// $analyticsData = LaravelAnalytics::getVisitorsAndPageViews(7);
|
||||
// });
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
||||
class SizesModel extends Model {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php namespace App\Models\paypal;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PayPalModel extends Model {
|
||||
|
||||
@@ -37,7 +37,5 @@ class PayPalModel extends Model {
|
||||
->get();
|
||||
// var_dump($i);
|
||||
return $i;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php namespace App\Models\teamstore;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TeamStoreModel extends Model {
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php namespace App\Models\user;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use DB;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UserModel extends Model {
|
||||
|
||||
@@ -310,5 +310,11 @@ class UserModel extends Model {
|
||||
return $i;
|
||||
}
|
||||
|
||||
function selectShippingCost(){
|
||||
$i = DB::table('shipping_cost')
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user