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'
|
||||
)); */
|
||||
// $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
|
||||
// live
|
||||
$this->_apiContext->setConfig(array(
|
||||
'mode' => 'live',
|
||||
'service.EndPoint' => 'https://api.paypal.com',
|
||||
@@ -45,34 +52,34 @@ 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);
|
||||
@@ -81,14 +88,19 @@ class PaypalController extends Controller {
|
||||
$grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey);
|
||||
$store_array = $m->selectTeamStore('Id', $grouped_item[0]->StoreId);
|
||||
|
||||
$getSmallItemQty = 0;
|
||||
$getBulkyItemQty = 0;
|
||||
$getMaskItemQty = 0;
|
||||
$shippingFee = 0;
|
||||
|
||||
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") {
|
||||
$getPercentageValue = $totalValue / 100;
|
||||
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
|
||||
$data = array(
|
||||
@@ -96,15 +108,31 @@ class PaypalController extends Controller {
|
||||
);
|
||||
|
||||
$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);
|
||||
@@ -112,15 +140,15 @@ class PaypalController extends Controller {
|
||||
// $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;"?"
|
||||
|
||||
@@ -131,7 +159,6 @@ class PaypalController extends Controller {
|
||||
// $order_items[$key]->setDescription($descriptions);
|
||||
// $order_items[$key]->setTax(10);
|
||||
$order_items[$key]->setPrice($item->Price);
|
||||
|
||||
}
|
||||
|
||||
$item_list = PayPal::ItemList();
|
||||
@@ -139,11 +166,12 @@ class PaypalController extends Controller {
|
||||
$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);
|
||||
@@ -152,23 +180,23 @@ class PaypalController extends Controller {
|
||||
// $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()
|
||||
@@ -198,25 +226,25 @@ class PaypalController extends Controller {
|
||||
|
||||
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 **/
|
||||
// /** 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');
|
||||
// // \Session::put('success','Payment success');
|
||||
// // return Redirect::route('paywithpaypal');
|
||||
// echo 'Payment success';
|
||||
// }
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
@@ -308,25 +336,25 @@ class PaypalController extends Controller {
|
||||
$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";
|
||||
}
|
||||
|
||||
@@ -342,7 +370,7 @@ class PaypalController extends Controller {
|
||||
'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']);
|
||||
@@ -353,9 +381,8 @@ class PaypalController extends Controller {
|
||||
|
||||
// redirect to thank you page.
|
||||
return view('paypal.get_done')
|
||||
->with('currency', $currency)
|
||||
->with('total', $total);
|
||||
|
||||
->with('currency', $currency)
|
||||
->with('total', $total);
|
||||
}
|
||||
|
||||
|
||||
@@ -367,27 +394,26 @@ class PaypalController extends Controller {
|
||||
$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';
|
||||
@@ -289,6 +291,7 @@ class TeamStoreController extends Controller {
|
||||
$product_form = $product_array[0]->ProductForm;
|
||||
$design_code = $product_array[0]->DesignCode;
|
||||
$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,7 +536,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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -38,6 +38,4 @@ class PayPalModel extends Model {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -35,10 +35,10 @@ return [
|
||||
],
|
||||
|
||||
// sandbox
|
||||
/* 'paypal' => [
|
||||
'client_id' => 'AQuz-HKzQiL7FygkG8skSekaWf-RP6Rgj4f1XeX1Ghp86bUFj7tQXVT1xbpluu5_WCGRbQpOVGtlJKVB',
|
||||
'secret' => 'EJAMKxQsl-mFkL_4J_90cvTamYfcsgswqgIxz9wQPiRAwJ6sy_wNsttMlmrXIpxI96JpYzdMXkLCHAPz'
|
||||
], */
|
||||
// 'paypal' => [
|
||||
// 'client_id' => 'AQuz-HKzQiL7FygkG8skSekaWf-RP6Rgj4f1XeX1Ghp86bUFj7tQXVT1xbpluu5_WCGRbQpOVGtlJKVB',
|
||||
// 'secret' => 'EJAMKxQsl-mFkL_4J_90cvTamYfcsgswqgIxz9wQPiRAwJ6sy_wNsttMlmrXIpxI96JpYzdMXkLCHAPz'
|
||||
// ],
|
||||
|
||||
// live
|
||||
'paypal' => [
|
||||
|
||||
@@ -1842,7 +1842,7 @@
|
||||
|
||||
function submitFormItemDetails(){
|
||||
var data = $("#frm-item-details").serialize();
|
||||
|
||||
console.log(data)
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
url : "{{ url('user/store-items/update') }}",
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
<li class="active">{{ $product_array[0]->ProductName }}</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<!-- Main content -->
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
@@ -146,9 +145,20 @@
|
||||
<label>Item Privacy</label>
|
||||
<select class="form-control" name="item_privacy">
|
||||
<option value="public" @if($product_array[0]->PrivacyStatus == "public") selected @endif>Public</option>
|
||||
<option value="private" @if($product_array[0]->PrivacyStatus == "private") selected @endif">Private</option>
|
||||
<option value="private" @if($product_array[0]->PrivacyStatus == "private") selected @endif>Private</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Select Shipping Category</label>
|
||||
<select class="form-control" name="shipping_cost" required>
|
||||
<option value="0">None</option>
|
||||
@foreach ($shipping_cost as $sc)
|
||||
<option value="{{ $sc->Id }}" @if($sc->Id == $product_array[0]->ShippingCostId) selected @endif>{{ $sc->DisplayName }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<span id="err_available_size"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user