06 2022
This commit is contained in:
parent
9b0b5feb7e
commit
7a040c3e19
106 changed files with 4074 additions and 1349 deletions
|
|
@ -110,19 +110,7 @@ class CheckoutController extends Controller
|
|||
//$shopping_user->save();
|
||||
}
|
||||
|
||||
|
||||
|
||||
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()->toArray();
|
||||
$payment_data = false;
|
||||
}
|
||||
|
||||
$payment_methods_active = \App\Models\PaymentMethod::where('active', true)->get()->pluck( 'id', 'short')->toArray();
|
||||
|
||||
$payment_methods = $this->getPaymentsMethods($is_from);
|
||||
$data = [
|
||||
'is_from' => $is_from,
|
||||
'is_for' => $is_for,
|
||||
|
|
@ -130,13 +118,40 @@ class CheckoutController extends Controller
|
|||
'user_shop' => Util::getUserShop(),
|
||||
'shopping_user' => $shopping_user,
|
||||
'shopping_mode' => Util::getUserShoppingMode(),
|
||||
'payment_methods' => $payment_methods,
|
||||
'payment_methods_active' => $payment_methods_active,
|
||||
'payment_data' => $payment_data,
|
||||
'payment_methods' => $payment_methods['default'],
|
||||
'payment_methods_active' => $payment_methods['active'],
|
||||
'payment_data' => $payment_methods['data'],
|
||||
];
|
||||
return view('web.templates.checkout', $data);
|
||||
}
|
||||
|
||||
private function getPaymentsMethods($is_from){
|
||||
$payment_methods = [];
|
||||
if($is_from !== 'shopping' && Util::getAuthUser()){
|
||||
$user = Util::getAuthUser();
|
||||
$payment_methods['default'] = $user->payment_methods;
|
||||
$payment_methods['data'] = $user->account->payment_data;
|
||||
}else{
|
||||
$payment_methods['default'] = PaymentMethod::getDefaultAsArray()->toArray();
|
||||
$payment_methods['data'] = false;
|
||||
}
|
||||
|
||||
$payment_methods['active'] = \App\Models\PaymentMethod::where('active', true)->get()->pluck( 'id', 'short')->toArray();
|
||||
return $payment_methods;
|
||||
}
|
||||
|
||||
private function isPaymentsMethodsActive($payment_method, $is_from){
|
||||
$payment_names = ['wlt#PPE' => 'PP', 'cc' => 'CC', 'sb#PNT' => 'SB', 'elv' => 'SEPA', 'vor' => 'VOR', 'fnc#MIV' => 'FNC'];
|
||||
$payment_methods = $this->getPaymentsMethods($is_from);
|
||||
if(isset($payment_names[$payment_method])){
|
||||
$payment_with = $payment_names[$payment_method];
|
||||
if(array_key_exists($payment_with, $payment_methods['active']) && in_array($payment_methods['active'][$payment_with], $payment_methods['default'])){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
abort(404);
|
||||
}
|
||||
|
||||
private function shoppingUserAuthData($is_from, $is_for, $data = []){
|
||||
|
||||
$user = Util::getAuthUser();
|
||||
|
|
@ -217,8 +232,11 @@ class CheckoutController extends Controller
|
|||
|
||||
public function checkoutFinal(){
|
||||
|
||||
|
||||
$data = Request::all();
|
||||
if(isset($data['payment_method'])){
|
||||
$this->isPaymentsMethodsActive($data['payment_method'], $data['is_from']);
|
||||
}
|
||||
|
||||
//change selected Country
|
||||
if(isset($data['selected_country']) && $data['selected_country'] === 'change'){
|
||||
if(!Request::get('same_as_billing')){
|
||||
|
|
@ -541,7 +559,7 @@ class CheckoutController extends Controller
|
|||
'tax_rate' => $item->taxRate,
|
||||
'tax' => $tax,
|
||||
'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id),
|
||||
'discount' => $shopping_order->getUserDiscount(),
|
||||
'discount' => $item->options->no_commission ? 0 : $shopping_order->getUserDiscount(),
|
||||
'points' => $item->options->points,
|
||||
'slug' => $item->options->slug,
|
||||
];
|
||||
|
|
@ -572,7 +590,7 @@ class CheckoutController extends Controller
|
|||
'tax_rate' => $item->taxRate,
|
||||
'tax' => $tax,
|
||||
'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id),
|
||||
'discount' => $shopping_order->getUserDiscount(),
|
||||
'discount' => $item->options->no_commission ? 0 : $shopping_order->getUserDiscount(),
|
||||
'points' => $item->options->points,
|
||||
'slug' => $item->options->slug
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue