10.April 2026
This commit is contained in:
parent
a00c42e770
commit
f58c709945
208 changed files with 19280 additions and 2914 deletions
|
|
@ -403,16 +403,20 @@ class AboController extends Controller
|
|||
$data['step'] = 4;
|
||||
break;
|
||||
case 5:
|
||||
// chekout verarbeiten
|
||||
UserService::setInstance($this->instance);
|
||||
UserService::initCustomerYard($shopping_user, 'abo-ot-customer');
|
||||
if (Request::get('action') == 'checkout') {
|
||||
// checkout verarbeiten
|
||||
if (! $this->preCheckCheckout()) {
|
||||
if (! Request::boolean('abo_order_info_checkbox')) {
|
||||
$data['error'] = __('abo.abo_order_info_checkbox_required');
|
||||
$data['step'] = 4;
|
||||
} elseif (! in_array((int) Request::input('abo_interval'), UserAbo::$aboDeliveryDays, true)) {
|
||||
$data['error'] = __('abo.error_abo_interval');
|
||||
$data['step'] = 4;
|
||||
} elseif (! $this->preCheckCheckout()) {
|
||||
$data['error'] = __('abo.abo_error_basis_product');
|
||||
$data['step'] = 4;
|
||||
} else {
|
||||
$data['checkout_url'] = $this->processCheckout();
|
||||
$data['checkout_url'] = $this->processCheckout($shopping_user);
|
||||
}
|
||||
}
|
||||
$data['step'] = 4;
|
||||
|
|
@ -439,18 +443,9 @@ class AboController extends Controller
|
|||
Shop::initUserShopLang($delivery_country, $this->instance);
|
||||
}
|
||||
|
||||
private function preCheckCheckout()
|
||||
private function preCheckCheckout(): bool
|
||||
{
|
||||
$result = false;
|
||||
// alle inhlate des warenkorb
|
||||
$cartItems = $this->yard->content();
|
||||
foreach ($cartItems as $item) {
|
||||
if (in_array(12, $item->options->show_on)) {
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
return AboHelper::aboHasBaseProduct($this->yard->getContentByOrder());
|
||||
}
|
||||
|
||||
private function checkBasisProduct()
|
||||
|
|
@ -550,7 +545,7 @@ class AboController extends Controller
|
|||
$this->yard->reCalculateShippingPrice();
|
||||
}
|
||||
|
||||
private function processCheckout()
|
||||
private function processCheckout(ShoppingUser $shoppingUser): string
|
||||
{
|
||||
$user_shop = Util::getUserShop();
|
||||
if (! $user_shop) {
|
||||
|
|
@ -560,24 +555,38 @@ class AboController extends Controller
|
|||
$identifier = Util::getToken();
|
||||
} while (ShoppingInstance::where('identifier', $identifier)->count());
|
||||
|
||||
$data = [];
|
||||
$data['is_from'] = 'shopping';
|
||||
$data['user_price_infos'] = $this->yard->getUserPriceInfos();
|
||||
$aboInterval = (int) Request::input('abo_interval', 0);
|
||||
|
||||
$fillable = (new ShoppingUser)->getFillable();
|
||||
$shoppingData = array_merge(
|
||||
array_intersect_key($shoppingUser->getAttributes(), array_flip($fillable)),
|
||||
[
|
||||
'shopping_user_id' => $shoppingUser->id,
|
||||
'is_from' => 'shopping',
|
||||
'is_for' => 'abo-ot-customer',
|
||||
'is_abo' => true,
|
||||
'abo_interval' => $aboInterval,
|
||||
'shipping_is_for' => 'abo-ot-customer',
|
||||
'user_price_infos' => $this->yard->getUserPriceInfos(),
|
||||
'mode' => config('app.mode') === 'test' ? 'test' : 'live',
|
||||
]
|
||||
);
|
||||
|
||||
ShoppingInstance::create([
|
||||
'identifier' => $identifier,
|
||||
'user_shop_id' => $user_shop->id,
|
||||
'payment' => 1, // Customer Shop Payment
|
||||
'payment' => 1,
|
||||
'subdomain' => url('/'),
|
||||
'country_id' => $this->yard->getShippingCountryId(),
|
||||
'language' => \App::getLocale(),
|
||||
'shopping_data' => $data,
|
||||
'language' => $shoppingUser->getLocale(),
|
||||
'amount' => (float) $this->yard->totalWithShipping(2, '.', ''),
|
||||
'shopping_user_id' => $shoppingUser->id,
|
||||
'shopping_data' => $shoppingData,
|
||||
'back' => url()->previous(),
|
||||
|
||||
]);
|
||||
|
||||
$this->yard->store($identifier);
|
||||
// add to DB
|
||||
|
||||
$path = route('checkout.checkout_card', ['identifier' => $identifier]);
|
||||
if (strpos($path, 'https') === false) {
|
||||
$path = str_replace('http', 'https', $path);
|
||||
|
|
|
|||
|
|
@ -8,9 +8,11 @@ use App\Models\ShoppingOrder;
|
|||
use App\Models\ShoppingPayment;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Services\Payment;
|
||||
use App\Services\ProductOrderContext;
|
||||
use App\Services\Shop;
|
||||
use App\Services\Util;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Yard;
|
||||
|
||||
class OrderController extends Controller
|
||||
|
|
@ -192,7 +194,7 @@ class OrderController extends Controller
|
|||
public function myOrderCreate(int $id)
|
||||
{
|
||||
$user = Auth::guard('customers')->user();
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
$shopping_order = ShoppingOrder::with('member.shop')->findOrFail($id);
|
||||
|
||||
if ($shopping_order->shopping_user_id != $user->shopping_user_id) {
|
||||
$shopping_user = ShoppingUser::findOrFail($user->shopping_user_id);
|
||||
|
|
@ -202,6 +204,13 @@ class OrderController extends Controller
|
|||
}
|
||||
|
||||
$shopping_user = ShoppingUser::findOrFail($user->shopping_user_id);
|
||||
|
||||
if ($shopping_order->is_abo) {
|
||||
Session::flash('alert-error', __('order.reorder_abo_not_allowed'));
|
||||
|
||||
return redirect()->route('portal.my_orders.show', $shopping_order->id);
|
||||
}
|
||||
|
||||
$delivery_country = $shopping_user->getDeliveryCountry(true);
|
||||
|
||||
\Session::put('user_init_country', strtolower($delivery_country->code));
|
||||
|
|
@ -211,18 +220,18 @@ class OrderController extends Controller
|
|||
Shop::initUserShopLang($delivery_country, $this->instance);
|
||||
|
||||
foreach ($shopping_order->shopping_order_items as $item) {
|
||||
if ($item->product) {
|
||||
if ($item->product && ProductOrderContext::isProductAllowedInCustomerWebshop($item->product)) {
|
||||
$this->addToCart($item->product_id, $item->qty);
|
||||
}
|
||||
}
|
||||
|
||||
return redirect(Util::getMyMivitaShopUrl('/user/card/show'));
|
||||
return redirect(Util::getCustomerReorderCartUrl($shopping_order));
|
||||
}
|
||||
|
||||
private function addToCart(int $productId, int $quantity = 1): void
|
||||
{
|
||||
$product = Product::find($productId);
|
||||
if (! $product) {
|
||||
if (! $product || ! ProductOrderContext::isProductAllowedInCustomerWebshop($product)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue