cart responsive, Checkout from cart

This commit is contained in:
Kevin Adametz 2020-08-14 18:32:41 +02:00
parent bde1095014
commit fb27009339
17 changed files with 501 additions and 319 deletions

View file

@ -37,31 +37,117 @@ class CheckoutController extends Controller
public function checkout(){
// dd("back");
// $user_shop = Util::getUserShop();
$shopping_data = Yard::instance('shopping')->getYardExtra('shopping_data');
$is_from = isset($shopping_data['is_from']) ? $shopping_data['is_from'] : 'shopping';
$is_for = isset($shopping_data['is_for']) ? $shopping_data['is_for'] : false;
$shopping_user = null;
if($shopping_data && $is_from !== 'shopping'){
//$shopping_user_id = isset($shopping_data['shopping_user_id']) ? $shopping_data['shopping_user_id'] : false;
$shopping_user = $this->shoppingUserAuthData($is_from, $is_for, $shopping_data);
}elseif($is_from === 'shopping') {
$shopping_user = new ShoppingUser();
$shopping_user->is_for = $is_for;
$shopping_user->is_from = $is_from;
}
if(Request::get('selected_country')){
Yard::instance('shopping')->setShippingCountryWithPrice(Request::get('selected_country'));
//Yard::instance('shopping')->setShippingCountryWithPrice(Request::get('selected_country'), $is_for);
}else{
$shopping_user->billing_state = Yard::instance('shopping')->getShippingCountryId();
$shopping_user->shipping_state = Yard::instance('shopping')->getShippingCountryId();
// $ShippingCountry = ShippingCountry::where('country_id', 1)->first();
// $selected_country = $ShippingCountry->id;
}
if(!$this->getPayments('shopping_user_id') && Util::getAuthUser()){
$user = Util::getAuthUser();
$user->email;
$shopping_user = new ShoppingUser();
$shopping_user->auth_user_id = $user->id;
$shopping_user->billing_salutation = $user->account->salutation;
$shopping_user->billing_company = $user->account->company;
$shopping_user->billing_firstname = $user->account->first_name;
$shopping_user->billing_lastname = $user->account->last_name;
$shopping_user->billing_address = $user->account->address;
$shopping_user->billing_address_2 = $user->account->address_2;
$shopping_user->billing_zipcode = $user->account->zipcode;
$shopping_user->billing_city = $user->account->city;
$shopping_user->billing_country_id = $user->account->country_id;
$shopping_user->billing_phone = $user->account->phone;
$shopping_user->billing_email = $user->email;
$shopping_user->accepted_data_checkbox = 1;
//$user->email;
// $shopping_user->save();
// $this->putPayments('shopping_user_id', $shopping_user->id);
}else{
//$shopping_user = ShoppingUser::findOrNew($this->getPayments('shopping_user_id'));
}
if(Util::getAuthUser()){
$shopping_user->abo_options = Util::getUserHistoryValue('abo_options');
//$shopping_user->save();
}
if($shopping_user->same_as_billing === NULL){
$shopping_user->same_as_billing = true;
}
$data = [
'is_from' => $is_from,
'is_for' => $is_for,
'user_shop' => Util::getUserShop(),
'shopping_user' => $shopping_user,
'shopping_mode' => Util::getUserShoppingMode(),
];
return view('web.templates.checkout', $data);
}
private function shoppingUserAuthData($is_from, $is_for, $data = []){
$user = Util::getAuthUser();
$shopping_user = new ShoppingUser();
$shopping_user->auth_user_id = $user->id;
$shopping_user->billing_salutation = $user->account->salutation;
$shopping_user->billing_company = $user->account->company;
$shopping_user->billing_firstname = $user->account->first_name;
$shopping_user->billing_lastname = $user->account->last_name;
$shopping_user->billing_address = $user->account->address;
$shopping_user->billing_address_2 = $user->account->address_2;
$shopping_user->billing_zipcode = $user->account->zipcode;
$shopping_user->billing_city = $user->account->city;
$shopping_user->billing_country_id = $user->account->country_id;
$shopping_user->billing_phone = $user->account->phone;
$shopping_user->billing_email = $user->email;
$shopping_user->faker_mail = false;
$shopping_user->accepted_data_checkbox = 1;
$shopping_user->is_for = $is_for;
$shopping_user->is_from = $is_from;
//Lieferadresse
if($is_from === 'user_order'){
if(isset($data['shopping_user_id']) && $data['is_for'] === 'ot'){
$s_user = ShoppingUser::findOrFail($data['shopping_user_id']);
$shopping_user->billing_salutation = $s_user->billing_salutation;
$shopping_user->billing_company = $s_user->billing_company;
$shopping_user->billing_firstname = $s_user->billing_firstname;
$shopping_user->billing_lastname = $s_user->billing_lastname;
$shopping_user->billing_address = $s_user->billing_address;
$shopping_user->billing_address_2 = $s_user->billing_address_2;
$shopping_user->billing_zipcode = $s_user->billing_zipcode;
$shopping_user->billing_city = $s_user->billing_city;
$shopping_user->billing_country_id = $s_user->billing_country_id;
$shopping_user->billing_phone = $s_user->billing_phone;
$shopping_user->billing_email = $s_user->billing_email;
$shopping_user->faker_mail = $s_user->faker_mail;
$shopping_user->shopping_user_id = $data['shopping_user_id'];
$shopping_user->member_id = $s_user->member_id;
}
$shopping_user->same_as_billing = false;
$shopping_user->shipping_salutation = isset($data['shipping_salutation']) ? $data['shipping_salutation'] : '';
$shopping_user->shipping_company = isset($data['shipping_company']) ? $data['shipping_company'] : '';
$shopping_user->shipping_firstname = isset($data['shipping_firstname']) ? $data['shipping_firstname'] : '';
$shopping_user->shipping_lastname = isset($data['shipping_lastname']) ? $data['shipping_lastname'] : '';
$shopping_user->shipping_address = isset($data['shipping_address']) ? $data['shipping_address'] : '';
$shopping_user->shipping_address_2 = isset($data['shipping_address_2']) ? $data['shipping_address_2'] : '';
$shopping_user->shipping_zipcode = isset($data['shipping_zipcode']) ? $data['shipping_zipcode'] : '';
$shopping_user->shipping_city = isset($data['shipping_city']) ? $data['shipping_city'] : '';
$shopping_user->shipping_country_id = isset($data['shipping_state']) ? $data['shipping_state'] : '';
$shopping_user->shipping_phone = isset($data['shipping_phone']) ? $data['shipping_phone'] : '';
}else{
$shopping_user->same_as_billing = $user->account->same_as_billing;
$shopping_user->shipping_salutation = $user->account->shipping_salutation;
$shopping_user->shipping_company = $user->account->shipping_company;
@ -73,29 +159,28 @@ class CheckoutController extends Controller
$shopping_user->shipping_city = $user->account->shipping_city;
$shopping_user->shipping_country_id = $user->account->shipping_country_id;
$shopping_user->shipping_phone = $user->account->shipping_phone;
$shopping_user->save();
$this->putPayments('shopping_user_id', $shopping_user->id);
}else{
$shopping_user = ShoppingUser::findOrNew($this->getPayments('shopping_user_id'));
}
if(Util::getAuthUser()){
$shopping_user->abo_options = Util::getUserHistoryValue('abo_options');
$shopping_user->save();
}
if($shopping_user->same_as_billing === NULL){
$shopping_user->same_as_billing = true;
}
$data = [
'user_shop' => Util::getUserShop(),
'shopping_user' => $shopping_user,
'shopping_mode' => Util::getUserShoppingMode(),
];
return view('web.templates.checkout', $data);
return $shopping_user;
}
public function checkoutFinal(){
$data = Request::all();
if(isset($data['selected_country']) && $data['selected_country'] === 'change'){
if(Request::get('same_as_billing')){
Yard::instance('shopping')->setShippingCountryWithPrice($data['billing_state'], $data['is_for']);
}else{
Yard::instance('shopping')->setShippingCountryWithPrice($data['shipping_state'], $data['is_for']);
}
return back()->withInput(Request::all());
}
dd('ads');
$rules = array(
'billing_salutation' => 'required',
'billing_firstname'=>'required',
@ -299,8 +384,6 @@ class CheckoutController extends Controller
private function makeShoppingUser($data){
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
$data['accepted_data_checkbox'] = isset($data['accepted_data_checkbox']) ? true : false;