updated voucher modules
This commit is contained in:
@@ -678,7 +678,6 @@ class TeamStoreController extends Controller
|
||||
public function addVoucher(Request $request)
|
||||
{
|
||||
$cartKey = $request->session()->get('cartkey');
|
||||
$userId = Auth::user()->id;
|
||||
|
||||
if ($cartKey == "") {
|
||||
return false;
|
||||
@@ -713,6 +712,14 @@ class TeamStoreController extends Controller
|
||||
|
||||
// check if if voucher is already in used;
|
||||
foreach ($items as $item) {
|
||||
|
||||
if( $item->VoucherId) {
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
'message' => 'You can only apply one voucher per order.'
|
||||
));
|
||||
}
|
||||
|
||||
if ($getVoucher[0]->Id == $item->VoucherId) {
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
@@ -736,6 +743,14 @@ class TeamStoreController extends Controller
|
||||
|
||||
if ($getVoucher[0]->VoucherType === "Flat") {
|
||||
|
||||
if (Auth::guest()) {
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
'message' => 'Log-in first to use this voucher.',
|
||||
));
|
||||
}
|
||||
|
||||
$userId = Auth::user()->id;
|
||||
$isUsed = $TeamStoreModel->checkVoucher($userId, $getVoucher[0]->Id);
|
||||
|
||||
if (count($isUsed) >= 1) {
|
||||
|
||||
Reference in New Issue
Block a user