upated shipping fee and using voucher code
This commit is contained in:
@@ -315,6 +315,7 @@ class PaypalController extends Controller
|
||||
$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);
|
||||
@@ -323,7 +324,7 @@ class PaypalController extends Controller
|
||||
);
|
||||
|
||||
$m->updateVoucherValueInCart($data, $item_id);
|
||||
} else if ($voucher[0]->VoucherType == "Percentage") {
|
||||
} else if ($voucher[0]->VoucherType == "Flat") {
|
||||
$data = array(
|
||||
'Price' => round($totalValue * -1, 2)
|
||||
);
|
||||
@@ -336,6 +337,9 @@ class PaypalController extends Controller
|
||||
} else if ($voucher[0]->VoucherType == "Shipping") {
|
||||
return $shippingFee = 0;
|
||||
}
|
||||
} else {
|
||||
$getSmallItemQty += $item->Quantity;
|
||||
$CAShippingfee += $item->Quantity; // for canada
|
||||
}
|
||||
// var_dump($item->ShippingCostId);
|
||||
// if ($item->ShippingCostId == 1) {
|
||||
@@ -347,8 +351,7 @@ class PaypalController extends Controller
|
||||
// } else if ($item->ShippingCostId == 4) {
|
||||
// $getDGSItemQty += $item->Quantity;
|
||||
// }
|
||||
$getSmallItemQty += $item->Quantity;
|
||||
$CAShippingfee += $item->Quantity; // for canada
|
||||
|
||||
}
|
||||
|
||||
$array_address_book = $UserModel->selectAddresBook('UserId', $userId);
|
||||
|
||||
@@ -95,7 +95,7 @@ class TeamStoreController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$thumbnails = [];
|
||||
foreach ($product_array as $p => $pr_arr) {
|
||||
|
||||
@@ -650,6 +650,7 @@ class TeamStoreController extends Controller
|
||||
|
||||
$cartKey = $request->session()->get('cartkey');
|
||||
$items = $m->myCart($cartKey);
|
||||
// var_dump($items);
|
||||
$getSubtotal = $m->getSubtotal($cartKey);
|
||||
$items_group = $m->myCartGroup($cartKey);
|
||||
//var_dump($items_group);
|
||||
@@ -674,6 +675,8 @@ class TeamStoreController extends Controller
|
||||
$vouchers = $m->selectVoucherWhereIn($voucherIds);
|
||||
}
|
||||
|
||||
// var_dump($vouchers);
|
||||
|
||||
$totalValue = 0;
|
||||
if (!empty($vouchers)) {
|
||||
foreach ($vouchers as $voucher) {
|
||||
@@ -693,6 +696,11 @@ class TeamStoreController extends Controller
|
||||
|
||||
if ($voucherData['type'] == "Percentage") {
|
||||
$getPercentageValue = $voucherData['totalValue'] / 100;
|
||||
|
||||
// var_dump($getPercentageValue);
|
||||
// var_dump($getSubtotal[0]->Subtotal);
|
||||
// var_dump($getSubtotal[0]->Subtotal * $getPercentageValue);
|
||||
|
||||
$getDiscountValue = ($getSubtotal[0]->Subtotal * $getPercentageValue);
|
||||
$finalSubTotal = $getSubtotal[0]->Subtotal - $getDiscountValue;
|
||||
} else {
|
||||
@@ -712,6 +720,7 @@ class TeamStoreController extends Controller
|
||||
$tax = [];
|
||||
}
|
||||
|
||||
// var_dump($finalSubTotal);
|
||||
|
||||
return view('merchbay.cart')
|
||||
->with('item_group', $items_group)
|
||||
@@ -910,15 +919,17 @@ class TeamStoreController extends Controller
|
||||
}
|
||||
|
||||
if ($getVoucher[0]->VoucherType == "Percentage") {
|
||||
$offData = $getVoucher[0]->VoucherValue . '%';
|
||||
} else {
|
||||
$offData = $getVoucher[0]->VoucherValue . ' ' . $store_array[0]->StoreCurrency;
|
||||
$offData = $getVoucher[0]->VoucherValue . '%' . ' OFF';
|
||||
} else if ($voucherData['type'] == "Flat") {
|
||||
$offData = $getVoucher[0]->VoucherValue . ' ' . $store_array[0]->StoreCurrency . ' OFF';
|
||||
} else if ($voucherData['type'] == "Shipping") {
|
||||
$offData = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$message = '<div class="btn-group mb-2">
|
||||
<button type="button" class="btn btn-black btn-sm dropdown-toggle" data-bs-toggle="dropdown">' . $getVoucher[0]->VoucherCode . ' ' . $offData . ' OFF</button>
|
||||
<button type="button" class="btn btn-black btn-sm dropdown-toggle" data-bs-toggle="dropdown">' . $getVoucher[0]->VoucherCode . ' ' . $offData . '</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="' . $removeItemURL . '">Remove</a></li>
|
||||
</ul>
|
||||
@@ -929,7 +940,9 @@ class TeamStoreController extends Controller
|
||||
'success' => true,
|
||||
'message' => $message,
|
||||
'shippingFee' => number_format($shippingFee, 2),
|
||||
'subtotal' => number_format($finalSubTotal + $shippingFee + $tax["tax"], 2)
|
||||
'total' => number_format($finalSubTotal + $shippingFee + $tax["tax"], 2),
|
||||
'subtotal' => number_format($finalSubTotal, 2),
|
||||
'remaining_shippingfee' => number_format(99 - $finalSubTotal, 2)
|
||||
));
|
||||
} else {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user