Berater Bestellung / online
This commit is contained in:
parent
16fe2fa363
commit
ecc71c616f
26 changed files with 828 additions and 240 deletions
|
|
@ -41,10 +41,8 @@ class CheckoutController extends Controller
|
|||
|
||||
public function checkout(){
|
||||
|
||||
//TODO ZAHLDIENSTE FORM USER !!!
|
||||
|
||||
// dump(Request::all());
|
||||
// dd("back");
|
||||
// $user_shop = Util::getUserShop();
|
||||
$shopping_data = Yard::instance('shopping')->getYardExtra('shopping_data');
|
||||
|
||||
|
|
@ -87,8 +85,6 @@ class CheckoutController extends Controller
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(old('selected_country') && old('selected_country') === 'change'){
|
||||
\Session::forget('_old_input.selected_country');
|
||||
$shopping_user->billing_state = old('billing_state');
|
||||
|
|
@ -110,8 +106,10 @@ class CheckoutController extends Controller
|
|||
if($is_from !== 'shopping' && Util::getAuthUser()){
|
||||
$user = Util::getAuthUser();
|
||||
$payment_methods = $user->payment_methods;
|
||||
$payment_data = $user->account->payment_data;
|
||||
}else{
|
||||
$payment_methods = PaymentMethod::getDefaultAsArray();
|
||||
$payment_methods = PaymentMethod::getDefaultAsArray()->toArray();
|
||||
$payment_data = false;
|
||||
}
|
||||
|
||||
$payment_methods_active = \App\Models\PaymentMethod::where('active', true)->get()->pluck( 'id', 'short')->toArray();
|
||||
|
|
@ -124,6 +122,7 @@ class CheckoutController extends Controller
|
|||
'shopping_mode' => Util::getUserShoppingMode(),
|
||||
'payment_methods' => $payment_methods,
|
||||
'payment_methods_active' => $payment_methods_active,
|
||||
'payment_data' => $payment_data,
|
||||
];
|
||||
return view('web.templates.checkout', $data);
|
||||
}
|
||||
|
|
@ -147,6 +146,8 @@ class CheckoutController extends Controller
|
|||
$shopping_user->billing_phone = $user->account->phone;
|
||||
$shopping_user->billing_email = $user->email;
|
||||
$shopping_user->faker_mail = false;
|
||||
$shopping_user->shipping_email = $user->email;
|
||||
|
||||
$shopping_user->accepted_data_checkbox = 1;
|
||||
$shopping_user->is_for = $is_for;
|
||||
$shopping_user->is_from = $is_from;
|
||||
|
|
@ -154,7 +155,7 @@ class CheckoutController extends Controller
|
|||
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_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;
|
||||
|
|
@ -165,11 +166,14 @@ class CheckoutController extends Controller
|
|||
$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;
|
||||
if(!$s_user->faker_mail){
|
||||
$shopping_user->shipping_email = $s_user->billing_email;
|
||||
}
|
||||
$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'] : '';
|
||||
|
|
@ -179,7 +183,7 @@ class CheckoutController extends Controller
|
|||
$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_country_id = Yard::instance('shopping')->getShippingCountryCountryId();
|
||||
$shopping_user->shipping_phone = isset($data['shipping_phone']) ? $data['shipping_phone'] : '';
|
||||
|
||||
}else{
|
||||
|
|
@ -211,7 +215,6 @@ class CheckoutController extends Controller
|
|||
Yard::instance('shopping')->setShippingCountryWithPrice($data['shipping_state'], $data['is_for']);
|
||||
}
|
||||
return back()->withInput(Request::all());
|
||||
|
||||
}
|
||||
|
||||
$rules = array(
|
||||
|
|
@ -244,6 +247,7 @@ class CheckoutController extends Controller
|
|||
$data = Request::all();
|
||||
//make User
|
||||
$shopping_user = $this->makeShoppingUser($data);
|
||||
|
||||
//make Order and Items
|
||||
$shopping_order = $this->makeShoppingOrder($shopping_user);
|
||||
//CustomerPriority
|
||||
|
|
@ -294,7 +298,6 @@ class CheckoutController extends Controller
|
|||
$pay->init($shopping_user, $shopping_order);
|
||||
$amount = Yard::instance('shopping')->totalWithShipping(2, '.', '') * 100;
|
||||
$ret['elv'] = $pay->checkBankAccount($data, $amount, 'EUR', $shopping_user);
|
||||
|
||||
if($ret['elv']['status'] === 'ERROR' || $ret['elv']['status'] === 'INVALID'){
|
||||
/* PaymentTransaction::create([
|
||||
'shopping_payment_id' => //is no shopping_payment_id at this moment,
|
||||
|
|
@ -418,7 +421,7 @@ class CheckoutController extends Controller
|
|||
private function storeUserPaymentsData($shopping_user, $ret){
|
||||
if($shopping_user->auth_user_id){
|
||||
$user = User::find($shopping_user->auth_user_id);
|
||||
if($user && $user->account && $shopping_user->abo_options){
|
||||
if($user && $user->account){
|
||||
if(isset($ret['elv']) && is_array($ret['elv'])){
|
||||
$user->account->payment_data = $ret['elv'];
|
||||
$user->account->save();
|
||||
|
|
@ -459,12 +462,20 @@ class CheckoutController extends Controller
|
|||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'user_shop_id' => $user_shop->id,
|
||||
'payment_for' => Util::getUserPaymentFor(),
|
||||
|
||||
|
||||
'total' => Yard::instance('shopping')->total(2, '.', ''),
|
||||
'subtotal' => Yard::instance('shopping')->subtotal(2, '.', ''),
|
||||
|
||||
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
|
||||
'subtotal' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ''),
|
||||
//'tax_rate' => Yard::getTaxRate(),
|
||||
'shipping_net' => Yard::instance('shopping')->shippingNet(2, '.', ''),
|
||||
'subtotal_ws' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ''),
|
||||
|
||||
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
|
||||
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
|
||||
|
||||
'points' => Yard::instance('shopping')->points(),
|
||||
|
||||
'weight' => Yard::instance('shopping')->weight(),
|
||||
'txaction' => 'prev',
|
||||
'mode' => Util::getUserShoppingMode(),
|
||||
|
|
@ -494,6 +505,7 @@ class CheckoutController extends Controller
|
|||
'product_id' => $item->id,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'price_net' => Yard::instance('shopping')->rowPriceNet($item, 3, '.', ''),
|
||||
'tax_rate' => $item->taxRate,
|
||||
'slug' => $item->options->slug,
|
||||
])->save();
|
||||
|
|
@ -511,6 +523,7 @@ class CheckoutController extends Controller
|
|||
'product_id' => $item->id,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'price_net' => Yard::instance('shopping')->rowPriceNet($item, 3, '.', ''),
|
||||
'tax_rate' => $item->taxRate,
|
||||
'slug' => $item->options->slug
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue