diff --git a/src/MicroweberPackages/Checkout/Http/Controllers/Traits/ShippingTrait.php b/src/MicroweberPackages/Checkout/Http/Controllers/Traits/ShippingTrait.php index 1d71607f86e..b6eaecd7786 100644 --- a/src/MicroweberPackages/Checkout/Http/Controllers/Traits/ShippingTrait.php +++ b/src/MicroweberPackages/Checkout/Http/Controllers/Traits/ShippingTrait.php @@ -38,13 +38,30 @@ public function shippingMethodSave(Request $request) { if (is_array($request->get('Address'))) { $request->merge([ - 'city'=>$request->get('Address')['city'], - 'zip'=>$request->get('Address')['zip'], - 'state'=>$request->get('Address')['state'], - 'address'=>$request->get('Address')['address'], + 'city'=>$request->get('Address')['city'], + 'zip'=>$request->get('Address')['zip'], + 'state'=>$request->get('Address')['state'], + 'address'=>$request->get('Address')['address'], ]); } + $rules = []; + $rules['shipping_gw'] = 'max:500'; + $rules['city'] = 'max:500'; + $rules['address'] = 'max:500'; + $rules['country'] = 'max:500'; + $rules['state'] = 'max:500'; + $rules['zip'] = 'max:500'; + $rules['other_info'] = 'max:500'; + + $validator = Validator::make($request->all(), $rules); + + if ($validator->fails()) { + $errors = $validator->messages()->toArray(); + session_set('errors', $errors); + return redirect(route('checkout.shipping_method')); + } + session_append_array('checkout_v2', [ 'shipping_gw'=> $request->get('shipping_gw'), 'city'=> $request->get('city'),