Compare commits
1 Commits
master
...
shipping_f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2cddafa5f |
@@ -6,7 +6,7 @@
|
|||||||
# Redirect Trailing Slashes...
|
# Redirect Trailing Slashes...
|
||||||
RewriteRule ^(.*)/$public /$1 [L,R=301]
|
RewriteRule ^(.*)/$public /$1 [L,R=301]
|
||||||
RewriteCond %{SERVER_PORT} 80
|
RewriteCond %{SERVER_PORT} 80
|
||||||
RewriteRule ^(.*)$ https://www.crewsportswear.com/beta/$1 [R,L]
|
#RewriteRule ^(.*)$ https://www.crewsportswear.com/beta/$1 [R,L]
|
||||||
# Handle Front Controller...
|
# Handle Front Controller...
|
||||||
RewriteCond %{REQUEST_FILENAME} !-d
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Http\Controllers\paypal;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\paypal;
|
||||||
|
|
||||||
use App\Http\Requests;
|
use App\Http\Requests;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
@@ -13,96 +15,97 @@ use Session;
|
|||||||
use Redirect;
|
use Redirect;
|
||||||
use Mail;
|
use Mail;
|
||||||
|
|
||||||
|
class PaypalController extends Controller
|
||||||
|
{
|
||||||
class PaypalController extends Controller {
|
|
||||||
|
|
||||||
private $_apiContext;
|
private $_apiContext;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
public function __construct()
|
{
|
||||||
{
|
$this->_apiContext = Paypal::ApiContext(
|
||||||
$this->_apiContext = PayPal::ApiContext(
|
config('services.paypal.client_id'),
|
||||||
config('services.paypal.client_id'),
|
config('services.paypal.secret')
|
||||||
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(
|
$this->_apiContext->setConfig(array(
|
||||||
'mode' => 'live',
|
'mode' => 'sandbox',
|
||||||
'service.EndPoint' => 'https://api.paypal.com',
|
'service.EndPoint' => 'https://api.sandbox.paypal.com',
|
||||||
'http.ConnectionTimeOut' => 30,
|
'http.ConnectionTimeOut' => 30,
|
||||||
'log.LogEnabled' => true,
|
'log.LogEnabled' => true,
|
||||||
'log.FileName' => storage_path('logs/paypal.log'),
|
'log.FileName' => storage_path('logs/paypal.log'),
|
||||||
'log.LogLevel' => 'FINE'
|
'log.LogLevel' => 'FINE'
|
||||||
));
|
));
|
||||||
}
|
|
||||||
|
// live
|
||||||
|
// $this->_apiContext->setConfig(array(
|
||||||
|
// 'mode' => 'live',
|
||||||
|
// 'service.EndPoint' => 'https://api.paypal.com',
|
||||||
|
// 'http.ConnectionTimeOut' => 30,
|
||||||
|
// 'log.LogEnabled' => true,
|
||||||
|
// 'log.FileName' => storage_path('logs/paypal.log'),
|
||||||
|
// 'log.LogLevel' => 'FINE'
|
||||||
|
// ));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function payPremium()
|
public function payPremium()
|
||||||
{
|
{
|
||||||
return view('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);
|
Session::flash('msg', $message);
|
||||||
return Redirect::back();
|
return Redirect::back();
|
||||||
}
|
}
|
||||||
|
|
||||||
$payer = PayPal::Payer();
|
$payer = PayPal::Payer();
|
||||||
$payer->setPaymentMethod('paypal');
|
$payer->setPaymentMethod('paypal');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$m = new TeamStoreModel;
|
$m = new TeamStoreModel;
|
||||||
$paypal_model = new PayPalModel;
|
$paypal_model = new PayPalModel;
|
||||||
$last_id = $paypal_model->getLastIdPaymentDetails();
|
$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');
|
$cartKey = $request->session()->get('cartkey');
|
||||||
|
|
||||||
$items = $m->myCart($cartKey);
|
$items = $m->myCart($cartKey);
|
||||||
|
|
||||||
$getSubtotal = $m->getSubtotal($cartKey);
|
$getSubtotal = $m->getSubtotal($cartKey);
|
||||||
$grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey);
|
$grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey);
|
||||||
$store_array = $m->selectTeamStore('Id', $grouped_item[0]->StoreId);
|
$store_array = $m->selectTeamStore('Id', $grouped_item[0]->StoreId);
|
||||||
|
$shipping_charges = 0;
|
||||||
|
|
||||||
|
foreach ($items as $item) {
|
||||||
foreach($items as $item){
|
if ($item->VoucherId != null) {
|
||||||
if($item->VoucherId != null){
|
|
||||||
$voucherIds[] = $item->VoucherId;
|
$voucherIds[] = $item->VoucherId;
|
||||||
$voucher = $m->selectVoucherWhereIn($voucherIds);
|
$voucher = $m->selectVoucherWhereIn($voucherIds);
|
||||||
$item_id = $item->Id;
|
$item_id = $item->Id;
|
||||||
$totalValue = $voucher[0]->VoucherValue;
|
$totalValue = $voucher[0]->VoucherValue;
|
||||||
if($voucher[0]->VoucherType == "Percentage"){
|
if ($voucher[0]->VoucherType == "Percentage") {
|
||||||
$getPercentageValue = $totalValue / 100;
|
$getPercentageValue = $totalValue / 100;
|
||||||
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
|
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
|
||||||
$data = array(
|
$data = array(
|
||||||
'Price' => round($getDiscountValue * -1, 2)
|
'Price' => round($getDiscountValue * -1, 2)
|
||||||
);
|
);
|
||||||
|
|
||||||
$m->updateVoucherValueInCart($data, $item_id);
|
$m->updateVoucherValueInCart($data, $item_id);
|
||||||
}else{
|
} else {
|
||||||
$voucherData = array(
|
$voucherData = array(
|
||||||
'totalValue'=> $totalValue,
|
'totalValue' => $totalValue,
|
||||||
'type'=>'Flat'
|
'type' => 'Flat'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$shipping_charges += $item->ShippingFee * $item->Quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
$order_items = array();
|
$order_items = array();
|
||||||
@@ -111,19 +114,19 @@ class PaypalController extends Controller {
|
|||||||
|
|
||||||
// $order_subtotal = $updated_getSubtotal[0]->Subtotal;
|
// $order_subtotal = $updated_getSubtotal[0]->Subtotal;
|
||||||
$order_grandtotal = $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){
|
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) {
|
||||||
$tax_value = 0;
|
$tax_value = 0;
|
||||||
}else{
|
} else {
|
||||||
$tax_value = 0.10;
|
$tax_value = 0.10;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tax = $order_grandtotal * $tax_value;
|
$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;"?"
|
// $descriptions = "Name: " . $item->Name . " Number: " . $item->Number . " Size: " . $item->Size;"?"
|
||||||
|
|
||||||
$order_items[$key] = PayPal::Item();
|
$order_items[$key] = PayPal::Item();
|
||||||
$order_items[$key]->setName($item->ProductName);
|
$order_items[$key]->setName($item->ProductName);
|
||||||
$order_items[$key]->setCurrency($store_array[0]->StoreCurrency);
|
$order_items[$key]->setCurrency($store_array[0]->StoreCurrency);
|
||||||
@@ -131,44 +134,45 @@ class PaypalController extends Controller {
|
|||||||
// $order_items[$key]->setDescription($descriptions);
|
// $order_items[$key]->setDescription($descriptions);
|
||||||
// $order_items[$key]->setTax(10);
|
// $order_items[$key]->setTax(10);
|
||||||
$order_items[$key]->setPrice($item->Price);
|
$order_items[$key]->setPrice($item->Price);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$item_list = PayPal::ItemList();
|
$item_list = PayPal::ItemList();
|
||||||
$item_list->setItems($order_items);
|
$item_list->setItems($order_items);
|
||||||
|
|
||||||
$amount_details = PayPal::Details();
|
$amount_details = PayPal::Details();
|
||||||
$amount_details->setSubtotal($order_grandtotal);
|
$amount_details->setSubtotal($order_grandtotal);
|
||||||
$amount_details->setTax($tax);
|
$amount_details->setTax($tax);
|
||||||
|
$amount_details->setShipping($shipping_charges);
|
||||||
|
|
||||||
$amount = PayPal::Amount();
|
$amount = PayPal::Amount();
|
||||||
$amount->setCurrency($store_array[0]->StoreCurrency);
|
$amount->setCurrency($store_array[0]->StoreCurrency);
|
||||||
$amount->setDetails($amount_details);
|
$amount->setDetails($amount_details);
|
||||||
$amount->setTotal($order_grandtotal + $tax);
|
$amount->setTotal($order_grandtotal + $tax + $shipping_charges);
|
||||||
|
|
||||||
$transaction = PayPal::Transaction();
|
$transaction = PayPal::Transaction();
|
||||||
$transaction->setAmount($amount);
|
$transaction->setAmount($amount);
|
||||||
$transaction->setItemList($item_list);
|
$transaction->setItemList($item_list);
|
||||||
|
|
||||||
// $transaction->setDescription('Your transaction description');
|
// $transaction->setDescription('Your transaction description');
|
||||||
$transaction->setInvoiceNumber(date('Ymd') . '-' . $invoice_num);
|
$transaction->setInvoiceNumber(date('Ymd') . '-' . $invoice_num);
|
||||||
|
|
||||||
$redirectUrls = PayPal:: RedirectUrls();
|
$redirectUrls = PayPal::RedirectUrls();
|
||||||
$redirectUrls->setReturnUrl(route('getDone'));
|
$redirectUrls->setReturnUrl(route('getDone'));
|
||||||
$redirectUrls->setCancelUrl(route('getCancel'));
|
$redirectUrls->setCancelUrl(route('getCancel'));
|
||||||
|
|
||||||
|
|
||||||
$payment = PayPal::Payment();
|
$payment = PayPal::Payment();
|
||||||
$payment->setIntent('sale');
|
$payment->setIntent('sale');
|
||||||
$payment->setPayer($payer);
|
$payment->setPayer($payer);
|
||||||
$payment->setRedirectUrls($redirectUrls);
|
$payment->setRedirectUrls($redirectUrls);
|
||||||
$payment->setTransactions(array($transaction));
|
$payment->setTransactions(array($transaction));
|
||||||
|
|
||||||
|
|
||||||
$response = $payment->create($this->_apiContext);
|
$response = $payment->create($this->_apiContext);
|
||||||
$redirectUrl = $response->links[1]->href;
|
$redirectUrl = $response->links[1]->href;
|
||||||
|
|
||||||
|
|
||||||
return redirect()->to( $redirectUrl );
|
return redirect()->to($redirectUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDoneTest()
|
public function getDoneTest()
|
||||||
@@ -193,42 +197,49 @@ class PaypalController extends Controller {
|
|||||||
// echo $ex;
|
// echo $ex;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDone(Request $request)
|
public function getDone(Request $request)
|
||||||
{
|
{
|
||||||
$id = $request->get('paymentId');
|
$id = $request->get('paymentId');
|
||||||
$token = $request->get('token');
|
$token = $request->get('token');
|
||||||
$payer_id = $request->get('PayerID');
|
$payer_id = $request->get('PayerID');
|
||||||
|
|
||||||
|
|
||||||
$payment = PayPal::getById($id, $this->_apiContext);
|
$payment = PayPal::getById($id, $this->_apiContext);
|
||||||
|
|
||||||
$paymentExecution = PayPal::PaymentExecution();
|
$paymentExecution = PayPal::PaymentExecution();
|
||||||
|
|
||||||
$paymentExecution->setPayerId($payer_id);
|
$paymentExecution->setPayerId($payer_id);
|
||||||
$executePayment = $payment->execute($paymentExecution, $this->_apiContext);
|
$executePayment = $payment->execute($paymentExecution, $this->_apiContext);
|
||||||
|
|
||||||
// print_r($executePayment);
|
// print_r($executePayment);
|
||||||
// if ($executePayment->getState() == 'approved') {
|
// 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');
|
// // return Redirect::route('paywithpaypal');
|
||||||
// echo 'Payment success';
|
// echo 'Payment success';
|
||||||
// }
|
// }
|
||||||
$obj = json_decode($executePayment);
|
$obj = json_decode($executePayment);
|
||||||
|
|
||||||
|
|
||||||
$line2 = null;
|
$line2 = null;
|
||||||
|
|
||||||
//details
|
//details
|
||||||
$total = $obj->transactions[0]->amount->total;
|
$total = $obj->transactions[0]->amount->total;
|
||||||
$sub_total = $obj->transactions[0]->amount->details->subtotal;
|
$sub_total = $obj->transactions[0]->amount->details->subtotal;
|
||||||
$tax = $obj->transactions[0]->amount->details->tax;
|
$tax = $obj->transactions[0]->amount->details->tax;
|
||||||
|
$shipping_cost = $obj->transactions[0]->amount->details->shipping;
|
||||||
|
|
||||||
|
$relatedResources = $obj->transactions[0]->related_resources[0];
|
||||||
|
$saleId = $relatedResources->sale->id; // transaction_id
|
||||||
|
//
|
||||||
|
// $sale = $relatedResources[0]->getSale();
|
||||||
|
// echo $saleId = $sale->getId();
|
||||||
|
|
||||||
$currency = $obj->transactions[0]->amount->currency;
|
$currency = $obj->transactions[0]->amount->currency;
|
||||||
$invoice_number = $obj->transactions[0]->invoice_number;
|
$invoice_number = $obj->transactions[0]->invoice_number;
|
||||||
@@ -236,7 +247,7 @@ class PaypalController extends Controller {
|
|||||||
//shipping address details
|
//shipping address details
|
||||||
$recipient_name = $obj->transactions[0]->item_list->shipping_address->recipient_name;
|
$recipient_name = $obj->transactions[0]->item_list->shipping_address->recipient_name;
|
||||||
$line1 = $obj->transactions[0]->item_list->shipping_address->line1;
|
$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;
|
$line2 = $obj->transactions[0]->item_list->shipping_address->line2;
|
||||||
}
|
}
|
||||||
$city = $obj->transactions[0]->item_list->shipping_address->city;
|
$city = $obj->transactions[0]->item_list->shipping_address->city;
|
||||||
@@ -250,7 +261,7 @@ class PaypalController extends Controller {
|
|||||||
$first_name = $obj->payer->payer_info->first_name;
|
$first_name = $obj->payer->payer_info->first_name;
|
||||||
$last_name = $obj->payer->payer_info->last_name;
|
$last_name = $obj->payer->payer_info->last_name;
|
||||||
$_payer_id = $obj->payer->payer_info->payer_id;
|
$_payer_id = $obj->payer->payer_info->payer_id;
|
||||||
|
|
||||||
/// end paypal codes
|
/// end paypal codes
|
||||||
|
|
||||||
$paypal_model = new PayPalModel;
|
$paypal_model = new PayPalModel;
|
||||||
@@ -263,23 +274,23 @@ class PaypalController extends Controller {
|
|||||||
$getSubtotal = $m->getSubtotal($cartKey);
|
$getSubtotal = $m->getSubtotal($cartKey);
|
||||||
|
|
||||||
$payment_details = array(
|
$payment_details = array(
|
||||||
|
'UserId' => $userId,
|
||||||
'UserId' => $userId,
|
'CartKey' => $cartKey,
|
||||||
'CartKey' => $cartKey,
|
'PaymentId' => $id,
|
||||||
'PaymentId' => $id,
|
'Token' => $token,
|
||||||
'Token' => $token,
|
'PayerId' => $payer_id,
|
||||||
'PayerId' => $payer_id,
|
'InvoiceNumber' => $invoice_number,
|
||||||
'InvoiceNumber' => $invoice_number,
|
'Currency' => $currency,
|
||||||
'Currency' => $currency,
|
'Total' => $total,
|
||||||
'Total' => $total,
|
'SubTotal' => $sub_total,
|
||||||
'SubTotal' => $sub_total,
|
'Tax' => $tax,
|
||||||
'Tax' => $tax,
|
'Payer_Email' => $email,
|
||||||
'Payer_Email' => $email,
|
'Payer_Firstname' => $first_name,
|
||||||
'Payer_Firstname' => $first_name,
|
'Payer_Lastname' => $last_name,
|
||||||
'Payer_Lastname' => $last_name,
|
'PaymentMethod' => $payment_method,
|
||||||
'PaymentMethod' =>$payment_method
|
'ShippingCost' => $shipping_cost,
|
||||||
|
'TransactionId' => $saleId,
|
||||||
);
|
);
|
||||||
|
|
||||||
$p_id = $paypal_model->insertToPaypalDetails($payment_details);
|
$p_id = $paypal_model->insertToPaypalDetails($payment_details);
|
||||||
|
|
||||||
@@ -295,7 +306,7 @@ class PaypalController extends Controller {
|
|||||||
);
|
);
|
||||||
// iinsert shipping address
|
// iinsert shipping address
|
||||||
$paypal_model->insertShippingAddress($shipping_address);
|
$paypal_model->insertShippingAddress($shipping_address);
|
||||||
|
|
||||||
// insert order from cart_tmp to orders table
|
// insert order from cart_tmp to orders table
|
||||||
$l = $paypal_model->insertToOrders($cartKey); // insert to orders table
|
$l = $paypal_model->insertToOrders($cartKey); // insert to orders table
|
||||||
|
|
||||||
@@ -306,31 +317,32 @@ class PaypalController extends Controller {
|
|||||||
$item_thumbs = $newUserModel->selectDisplayItemThumb();
|
$item_thumbs = $newUserModel->selectDisplayItemThumb();
|
||||||
$array_payment_details = $newUserModel->selectPaymentDetails('CartKey', $cartKey);
|
$array_payment_details = $newUserModel->selectPaymentDetails('CartKey', $cartKey);
|
||||||
$array_storename = $newUserModel->selectTeamStoreName($cartKey); // email subject
|
$array_storename = $newUserModel->selectTeamStoreName($cartKey); // email subject
|
||||||
|
|
||||||
|
|
||||||
foreach($array_storename as $storname){
|
foreach ($array_storename as $storname) {
|
||||||
|
|
||||||
$sName[] = $storname->StoreName;
|
$sName[] = $storname->StoreName;
|
||||||
$sid[] = $storname->Id;
|
$sid[] = $storname->Id;
|
||||||
}
|
}
|
||||||
$sName = implode (", ", $sName);
|
$sName = implode(", ", $sName);
|
||||||
|
|
||||||
|
|
||||||
$user_loginsArray = $newUserModel->selectUserLoginsWhereIn($sid);
|
$user_loginsArray = $newUserModel->selectUserLoginsWhereIn($sid);
|
||||||
|
|
||||||
foreach($user_loginsArray as $userdata){
|
foreach ($user_loginsArray as $userdata) {
|
||||||
|
|
||||||
$other_email[] = $userdata->other_email;
|
$other_email[] = $userdata->other_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($other_email[0] != null){
|
if ($other_email[0] != null) {
|
||||||
$other_email = implode (", ", $other_email);
|
$other_email = implode(", ", $other_email);
|
||||||
$email_cc = "orders@crewsportswear.com" . "," . $other_email;
|
$email_cc = "orders@crewsportswear.com" . "," . $other_email;
|
||||||
}else{
|
} else {
|
||||||
$email_cc = "orders@crewsportswear.com";
|
$email_cc = "orders@crewsportswear.com";
|
||||||
}
|
}
|
||||||
|
|
||||||
$explode_other_email = explode(",", $email_cc);
|
// $explode_other_email = explode(",", $email_cc);
|
||||||
|
$explode_other_email = "orders@crewsportswear.com"; // test_email
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'order_item_array' => $order_item_array,
|
'order_item_array' => $order_item_array,
|
||||||
@@ -341,16 +353,17 @@ class PaypalController extends Controller {
|
|||||||
'email_cc' => $explode_other_email,
|
'email_cc' => $explode_other_email,
|
||||||
'subject' => $sName . ' ORDERS',
|
'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->from('no-reply@crewsportswear.com', 'CREW Sportswear');
|
||||||
$message->bcc($data['email_cc'], 'Orders From CREW Sportswear');
|
$message->bcc($data['email_cc'], 'Orders From CREW Sportswear');
|
||||||
$message->to($data['receiver'])->subject($data['subject']);
|
$message->to($data['receiver'])->subject($data['subject']);
|
||||||
});
|
});
|
||||||
// end email sending
|
|
||||||
|
|
||||||
$request->session()->forget('cartkey'); // clear session for cartkey
|
|
||||||
|
|
||||||
|
// end email sending
|
||||||
|
$m->delete_cartTmp("CartKey", $cartKey);
|
||||||
|
$request->session()->forget('cartkey'); // clear session for cartkey
|
||||||
|
|
||||||
// redirect to thank you page.
|
// redirect to thank you page.
|
||||||
return view('paypal.get_done')
|
return view('paypal.get_done')
|
||||||
->with('currency', $currency)
|
->with('currency', $currency)
|
||||||
@@ -363,31 +376,30 @@ class PaypalController extends Controller {
|
|||||||
{
|
{
|
||||||
$m = new TeamStoreModel;
|
$m = new TeamStoreModel;
|
||||||
$cartKey = $request->session()->get('cartkey');
|
$cartKey = $request->session()->get('cartkey');
|
||||||
|
|
||||||
$items = $m->myCart($cartKey);
|
$items = $m->myCart($cartKey);
|
||||||
$getSubtotal = $m->getSubtotal($cartKey);
|
$getSubtotal = $m->getSubtotal($cartKey);
|
||||||
|
|
||||||
foreach($items as $item){
|
foreach ($items as $item) {
|
||||||
if($item->VoucherId != null){
|
if ($item->VoucherId != null) {
|
||||||
$voucherIds[] = $item->VoucherId;
|
$voucherIds[] = $item->VoucherId;
|
||||||
$voucher = $m->selectVoucherWhereIn($voucherIds);
|
$voucher = $m->selectVoucherWhereIn($voucherIds);
|
||||||
$item_id = $item->Id;
|
$item_id = $item->Id;
|
||||||
$totalValue = $voucher[0]->VoucherValue;
|
$totalValue = $voucher[0]->VoucherValue;
|
||||||
if($voucher[0]->VoucherType == "Percentage"){
|
if ($voucher[0]->VoucherType == "Percentage") {
|
||||||
$data = array(
|
$data = array(
|
||||||
'Price' => '00.00'
|
'Price' => '00.00'
|
||||||
);
|
);
|
||||||
$m->updateVoucherValueInCart($data, $item_id);
|
$m->updateVoucherValueInCart($data, $item_id);
|
||||||
}else{
|
} else {
|
||||||
$voucherData = array(
|
$voucherData = array(
|
||||||
'totalValue'=> $totalValue,
|
'totalValue' => $totalValue,
|
||||||
'type'=>'Flat'
|
'type' => 'Flat'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->route('cart');
|
return redirect()->route('cart');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Http\Controllers\teamstore;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\teamstore;
|
||||||
|
|
||||||
use App\Http\Requests;
|
use App\Http\Requests;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
@@ -11,8 +13,9 @@ use Mail;
|
|||||||
use Analytics;
|
use Analytics;
|
||||||
|
|
||||||
|
|
||||||
class TeamStoreController extends Controller {
|
class TeamStoreController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
public function index(Request $request, $teamStoreURL)
|
public function index(Request $request, $teamStoreURL)
|
||||||
{
|
{
|
||||||
// var_dump($teamStoreURL);
|
// var_dump($teamStoreURL);
|
||||||
@@ -20,71 +23,69 @@ class TeamStoreController extends Controller {
|
|||||||
$store_array = $m->selectTeamStore('StoreUrl', $teamStoreURL);
|
$store_array = $m->selectTeamStore('StoreUrl', $teamStoreURL);
|
||||||
$product_array = $m->selectTeamStoreProducts('TeamStoreId', $store_array[0]->Id);
|
$product_array = $m->selectTeamStoreProducts('TeamStoreId', $store_array[0]->Id);
|
||||||
$user_role = '';
|
$user_role = '';
|
||||||
|
|
||||||
if (Auth::check()){
|
if (Auth::check()) {
|
||||||
$user_role = Auth::user()->role;
|
$user_role = Auth::user()->role;
|
||||||
$store_id = Auth::user()->store_id;
|
$store_id = Auth::user()->store_id;
|
||||||
}else{
|
} else {
|
||||||
$user_role = null;
|
$user_role = null;
|
||||||
$store_id = null;
|
$store_id = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($store_array[0]->Password != null){
|
|
||||||
if($request->session()->get('teamstore_data_array') == null){
|
if ($store_array[0]->Password != null) {
|
||||||
if($store_id != $store_array[0]->Id){
|
if ($request->session()->get('teamstore_data_array') == null) {
|
||||||
|
if ($store_id != $store_array[0]->Id) {
|
||||||
return redirect('teamstore');
|
return redirect('teamstore');
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
|
|
||||||
if($user_role != "store_owner"){
|
if ($user_role != "store_owner") {
|
||||||
if($request->session()->get('teamstore_data_array')[0]->StoreUrl != $store_array[0]->StoreUrl){
|
if ($request->session()->get('teamstore_data_array')[0]->StoreUrl != $store_array[0]->StoreUrl) {
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach ($product_array as $p => $pr_arr) {
|
foreach ($product_array as $p => $pr_arr) {
|
||||||
|
|
||||||
$thumbnails_array = $m->getProductThumbnails($pr_arr->Id);
|
$thumbnails_array = $m->getProductThumbnails($pr_arr->Id);
|
||||||
if(!empty($thumbnails_array)){
|
if (!empty($thumbnails_array)) {
|
||||||
foreach ($thumbnails_array as $t => $thumb) {
|
foreach ($thumbnails_array as $t => $thumb) {
|
||||||
|
|
||||||
if($thumb->ImageClass == 'custom'){
|
if ($thumb->ImageClass == 'custom') {
|
||||||
$displayThumbnails = $thumb->Image;
|
$displayThumbnails = $thumb->Image;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($thumb->ImageClass == 'active'){
|
if ($thumb->ImageClass == 'active') {
|
||||||
$displayThumbnails = $thumb->Image;
|
$displayThumbnails = $thumb->Image;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$thumbnails[] = array(
|
$thumbnails[] = array(
|
||||||
'folder' => $store_array[0]->ImageFolder,
|
'folder' => $store_array[0]->ImageFolder,
|
||||||
'product_id' => $pr_arr->Id,
|
'product_id' => $pr_arr->Id,
|
||||||
'thumb' => $displayThumbnails
|
'thumb' => $displayThumbnails
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
}else{
|
);
|
||||||
|
} else {
|
||||||
$thumbnails[] = array(
|
$thumbnails[] = array(
|
||||||
'folder' => $store_array[0]->ImageFolder,
|
'folder' => $store_array[0]->ImageFolder,
|
||||||
'product_id' => $pr_arr->Id,
|
'product_id' => $pr_arr->Id,
|
||||||
'thumb' => "product-image-placeholder.png"
|
'thumb' => "product-image-placeholder.png"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// var_dump($thumbnails);
|
// var_dump($thumbnails);
|
||||||
return view('teamstore-sublayouts.index')
|
return view('teamstore-sublayouts.index')
|
||||||
->with('store_array', $store_array)
|
->with('store_array', $store_array)
|
||||||
->with('product_array', $product_array)
|
->with('product_array', $product_array)
|
||||||
->with('thumbnails', $thumbnails);
|
->with('thumbnails', $thumbnails);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function storelist(Request $request)
|
public function storelist(Request $request)
|
||||||
@@ -99,54 +100,53 @@ class TeamStoreController extends Controller {
|
|||||||
|
|
||||||
// foreach($teamstore as $t){
|
// foreach($teamstore as $t){
|
||||||
// $sad = explode('/', $t);
|
// $sad = explode('/', $t);
|
||||||
|
|
||||||
// if(count($sad) == 4){
|
// if(count($sad) == 4){
|
||||||
// $arr_teamstore[] = explode('?', $sad['3'])['0'];
|
// $arr_teamstore[] = explode('?', $sad['3'])['0'];
|
||||||
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// var_dump(array_unique($arr_teamstore));
|
// var_dump(array_unique($arr_teamstore));
|
||||||
|
|
||||||
$m = new TeamStoreModel;
|
$m = new TeamStoreModel;
|
||||||
$q = $request->input('q');
|
$q = $request->input('q');
|
||||||
$sort = $request->input('s');
|
$sort = $request->input('s');
|
||||||
|
|
||||||
if(isset($q) && isset($sort)){
|
if (isset($q) && isset($sort)) {
|
||||||
|
|
||||||
if($sort == "latest"){
|
if ($sort == "latest") {
|
||||||
$field = "Id";
|
$field = "Id";
|
||||||
$sort_value = "DESC";
|
|
||||||
}elseif($sort == "al-desc"){
|
|
||||||
$field = "StoreName";
|
|
||||||
$sort_value = "DESC";
|
$sort_value = "DESC";
|
||||||
}elseif($sort == "oldest"){
|
} elseif ($sort == "al-desc") {
|
||||||
|
$field = "StoreName";
|
||||||
|
$sort_value = "DESC";
|
||||||
|
} elseif ($sort == "oldest") {
|
||||||
$field = "Id";
|
$field = "Id";
|
||||||
$sort_value = "ASC";
|
$sort_value = "ASC";
|
||||||
}else{
|
} else {
|
||||||
$field = "StoreName";
|
$field = "StoreName";
|
||||||
$sort_value = "ASC";
|
$sort_value = "ASC";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($q != ""){
|
|
||||||
// keyword and sort
|
|
||||||
$stores_array = $m->selectTeamstoreSearch($field, $sort_value, $q);
|
|
||||||
}else{
|
|
||||||
// sort only
|
|
||||||
$stores_array = $m->selectTeamstoreFilter($field, $sort_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
if ($q != "") {
|
||||||
|
// keyword and sort
|
||||||
|
$stores_array = $m->selectTeamstoreSearch($field, $sort_value, $q);
|
||||||
|
} else {
|
||||||
|
// sort only
|
||||||
|
$stores_array = $m->selectTeamstoreFilter($field, $sort_value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$field = "StoreName";
|
$field = "StoreName";
|
||||||
$sort_value = "ASC";
|
$sort_value = "ASC";
|
||||||
$sort = "al-asc";
|
$sort = "al-asc";
|
||||||
$stores_array = $m->selectTeamstoreFilter($field, $sort_value);
|
$stores_array = $m->selectTeamstoreFilter($field, $sort_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('teamstore-sublayouts.stores')
|
return view('teamstore-sublayouts.stores')
|
||||||
->with('stores_array', $stores_array)
|
->with('stores_array', $stores_array)
|
||||||
->with('keyword', $q)
|
->with('keyword', $q)
|
||||||
->with('filter', $sort);
|
->with('filter', $sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkTeamStorePassword(Request $request)
|
public function checkTeamStorePassword(Request $request)
|
||||||
@@ -155,82 +155,78 @@ class TeamStoreController extends Controller {
|
|||||||
$post = $request->all();
|
$post = $request->all();
|
||||||
$store_array = $m->selectTeamStore('Password', $post['password']);
|
$store_array = $m->selectTeamStore('Password', $post['password']);
|
||||||
|
|
||||||
if($store_array){
|
if ($store_array) {
|
||||||
$request->session()->put('teamstore_data_array', $store_array);
|
$request->session()->put('teamstore_data_array', $store_array);
|
||||||
return redirect('teamstore/'. $store_array[0]->StoreUrl);
|
return redirect('teamstore/' . $store_array[0]->StoreUrl);
|
||||||
|
} else {
|
||||||
}else{
|
return redirect()->back()->with('errors', 'Invalid Password.');
|
||||||
return redirect()->back()->with('errors', 'Invalid Password.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private $teams_array;
|
private $teams_array;
|
||||||
|
|
||||||
public function productDetails($teamStoreURL, $productURL)
|
public function productDetails($teamStoreURL, $productURL)
|
||||||
{
|
{
|
||||||
$m = new TeamStoreModel;
|
$m = new TeamStoreModel;
|
||||||
$teams_array = array();
|
$teams_array = array();
|
||||||
$store_array = $m->selectTeamStore('StoreUrl', $teamStoreURL);
|
$store_array = $m->selectTeamStore('StoreUrl', $teamStoreURL);
|
||||||
$product_array = $m->selectTeamStoreProducts('ProductURL', $productURL);
|
$product_array = $m->selectTeamStoreProducts('ProductURL', $productURL);
|
||||||
|
|
||||||
$thumbnails_array = $m->getThumbnails($product_array[0]->Id);
|
$thumbnails_array = $m->getThumbnails($product_array[0]->Id);
|
||||||
$teams_array = $m->getTeams($product_array[0]->Id);
|
$teams_array = $m->getTeams($product_array[0]->Id);
|
||||||
// $sizes_array = $m->getSizes();
|
// $sizes_array = $m->getSizes();
|
||||||
|
|
||||||
if(empty($thumbnails_array)){
|
if (empty($thumbnails_array)) {
|
||||||
|
|
||||||
$data = (object) array(
|
$data = (object) array(
|
||||||
'Image' => 'product-image-placeholder.png',
|
'Image' => 'product-image-placeholder.png',
|
||||||
'ImageClass' => 'active'
|
'ImageClass' => 'active'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$thumbnails_array[] = $data;
|
$thumbnails_array[] = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$x = explode(",", $product_array[0]->AvailableSizes );
|
|
||||||
foreach($x as $s){
|
$x = explode(",", $product_array[0]->AvailableSizes);
|
||||||
|
foreach ($x as $s) {
|
||||||
$h[] = $m->getSizesByBracket($s);
|
$h[] = $m->getSizesByBracket($s);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($h as $d){
|
foreach ($h as $d) {
|
||||||
foreach($d as $g){
|
foreach ($d as $g) {
|
||||||
$sizes_array[] = $g;
|
$sizes_array[] = $g;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($product_array[0]->ProductAvailableQty != null){
|
if ($product_array[0]->ProductAvailableQty != null) {
|
||||||
$soldQty = $m->getSoldQty($product_array[0]->Id);
|
$soldQty = $m->getSoldQty($product_array[0]->Id);
|
||||||
$availableQty = $product_array[0]->ProductAvailableQty - $soldQty[0]->SoldQty;
|
$availableQty = $product_array[0]->ProductAvailableQty - $soldQty[0]->SoldQty;
|
||||||
}else{
|
} else {
|
||||||
// echo 'no qty';
|
// echo 'no qty';
|
||||||
$availableQty = null;
|
$availableQty = null;
|
||||||
}
|
}
|
||||||
// $product_array[0]->ProductAvailableQty
|
// $product_array[0]->ProductAvailableQty
|
||||||
|
|
||||||
return view('teamstore-sublayouts.product-details')
|
return view('teamstore-sublayouts.product-details')
|
||||||
->with('store_array', $store_array)
|
->with('store_array', $store_array)
|
||||||
->with('product_array', $product_array)
|
->with('product_array', $product_array)
|
||||||
->with('thumbnails_array', $thumbnails_array)
|
->with('thumbnails_array', $thumbnails_array)
|
||||||
->with('teams_array', $teams_array)
|
->with('teams_array', $teams_array)
|
||||||
->with('sizes_array', $sizes_array)
|
->with('sizes_array', $sizes_array)
|
||||||
->with('available_qty', $availableQty);
|
->with('available_qty', $availableQty);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function login(Request $request)
|
public function login(Request $request)
|
||||||
{
|
{
|
||||||
return view('teamstore-sublayouts.login');
|
return view('teamstore-sublayouts.login');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clearSession(Request $request)
|
public function clearSession(Request $request)
|
||||||
{
|
{
|
||||||
$request->session()->forget('teamstore_data_array');
|
$request->session()->forget('teamstore_data_array');
|
||||||
return redirect("{{ url('/') }}");
|
return redirect("{{ url('/') }}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addNewRow(Request $request)
|
public function addNewRow(Request $request)
|
||||||
{
|
{
|
||||||
$post = $request->all();
|
$post = $request->all();
|
||||||
@@ -239,47 +235,45 @@ class TeamStoreController extends Controller {
|
|||||||
$item = $TeamStoreModel->selectTeamStoreProductByIdHash($post['p_id']);
|
$item = $TeamStoreModel->selectTeamStoreProductByIdHash($post['p_id']);
|
||||||
$x = explode(",", $item[0]->AvailableSizes);
|
$x = explode(",", $item[0]->AvailableSizes);
|
||||||
|
|
||||||
foreach($x as $s){
|
foreach ($x as $s) {
|
||||||
$h[] = $TeamStoreModel->getSizesByBracket($s);
|
$h[] = $TeamStoreModel->getSizesByBracket($s);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($h as $d){
|
foreach ($h as $d) {
|
||||||
foreach($d as $g){
|
foreach ($d as $g) {
|
||||||
$sizes_array[] = $g;
|
$sizes_array[] = $g;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($item[0]->ProductAvailableQty != null){
|
if ($item[0]->ProductAvailableQty != null) {
|
||||||
$soldQty = $m->getSoldQty($product_array[0]->Id);
|
$soldQty = $m->getSoldQty($product_array[0]->Id);
|
||||||
$availableQty = $item[0]->ProductAvailableQty - $soldQty[0]->SoldQty;
|
$availableQty = $item[0]->ProductAvailableQty - $soldQty[0]->SoldQty;
|
||||||
}else{
|
} else {
|
||||||
// echo 'no qty';
|
// echo 'no qty';
|
||||||
$availableQty = null;
|
$availableQty = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$handle_form = view('teamstore-sublayouts.forms.' . $item[0]->ProductForm )
|
$handle_form = view('teamstore-sublayouts.forms.' . $item[0]->ProductForm)
|
||||||
->with('sizes_array', $sizes_array)
|
->with('sizes_array', $sizes_array)
|
||||||
->with('availableQty', $availableQty)
|
->with('availableQty', $availableQty)
|
||||||
->render();
|
->render();
|
||||||
|
|
||||||
return $handle_form;
|
return $handle_form;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addToCart(Request $request)
|
public function addToCart(Request $request)
|
||||||
{
|
{
|
||||||
$post = $request->all();
|
$post = $request->all();
|
||||||
$m = new TeamStoreModel;
|
$m = new TeamStoreModel;
|
||||||
$hash_product_id = $post['p_id'];
|
$hash_product_id = $post['p_id'];
|
||||||
|
|
||||||
if($request->session()->has('cartkey')){
|
if ($request->session()->has('cartkey')) {
|
||||||
$cartKey = $request->session()->get('cartkey');
|
$cartKey = $request->session()->get('cartkey');
|
||||||
}else{
|
} else {
|
||||||
$request->session()->put('cartkey', sha1(time() . str_random(6)));
|
$request->session()->put('cartkey', sha1(time() . str_random(6)));
|
||||||
$cartKey = $cartKey = $request->session()->get('cartkey');
|
$cartKey = $cartKey = $request->session()->get('cartkey');
|
||||||
}
|
}
|
||||||
|
|
||||||
$product_array = $m->selectTeamStoreProductByIdHash($hash_product_id);
|
$product_array = $m->selectTeamStoreProductByIdHash($hash_product_id);
|
||||||
$product_id = $product_array[0]->Id;
|
$product_id = $product_array[0]->Id;
|
||||||
$TeamStoreId = $product_array[0]->TeamStoreId;
|
$TeamStoreId = $product_array[0]->TeamStoreId;
|
||||||
@@ -287,27 +281,28 @@ class TeamStoreController extends Controller {
|
|||||||
$ProductURL = $product_array[0]->ProductURL;
|
$ProductURL = $product_array[0]->ProductURL;
|
||||||
$product_form = $product_array[0]->ProductForm;
|
$product_form = $product_array[0]->ProductForm;
|
||||||
$design_code = $product_array[0]->DesignCode;
|
$design_code = $product_array[0]->DesignCode;
|
||||||
$product_name = $product_array[0]->ProductName;
|
$product_name = $product_array[0]->ProductName;
|
||||||
|
$shipping_fee = $product_array[0]->ShippingFee;
|
||||||
|
|
||||||
$teamstore_array = $m->selectTeamStore('Id', $TeamStoreId);
|
$teamstore_array = $m->selectTeamStore('Id', $TeamStoreId);
|
||||||
|
|
||||||
$store_url = $teamstore_array[0]->StoreUrl;
|
$store_url = $teamstore_array[0]->StoreUrl;
|
||||||
$store_id = $teamstore_array[0]->Id;
|
$store_id = $teamstore_array[0]->Id;
|
||||||
|
|
||||||
if($product_form == "jersey-and-shorts-form"){
|
if ($product_form == "jersey-and-shorts-form") {
|
||||||
$order_names = $post['order_names'];
|
$order_names = $post['order_names'];
|
||||||
$order_number = $post['order_number'];
|
$order_number = $post['order_number'];
|
||||||
$order_jersey_size = $post['order_jersey_size'];
|
$order_jersey_size = $post['order_jersey_size'];
|
||||||
$order_shorts_size = $post['order_shorts_size'];
|
$order_shorts_size = $post['order_shorts_size'];
|
||||||
|
|
||||||
foreach($order_names as $key => $val){
|
foreach ($order_names as $key => $val) {
|
||||||
|
|
||||||
if($order_jersey_size[$key] == "none" || $order_shorts_size[$key] == "none"){
|
if ($order_jersey_size[$key] == "none" || $order_shorts_size[$key] == "none") {
|
||||||
$final_price = $ProductPrice / 2;
|
$final_price = $ProductPrice / 2;
|
||||||
}else{
|
} else {
|
||||||
$final_price = $ProductPrice;
|
$final_price = $ProductPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'ProductId' => $product_id,
|
'ProductId' => $product_id,
|
||||||
'StoreURL' => $store_url,
|
'StoreURL' => $store_url,
|
||||||
@@ -322,10 +317,11 @@ class TeamStoreController extends Controller {
|
|||||||
'JerseySize' => $order_jersey_size[$key],
|
'JerseySize' => $order_jersey_size[$key],
|
||||||
'ShortsSize' => $order_shorts_size[$key],
|
'ShortsSize' => $order_shorts_size[$key],
|
||||||
'Price' => $final_price,
|
'Price' => $final_price,
|
||||||
'Quantity' => 1
|
'Quantity' => 1,
|
||||||
|
'ShippingFee' => $shipping_fee
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}elseif($product_form == "tshirt-form"){
|
} elseif ($product_form == "tshirt-form") {
|
||||||
|
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'ProductId' => $product_id,
|
'ProductId' => $product_id,
|
||||||
@@ -338,9 +334,10 @@ class TeamStoreController extends Controller {
|
|||||||
'ProductName' => $product_name,
|
'ProductName' => $product_name,
|
||||||
'Size' => $post['uniformSize'],
|
'Size' => $post['uniformSize'],
|
||||||
'Price' => $ProductPrice,
|
'Price' => $ProductPrice,
|
||||||
'Quantity' => $post['quantity']
|
'Quantity' => $post['quantity'],
|
||||||
|
'ShippingFee' => $shipping_fee
|
||||||
);
|
);
|
||||||
}elseif($product_form == "quantity-form"){
|
} elseif ($product_form == "quantity-form") {
|
||||||
|
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'ProductId' => $product_id,
|
'ProductId' => $product_id,
|
||||||
@@ -352,16 +349,15 @@ class TeamStoreController extends Controller {
|
|||||||
'ProductURL' => $ProductURL,
|
'ProductURL' => $ProductURL,
|
||||||
'ProductName' => $product_name,
|
'ProductName' => $product_name,
|
||||||
'Price' => $ProductPrice,
|
'Price' => $ProductPrice,
|
||||||
'Quantity' => $post['quantity']
|
'Quantity' => $post['quantity'],
|
||||||
|
'ShippingFee' => $shipping_fee
|
||||||
);
|
);
|
||||||
|
} elseif ($product_form == "name-number-form") {
|
||||||
|
|
||||||
}elseif($product_form == "name-number-form"){
|
|
||||||
|
|
||||||
$order_names = $post['order_names'];
|
$order_names = $post['order_names'];
|
||||||
$order_number = $post['order_number'];
|
$order_number = $post['order_number'];
|
||||||
|
|
||||||
foreach($order_names as $key => $val){
|
foreach ($order_names as $key => $val) {
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'ProductId' => $product_id,
|
'ProductId' => $product_id,
|
||||||
'StoreURL' => $store_url,
|
'StoreURL' => $store_url,
|
||||||
@@ -374,16 +370,17 @@ class TeamStoreController extends Controller {
|
|||||||
'Name' => $order_names[$key],
|
'Name' => $order_names[$key],
|
||||||
'Number' => $order_number[$key],
|
'Number' => $order_number[$key],
|
||||||
'Price' => $ProductPrice,
|
'Price' => $ProductPrice,
|
||||||
'Quantity' => 1
|
'Quantity' => 1,
|
||||||
|
'ShippingFee' => $shipping_fee
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}elseif($product_form == "name-number-size-form"){
|
} elseif ($product_form == "name-number-size-form") {
|
||||||
|
|
||||||
$order_names = $post['order_names'];
|
$order_names = $post['order_names'];
|
||||||
$order_number = $post['order_number'];
|
$order_number = $post['order_number'];
|
||||||
$order_size = $post['order_size'];
|
$order_size = $post['order_size'];
|
||||||
|
|
||||||
foreach($order_names as $key => $val){
|
foreach ($order_names as $key => $val) {
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'ProductId' => $product_id,
|
'ProductId' => $product_id,
|
||||||
'StoreURL' => $store_url,
|
'StoreURL' => $store_url,
|
||||||
@@ -397,15 +394,15 @@ class TeamStoreController extends Controller {
|
|||||||
'Size' => $order_size[$key],
|
'Size' => $order_size[$key],
|
||||||
'Number' => $order_number[$key],
|
'Number' => $order_number[$key],
|
||||||
'Price' => $ProductPrice,
|
'Price' => $ProductPrice,
|
||||||
'Quantity' => 1
|
'Quantity' => 1,
|
||||||
|
'ShippingFee' => $shipping_fee
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} elseif ($product_form == "number-form") {
|
||||||
}elseif($product_form == "number-form"){
|
|
||||||
|
|
||||||
$order_number = $post['order_number'];
|
$order_number = $post['order_number'];
|
||||||
|
|
||||||
foreach($order_number as $key => $val){
|
foreach ($order_number as $key => $val) {
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'ProductId' => $product_id,
|
'ProductId' => $product_id,
|
||||||
'StoreURL' => $store_url,
|
'StoreURL' => $store_url,
|
||||||
@@ -417,16 +414,17 @@ class TeamStoreController extends Controller {
|
|||||||
'ProductName' => $product_name,
|
'ProductName' => $product_name,
|
||||||
'Number' => $order_number[$key],
|
'Number' => $order_number[$key],
|
||||||
'Price' => $ProductPrice,
|
'Price' => $ProductPrice,
|
||||||
'Quantity' => 1
|
'Quantity' => 1,
|
||||||
|
'ShippingFee' => $shipping_fee
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}elseif($product_form == "name-name2-size-form"){
|
} elseif ($product_form == "name-name2-size-form") {
|
||||||
|
|
||||||
$order_names = $post['order_names'];
|
$order_names = $post['order_names'];
|
||||||
$order_names2 = $post['order_names2'];
|
$order_names2 = $post['order_names2'];
|
||||||
$order_size = $post['order_size'];
|
$order_size = $post['order_size'];
|
||||||
|
|
||||||
foreach($order_names as $key => $val){
|
foreach ($order_names as $key => $val) {
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'ProductId' => $product_id,
|
'ProductId' => $product_id,
|
||||||
'StoreURL' => $store_url,
|
'StoreURL' => $store_url,
|
||||||
@@ -440,15 +438,16 @@ class TeamStoreController extends Controller {
|
|||||||
'Name2' => $order_names2[$key],
|
'Name2' => $order_names2[$key],
|
||||||
'Size' => $order_size[$key],
|
'Size' => $order_size[$key],
|
||||||
'Price' => $ProductPrice,
|
'Price' => $ProductPrice,
|
||||||
'Quantity' => 1
|
'Quantity' => 1,
|
||||||
|
'ShippingFee' => $shipping_fee
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}elseif($product_form == "name-size-form"){
|
} elseif ($product_form == "name-size-form") {
|
||||||
|
|
||||||
$order_names = $post['order_names'];
|
$order_names = $post['order_names'];
|
||||||
$order_size = $post['order_size'];
|
$order_size = $post['order_size'];
|
||||||
|
|
||||||
foreach($order_names as $key => $val){
|
foreach ($order_names as $key => $val) {
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'ProductId' => $product_id,
|
'ProductId' => $product_id,
|
||||||
'StoreURL' => $store_url,
|
'StoreURL' => $store_url,
|
||||||
@@ -461,21 +460,22 @@ class TeamStoreController extends Controller {
|
|||||||
'Name' => $order_names[$key],
|
'Name' => $order_names[$key],
|
||||||
'Size' => $order_size[$key],
|
'Size' => $order_size[$key],
|
||||||
'Price' => $ProductPrice,
|
'Price' => $ProductPrice,
|
||||||
'Quantity' => 1
|
'Quantity' => 1,
|
||||||
|
'ShippingFee' => $shipping_fee
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}elseif($product_form == "jersey-and-shorts-quantity-form"){
|
} elseif ($product_form == "jersey-and-shorts-quantity-form") {
|
||||||
|
|
||||||
$order_shorts_size = $post['order_shorts_size'];
|
$order_shorts_size = $post['order_shorts_size'];
|
||||||
$order_jersey_size = $post['order_jersey_size'];
|
$order_jersey_size = $post['order_jersey_size'];
|
||||||
$quantity = $post['quantity'];
|
$quantity = $post['quantity'];
|
||||||
|
|
||||||
foreach($order_jersey_size as $key => $val){
|
foreach ($order_jersey_size as $key => $val) {
|
||||||
if($order_jersey_size[$key] != "none" || $order_shorts_size[$key] != "none"){
|
if ($order_jersey_size[$key] != "none" || $order_shorts_size[$key] != "none") {
|
||||||
|
|
||||||
if($order_jersey_size[$key] == "none" || $order_shorts_size[$key] == "none"){
|
if ($order_jersey_size[$key] == "none" || $order_shorts_size[$key] == "none") {
|
||||||
$final_price = $ProductPrice / 2;
|
$final_price = $ProductPrice / 2;
|
||||||
}else{
|
} else {
|
||||||
$final_price = $ProductPrice;
|
$final_price = $ProductPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,25 +491,25 @@ class TeamStoreController extends Controller {
|
|||||||
'JerseySize' => $order_jersey_size[$key],
|
'JerseySize' => $order_jersey_size[$key],
|
||||||
'ShortsSize' => $order_shorts_size[$key],
|
'ShortsSize' => $order_shorts_size[$key],
|
||||||
'Price' => $final_price,
|
'Price' => $final_price,
|
||||||
'Quantity' => $quantity[$key]
|
'Quantity' => $quantity[$key],
|
||||||
|
'ShippingFee' => $shipping_fee
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}elseif($product_form == "number-jersey-shorts-form"){
|
} elseif ($product_form == "number-jersey-shorts-form") {
|
||||||
|
|
||||||
$order_number = $post['order_number'];
|
$order_number = $post['order_number'];
|
||||||
$order_jersey_size = $post['order_jersey_size'];
|
$order_jersey_size = $post['order_jersey_size'];
|
||||||
$order_shorts_size = $post['order_shorts_size'];
|
$order_shorts_size = $post['order_shorts_size'];
|
||||||
|
|
||||||
foreach($order_number as $key => $val){
|
foreach ($order_number as $key => $val) {
|
||||||
|
|
||||||
if($order_jersey_size[$key] == "none" || $order_shorts_size[$key] == "none"){
|
if ($order_jersey_size[$key] == "none" || $order_shorts_size[$key] == "none") {
|
||||||
$final_price = $ProductPrice / 2;
|
$final_price = $ProductPrice / 2;
|
||||||
}else{
|
} else {
|
||||||
$final_price = $ProductPrice;
|
$final_price = $ProductPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'ProductId' => $product_id,
|
'ProductId' => $product_id,
|
||||||
'StoreURL' => $store_url,
|
'StoreURL' => $store_url,
|
||||||
@@ -523,14 +523,15 @@ class TeamStoreController extends Controller {
|
|||||||
'JerseySize' => $order_jersey_size[$key],
|
'JerseySize' => $order_jersey_size[$key],
|
||||||
'ShortsSize' => $order_shorts_size[$key],
|
'ShortsSize' => $order_shorts_size[$key],
|
||||||
'Price' => $final_price,
|
'Price' => $final_price,
|
||||||
'Quantity' => 1
|
'Quantity' => 1,
|
||||||
|
'ShippingFee' => $shipping_fee
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = $m->insertToCart($items);
|
$i = $m->insertToCart($items);
|
||||||
|
|
||||||
if($i['i']){
|
if ($i['i']) {
|
||||||
return response()->json(array(
|
return response()->json(array(
|
||||||
'success' => true
|
'success' => true
|
||||||
));
|
));
|
||||||
@@ -540,11 +541,12 @@ class TeamStoreController extends Controller {
|
|||||||
return response()->json(array(
|
return response()->json(array(
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => "Something went wrong. Please refresh the page."
|
'message' => "Something went wrong. Please refresh the page."
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cart(Request $request){
|
public function cart(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
$m = new TeamStoreModel;
|
$m = new TeamStoreModel;
|
||||||
$cartKey = $request->session()->get('cartkey');
|
$cartKey = $request->session()->get('cartkey');
|
||||||
$items = $m->myCart($cartKey);
|
$items = $m->myCart($cartKey);
|
||||||
@@ -552,91 +554,95 @@ class TeamStoreController extends Controller {
|
|||||||
$items_group = $m->myCartGroup($cartKey);
|
$items_group = $m->myCartGroup($cartKey);
|
||||||
//var_dump($items_group);
|
//var_dump($items_group);
|
||||||
$grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey);
|
$grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey);
|
||||||
if($grouped_item){
|
if ($grouped_item) {
|
||||||
$defId = $grouped_item[0]->StoreId;
|
$defId = $grouped_item[0]->StoreId;
|
||||||
}else{
|
} else {
|
||||||
$defId = 0;
|
$defId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item_thumbs = $m->selectDisplayCartThumb();
|
|
||||||
$store_array = $m->selectTeamStore('Id', $defId);
|
|
||||||
|
|
||||||
|
|
||||||
if($items){
|
$item_thumbs = $m->selectDisplayCartThumb();
|
||||||
|
$store_array = $m->selectTeamStore('Id', $defId);
|
||||||
|
$shipping_cost = 0;
|
||||||
|
|
||||||
|
if ($items) {
|
||||||
$voucherIds = array();
|
$voucherIds = array();
|
||||||
foreach($items as $item){
|
foreach ($items as $item) {
|
||||||
if($item->VoucherId != null){
|
if ($item->VoucherId != null) {
|
||||||
$voucherIds[] = $item->VoucherId;
|
$voucherIds[] = $item->VoucherId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$shipping_cost += $item->ShippingFee * $item->Quantity;
|
||||||
}
|
}
|
||||||
$vouchers = $m->selectVoucherWhereIn($voucherIds);
|
$vouchers = $m->selectVoucherWhereIn($voucherIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
$totalValue = 0;
|
$totalValue = 0;
|
||||||
if(!empty($vouchers)){
|
if (!empty($vouchers)) {
|
||||||
foreach($vouchers as $voucher){
|
foreach ($vouchers as $voucher) {
|
||||||
$totalValue = $totalValue + $voucher->VoucherValue;
|
$totalValue = $totalValue + $voucher->VoucherValue;
|
||||||
if($voucher->VoucherType == "Percentage"){
|
if ($voucher->VoucherType == "Percentage") {
|
||||||
$voucherData = array(
|
$voucherData = array(
|
||||||
'totalValue'=> $totalValue,
|
'totalValue' => $totalValue,
|
||||||
'type'=>'Percentage'
|
'type' => 'Percentage'
|
||||||
);
|
);
|
||||||
}else{
|
} else {
|
||||||
$voucherData = array(
|
$voucherData = array(
|
||||||
'totalValue'=> $totalValue,
|
'totalValue' => $totalValue,
|
||||||
'type'=>'Flat'
|
'type' => 'Flat'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($voucherData['type'] == "Percentage"){
|
if ($voucherData['type'] == "Percentage") {
|
||||||
$getPercentageValue = $voucherData['totalValue'] / 100;
|
$getPercentageValue = $voucherData['totalValue'] / 100;
|
||||||
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
|
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
|
||||||
$finalSubTotal = $getSubtotal[0]->Subtotal - $getDiscountValue;
|
$finalSubTotal = $getSubtotal[0]->Subtotal - $getDiscountValue;
|
||||||
}else{
|
} else {
|
||||||
//Flat voucher computation here..
|
//Flat voucher computation here..
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$finalSubTotal = $getSubtotal[0]->Subtotal;
|
$finalSubTotal = $getSubtotal[0]->Subtotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('sublayouts.cart')
|
return view('sublayouts.cart')
|
||||||
->with('item_group', $items_group)
|
->with('item_group', $items_group)
|
||||||
->with('row', $items)
|
->with('row', $items)
|
||||||
->with('img_thumb', $item_thumbs)
|
->with('img_thumb', $item_thumbs)
|
||||||
->with('getSubtotal', $finalSubTotal)
|
->with('getSubtotal', $finalSubTotal)
|
||||||
->with('store_array', $store_array);
|
->with('store_array', $store_array)
|
||||||
|
->with('shipping_cost', $shipping_cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addVoucher(Request $request){
|
public function addVoucher(Request $request)
|
||||||
|
{
|
||||||
$cartKey = $request->session()->get('cartkey');
|
$cartKey = $request->session()->get('cartkey');
|
||||||
|
|
||||||
if($cartKey == ""){
|
if ($cartKey == "") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$TeamStoreModel = new TeamStoreModel;
|
$TeamStoreModel = new TeamStoreModel;
|
||||||
$post = $request->all();
|
$post = $request->all();
|
||||||
|
|
||||||
$grouped_item = $TeamStoreModel->selectTeamStoreGroupByCartKey($cartKey);
|
$grouped_item = $TeamStoreModel->selectTeamStoreGroupByCartKey($cartKey);
|
||||||
$store_id = $grouped_item[0]->StoreId;
|
$store_id = $grouped_item[0]->StoreId;
|
||||||
$vocher = $post['voucher'];
|
$vocher = $post['voucher'];
|
||||||
$store_array = $TeamStoreModel->selectTeamStore('Id', $grouped_item[0]->StoreId);
|
$store_array = $TeamStoreModel->selectTeamStore('Id', $grouped_item[0]->StoreId);
|
||||||
$getSubtotal = $TeamStoreModel->getSubtotal($cartKey);
|
$getSubtotal = $TeamStoreModel->getSubtotal($cartKey);
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'store_id' => $store_id,
|
'store_id' => $store_id,
|
||||||
'voucher' => $vocher
|
'voucher' => $vocher
|
||||||
);
|
);
|
||||||
|
|
||||||
$getVoucher = $TeamStoreModel->selectVoucher($data);
|
$getVoucher = $TeamStoreModel->selectVoucher($data);
|
||||||
|
|
||||||
if($getVoucher){
|
if ($getVoucher) {
|
||||||
$items = $TeamStoreModel->myCart($cartKey);
|
$items = $TeamStoreModel->myCart($cartKey);
|
||||||
|
|
||||||
// check if if voucher is already in used;
|
// check if if voucher is already in used;
|
||||||
foreach($items as $item){
|
foreach ($items as $item) {
|
||||||
if($getVoucher[0]->Id == $item->VoucherId){
|
if ($getVoucher[0]->Id == $item->VoucherId) {
|
||||||
return response()->json(array(
|
return response()->json(array(
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => 'This voucher is already in used.'
|
'message' => 'This voucher is already in used.'
|
||||||
@@ -661,73 +667,69 @@ class TeamStoreController extends Controller {
|
|||||||
|
|
||||||
//get all voucher used.
|
//get all voucher used.
|
||||||
$updated_items = $TeamStoreModel->myCart($cartKey);
|
$updated_items = $TeamStoreModel->myCart($cartKey);
|
||||||
foreach($updated_items as $item){
|
foreach ($updated_items as $item) {
|
||||||
if($item->VoucherId != null){
|
if ($item->VoucherId != null) {
|
||||||
$voucherIds[] = $item->VoucherId;
|
$voucherIds[] = $item->VoucherId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$vouchers = $TeamStoreModel->selectVoucherWhereIn($voucherIds);
|
$vouchers = $TeamStoreModel->selectVoucherWhereIn($voucherIds);
|
||||||
|
|
||||||
$totalValue = 0;
|
$totalValue = 0;
|
||||||
if(!empty($vouchers)){
|
if (!empty($vouchers)) {
|
||||||
foreach($vouchers as $voucher){
|
foreach ($vouchers as $voucher) {
|
||||||
$totalValue = $totalValue + $voucher->VoucherValue;
|
$totalValue = $totalValue + $voucher->VoucherValue;
|
||||||
if($voucher->VoucherType == "Percentage"){
|
if ($voucher->VoucherType == "Percentage") {
|
||||||
$voucherData = array(
|
$voucherData = array(
|
||||||
'totalValue'=> $totalValue,
|
'totalValue' => $totalValue,
|
||||||
'type'=>'Percentage'
|
'type' => 'Percentage'
|
||||||
);
|
);
|
||||||
}else{
|
} else {
|
||||||
$voucherData = array(
|
$voucherData = array(
|
||||||
'totalValue'=> $totalValue,
|
'totalValue' => $totalValue,
|
||||||
'type'=>'Flat'
|
'type' => 'Flat'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($voucherData['type'] == "Percentage"){
|
if ($voucherData['type'] == "Percentage") {
|
||||||
$getPercentageValue = $voucherData['totalValue'] / 100;
|
$getPercentageValue = $voucherData['totalValue'] / 100;
|
||||||
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
|
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
|
||||||
$finalSubTotal = $getSubtotal[0]->Subtotal - $getDiscountValue;
|
$finalSubTotal = $getSubtotal[0]->Subtotal - $getDiscountValue;
|
||||||
}else{
|
} else {
|
||||||
//Flat voucher computation here..
|
//Flat voucher computation here..
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$finalSubTotal = $getSubtotal[0]->Subtotal;
|
$finalSubTotal = $getSubtotal[0]->Subtotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($getVoucher[0]->VoucherType == "Percentage"){
|
if ($getVoucher[0]->VoucherType == "Percentage") {
|
||||||
$offData = $getVoucher[0]->VoucherValue . '%';
|
$offData = $getVoucher[0]->VoucherValue . '%';
|
||||||
}else{
|
} else {
|
||||||
$offData = $getVoucher[0]->VoucherValue . ' ' . $store_array[0]->StoreCurrency;
|
$offData = $getVoucher[0]->VoucherValue . ' ' . $store_array[0]->StoreCurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$message = '<div class="btn-group">
|
$message = '<div class="btn-group">
|
||||||
<button type="button" class="btn btn-default btn-xs">'.$getVoucher[0]->VoucherCode. ' ' .$offData. ' OFF</button>
|
<button type="button" class="btn btn-default btn-xs">' . $getVoucher[0]->VoucherCode . ' ' . $offData . ' OFF</button>
|
||||||
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
<span class="sr-only"></span>
|
<span class="sr-only"></span>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="'.$removeItemURL.'"><i class="fa fa-times"></i> Remove</a></li>
|
<li><a href="' . $removeItemURL . '"><i class="fa fa-times"></i> Remove</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
// return success
|
// return success
|
||||||
return response()->json(array(
|
return response()->json(array(
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
'subtotal' =>$finalSubTotal
|
'subtotal' => $finalSubTotal
|
||||||
));
|
));
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
return response()->json(array(
|
return response()->json(array(
|
||||||
'success' => false,
|
'success' => false,
|
||||||
'message' => "Sorry, the voucher code is invalid. Please try again."
|
'message' => "Sorry, the voucher code is invalid. Please try again."
|
||||||
@@ -739,10 +741,10 @@ class TeamStoreController extends Controller {
|
|||||||
{
|
{
|
||||||
$m = new TeamStoreModel;
|
$m = new TeamStoreModel;
|
||||||
$cartKey = $request->session()->get('cartkey');
|
$cartKey = $request->session()->get('cartkey');
|
||||||
|
|
||||||
$usermodel = new UserModel;
|
$usermodel = new UserModel;
|
||||||
$userId = Auth::user()->id;
|
$userId = Auth::user()->id;
|
||||||
|
|
||||||
$array_address_book = $usermodel->selectAddresBook('UserId', $userId);
|
$array_address_book = $usermodel->selectAddresBook('UserId', $userId);
|
||||||
|
|
||||||
// var_dump($array_address_book);
|
// var_dump($array_address_book);
|
||||||
@@ -752,10 +754,9 @@ class TeamStoreController extends Controller {
|
|||||||
$getSubtotal = $m->getSubtotal($cartKey);
|
$getSubtotal = $m->getSubtotal($cartKey);
|
||||||
|
|
||||||
return view('sublayouts.checkout')
|
return view('sublayouts.checkout')
|
||||||
->with('row', $items)
|
->with('row', $items)
|
||||||
->with('getSubtotal', $getSubtotal)
|
->with('getSubtotal', $getSubtotal)
|
||||||
->with('array_address_book', $array_address_book);
|
->with('array_address_book', $array_address_book);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mail()
|
public function mail()
|
||||||
@@ -771,13 +772,10 @@ class TeamStoreController extends Controller {
|
|||||||
|
|
||||||
|
|
||||||
// dd('Mail Send Successfully');
|
// dd('Mail Send Successfully');
|
||||||
Mail::raw('Text to e-mail', function($message)
|
Mail::raw('Text to e-mail', function ($message) {
|
||||||
{
|
|
||||||
$message->from('us@example.com', 'Laravel');
|
$message->from('us@example.com', 'Laravel');
|
||||||
|
|
||||||
$message->to('frank.begornia@yahoo.com')->subject('sample email');
|
$message->to('frank.begornia@yahoo.com')->subject('sample email');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,4 +219,10 @@ class TeamStoreModel extends Model {
|
|||||||
return $i;
|
return $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function delete_cartTmp($field, $cartKey){
|
||||||
|
$i = DB::table('cart_tmp')
|
||||||
|
->where($field, $cartKey)
|
||||||
|
->delete();
|
||||||
|
return $i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,15 +35,15 @@ return [
|
|||||||
],
|
],
|
||||||
|
|
||||||
// sandbox
|
// sandbox
|
||||||
/* 'paypal' => [
|
'paypal' => [
|
||||||
'client_id' => 'AQuz-HKzQiL7FygkG8skSekaWf-RP6Rgj4f1XeX1Ghp86bUFj7tQXVT1xbpluu5_WCGRbQpOVGtlJKVB',
|
'client_id' => 'AR1FObcz7lD_p53BJpOw1Frf0hIJ1-VOArYoDnsNJXVvoxjYv6mOKBBvdvZBzQcpBPfB_AJnofdalO0t',
|
||||||
'secret' => 'EJAMKxQsl-mFkL_4J_90cvTamYfcsgswqgIxz9wQPiRAwJ6sy_wNsttMlmrXIpxI96JpYzdMXkLCHAPz'
|
'secret' => 'EK0CB8Re802HTxLQawwjAYzOu-SxrFOwuVG7qZ_nSovwgkp77wVs6k4XelXj2v5Il5llCFzsWs_Eb4o-'
|
||||||
], */
|
],
|
||||||
|
|
||||||
// live
|
// live
|
||||||
'paypal' => [
|
// 'paypal' => [
|
||||||
'client_id' => 'AUqBUFW5lfyYmrlBtFZA3RNw45sttM3ltbvS_d4qCVBMrkcMG9rEeivGvtNFSy8XTiEp50YyQ6khKxbq',
|
// 'client_id' => 'AUqBUFW5lfyYmrlBtFZA3RNw45sttM3ltbvS_d4qCVBMrkcMG9rEeivGvtNFSy8XTiEp50YyQ6khKxbq',
|
||||||
'secret' => 'ELlnuiupoFKwGUSc2g5j-sD1EmsvKpdhth1gFV7njpfvyNtKsK8WwIKUMOS0ehJcRatV865eMhfgsnd_'
|
// 'secret' => 'ELlnuiupoFKwGUSc2g5j-sD1EmsvKpdhth1gFV7njpfvyNtKsK8WwIKUMOS0ehJcRatV865eMhfgsnd_'
|
||||||
],
|
// ],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -387,6 +387,10 @@
|
|||||||
<td class="col-md-3">Tax</td>
|
<td class="col-md-3">Tax</td>
|
||||||
<td>{{ $array_payment_details[0]->Tax . ' ' . $array_payment_details[0]->Currency }}</td>
|
<td>{{ $array_payment_details[0]->Tax . ' ' . $array_payment_details[0]->Currency }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="col-md-3">Shipping Fee</td>
|
||||||
|
<td>{{ $array_payment_details[0]->ShippingCost . ' ' . $array_payment_details[0]->Currency }}</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="col-md-3">Total</td>
|
<td class="col-md-3">Total</td>
|
||||||
<td>{{ $array_payment_details[0]->Total . ' ' . $array_payment_details[0]->Currency }}</td>
|
<td>{{ $array_payment_details[0]->Total . ' ' . $array_payment_details[0]->Currency }}</td>
|
||||||
|
|||||||
@@ -46,14 +46,37 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="border: 1px solid #e2e2e2; padding: 10px; border-bottom: none;">
|
<div style="border: 1px solid #e2e2e2; padding: 10px; border-bottom: none;">
|
||||||
<h3>Subtotal: <span id="my_subtotal">{{ round($getSubtotal, 2) }}</span> <small>{{ $store_array[0]->StoreCurrency }}</small></h3>
|
{{-- <h3>Subtotal: <span id="my_subtotal">{{ round($getSubtotal, 2) }}</span> <small>{{ $store_array[0]->StoreCurrency }}</small></h3> --}}
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
|
||||||
|
<p>Free Shipping on orders with subtotal over 150.00 {{ $store_array[0]->StoreCurrency }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<tr>
|
||||||
|
<th>Subtotal</th>
|
||||||
|
<td>{{ round($getSubtotal, 2) }}</span> <small>{{ $store_array[0]->StoreCurrency }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Tax</th>
|
||||||
|
<td>{{ round($getSubtotal, 2) * 0.10 }}</span> <small>{{ $store_array[0]->StoreCurrency }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Shipping Fee</th>
|
||||||
|
<td>{{ round($shipping_cost, 2) }}</span> <small>{{ $store_array[0]->StoreCurrency }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><h5>Total<h5></th>
|
||||||
|
<td><h5>{{ round($getSubtotal + $shipping_cost + ($getSubtotal * 0.10), 2) }}</span> <small>{{ $store_array[0]->StoreCurrency }}</h5></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="form-group" id="voucher_list">
|
<div class="form-group" id="voucher_list">
|
||||||
@foreach($row as $item)
|
@foreach($row as $item)
|
||||||
@if($item->VoucherId != null)
|
@if($item->VoucherId != null)
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
@if($item->VoucherType == "Percentage")
|
@if($item->VoucherType == "Percentage")
|
||||||
<button type="button" class="btn btn-default btn-xs">{{ $item->VoucherCode . ' ' . $item->VoucherValue . '%' }} OFF</button>
|
<button type="button" class="btn btn-default btn-xs">{{ $item->VoucherCode . ' ' . $item->VoucherValue . '%' }} OFF</button>
|
||||||
@else
|
@else
|
||||||
<button type="button" class="btn btn-default btn-xs">{{ $item->VoucherCode . ' ' . $item->VoucherValue . ' ' . $store_array[0]->StoreCurrency }} OFF</button>
|
<button type="button" class="btn btn-default btn-xs">{{ $item->VoucherCode . ' ' . $item->VoucherValue . ' ' . $store_array[0]->StoreCurrency }} OFF</button>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
Reference in New Issue
Block a user