This commit is contained in:
franknstayn
2022-01-26 20:30:34 +08:00
parent 137fbbc843
commit 8a9b1209a3
2 changed files with 45 additions and 33 deletions

View File

@@ -290,6 +290,7 @@ class PaypalController extends Controller
$m = new TeamStoreModel;
$UserModel = new UserModel;
$userId = 0;
if (!Auth::guest()) {
$userId = Auth::user()->id;
}
@@ -299,9 +300,6 @@ class PaypalController extends Controller
$items = $m->myCart($cartKey); // item from cart_tmp
$getSubtotal = $m->getSubtotal($cartKey);
// var_dump($getSubtotal);
if($getSubtotal[0]->Subtotal >= 99) {
return $shippingFee = 0;
}
$getSmallItemQty = 0;
$getBulkyItemQty = 0;
@@ -337,8 +335,9 @@ class PaypalController extends Controller
// );
}
}
// var_dump($item->ShippingCostId);
if ($item->ShippingCostId == 1) {
$getSmallItemQty += $item->Quantity;
} else if ($item->ShippingCostId == 2) {
$getBulkyItemQty += $item->Quantity;
@@ -360,12 +359,15 @@ class PaypalController extends Controller
// $getSmallItemQty = ceil($getSmallItemQty / 3) * 8.99;
if($getSmallItemQty >= 2) {
$getSmallItemQty = ceil(($getSmallItemQty - 1) / 1) * 2.49;
$getSmallItemQty = $getSmallItemQty + 8.99;
}else {
$getSmallItemQty = 8.99;
if($getSmallItemQty >= 1) {
if($getSmallItemQty >= 2) {
$getSmallItemQty = ceil(($getSmallItemQty - 1) / 1) * 2.49;
$getSmallItemQty = $getSmallItemQty + 8.99;
}else {
$getSmallItemQty = 8.99;
}
}
$getBulkyItemQty = ceil($getBulkyItemQty / 1) * 8;
$getMaskItemQty = ceil($getMaskItemQty / 25) * 8;
@@ -375,6 +377,10 @@ class PaypalController extends Controller
if ($countryCode == "CA") {
$shippingFee = $CAShippingfee;
}
if($getSubtotal[0]->Subtotal >= 99 && $countryCode != "CA") {
return $shippingFee = 0;
}
return $shippingFee;
}