add currency for teamstore

This commit is contained in:
Frank John Begornia
2019-08-19 21:37:47 +08:00
parent e60bb3baf8
commit b7e81adf31
68 changed files with 9977 additions and 442 deletions

View File

@@ -59,7 +59,7 @@ class PaypalController extends Controller {
if(Auth::guest()){
Session::flash('msg', 'Please login to proceed.');
Session::flash('msg', 'Please login your account to proceed.');
return Redirect::back();
}
@@ -68,42 +68,59 @@ class PaypalController extends Controller {
$m = new TeamStoreModel;
$paypal_model = new PayPalModel;
$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);
$cartKey = $request->session()->get('cartkey');
$items = $m->myCart($cartKey);
$getSubtotal = $m->getSubtotal($cartKey);
$grouped_item = $m->selectTeamStoreGroupByCartKey($cartKey);
$store_array = $m->selectTeamStore('Id', $grouped_item[0]->StoreId);
// var_dump($getSubtotal[0]->Subtotal);
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"){
$getPercentageValue = $totalValue / 100;
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
$data = array(
'Price' => $getDiscountValue * -1
);
$order_subtotal = $getSubtotal[0]->Subtotal;
$order_grandtotal = $getSubtotal[0]->Subtotal;
$m->updateVoucherValueInCart($data, $item_id);
}else{
$voucherData = array(
'totalValue'=> $totalValue,
'type'=>'Flat'
);
}
}
}
$order_items = array();
$updated_items = $m->myCart($cartKey);
$updated_getSubtotal = $m->getSubtotal($cartKey);
$order_subtotal = $updated_getSubtotal[0]->Subtotal;
$order_grandtotal = $updated_getSubtotal[0]->Subtotal;
$tax = $order_grandtotal * 0.10;
$order_items = array();
foreach($items as $key => $item){
if($item->Order == "Jersey"){
$itemOrder = " (Jersey Only)";
}elseif ($item->Order == "Shorts"){
$itemOrder = " (Shorts Only)";
}else{
$itemOrder = " (w/ Shorts)";
}
foreach($updated_items as $key => $item){
// $descriptions = "Name: " . $item->Name . " Number: " . $item->Number . " Size: " . $item->Size;"?"
$order_items[$key] = PayPal::Item();
$order_items[$key]->setName($item->ProductName);
$order_items[$key]->setCurrency('USD');
$order_items[$key]->setCurrency($store_array[0]->StoreCurrency);
$order_items[$key]->setQuantity($item->Quantity);
// $order_items[$key]->setDescription($descriptions);
// $order_items[$key]->setTax(10);
@@ -120,7 +137,7 @@ class PaypalController extends Controller {
$amount_details->setTax($tax);
$amount = PayPal::Amount();
$amount->setCurrency('USD');
$amount->setCurrency($store_array[0]->StoreCurrency);
$amount->setDetails($amount_details);
$amount->setTotal($order_grandtotal + $tax);
@@ -305,7 +322,6 @@ class PaypalController extends Controller {
$message->from('no-reply@crewsportswear.com', 'CREW Sportswear');
$message->cc('orders@crewsportswear.com', 'Orders From CREW Sportswear');
$message->to($data['receiver'])->subject($data['subject']);
});
// end email sending
@@ -319,8 +335,34 @@ class PaypalController extends Controller {
}
public function getCancel()
public function getCancel(Request $request)
{
$m = new TeamStoreModel;
$cartKey = $request->session()->get('cartkey');
$items = $m->myCart($cartKey);
$getSubtotal = $m->getSubtotal($cartKey);
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"){
$data = array(
'Price' => '00.00'
);
$m->updateVoucherValueInCart($data, $item_id);
}else{
$voucherData = array(
'totalValue'=> $totalValue,
'type'=>'Flat'
);
}
}
}
return redirect()->route('cart');
}