20-02-2026

This commit is contained in:
Kevin Adametz 2026-02-20 17:55:06 +01:00
parent a8b395e20d
commit a00c42e770
252 changed files with 28785 additions and 8907 deletions

View file

@ -11,15 +11,14 @@ use App\Models\ShoppingOrder;
use App\Models\ShoppingUser;
use App\Models\UserHistory;
use App\Services\AboHelper;
use App\Services\MyLog;
use App\Services\OrderPaymentService;
use App\Services\Payment;
use App\Services\Shop;
use App\Services\UserService;
use App\Services\Util;
use App\Services\MyLog;
use App\User;
use Auth;
use Illuminate\Http\Request as IlluminateRequest;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Request;
@ -68,20 +67,20 @@ class OrderController extends Controller
$query = ShoppingOrder::with('shopping_user', 'shopping_payments')
->select('shopping_orders.*')
->where('auth_user_id', '=', $user->id)
->where('txaction', '!=', NULL);
->where('txaction', '!=', null);
return \DataTables::eloquent($query)
->addColumn('id', function (ShoppingOrder $ShoppingOrder) {
return '<a href="' . route('user_order_detail', [$ShoppingOrder->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
return '<a href="'.route('user_order_detail', [$ShoppingOrder->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->created_at->format("d.m.Y");
return $ShoppingOrder->created_at->format('d.m.Y');
})
->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
return Payment::getShoppingOrderBadge($ShoppingOrder);
})
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
return '<span class="no-line-break">' . $ShoppingOrder->getFormattedTotalShipping() . " €</span>";
return '<span class="no-line-break">'.$ShoppingOrder->getFormattedTotalShipping().' €</span>';
})
->addColumn('payment', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
@ -89,21 +88,22 @@ class OrderController extends Controller
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
if ($ShoppingOrder->payment_for === 8) {
return '<button type="button" class="btn btn-xs btn-info btn-round" data-toggle="modal" data-target="#modals-load-content"
data-id="' . $ShoppingOrder->id . '"
data-id="'.$ShoppingOrder->id.'"
data-action="shop-user-order-shipping-detail"
data-back=""
data-modal="modal-xl"
data-init_from="user"
data-route="' . route('modal_load') . '"><span class="fa fa-eye"></span></button>';
data-route="'.route('modal_load').'"><span class="fa fa-eye"></span></button>';
}
return '<span class="badge badge-pill badge-' . $ShoppingOrder->getShippedColor() . '">' . $ShoppingOrder->getShippedType() . '</span>';
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
})
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
return Payment::getPaymentForBadge($ShoppingOrder);
})
->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->isInvoice() ? '<span class="no-line-break"><a href="' . route('storage_file', [$ShoppingOrder->id, 'invoice', 'download']) . '" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a>
<a href="' . route('storage_file', [$ShoppingOrder->id, 'invoice', 'stream']) . '" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a></span>' : '-';
return $ShoppingOrder->isInvoice() ? '<span class="no-line-break"><a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a>
<a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a></span>' : '-';
})
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getLastShoppingPayment('reference');
@ -130,16 +130,18 @@ class OrderController extends Controller
$shopping_user = Shop::checkShoppingUser($id, $user);
$delivery_id = $shopping_user->id;
if (!Shop::checkShoppingCountry($for, $delivery_id) && !\Session()->has('custom-error')) {
if (! Shop::checkShoppingCountry($for, $delivery_id) && ! \Session()->has('custom-error')) {
$country = Shop::getDeliveryCountry($for, $delivery_id);
\Session()->flash('custom-error', $country . ": " . __('validation.custom.shipping_not_found'));
\Session()->flash('custom-error', $country.': '.__('validation.custom.shipping_not_found'));
Log::channel(self::LOG_CHANNEL)->error("Shipping country not found for user #{$user->id}, country: {$country}");
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
}
if ($for === 'abo-ot-customer') {
if (AboHelper::hasAboByEmail($shopping_user->billing_email) && !\Session()->has('custom-error')) {
if (AboHelper::hasAboByEmail($shopping_user->billing_email) && ! \Session()->has('custom-error')) {
\Session()->flash('custom-error', __('abo.error_email_has_abo', ['email' => $shopping_user->billing_email]));
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
}
}
@ -150,6 +152,7 @@ class OrderController extends Controller
if (strpos(Request::get('switchers-radio-is-for'), 'ot') !== false) {
$delivery_id = $id;
}
return redirect(route('user_order_my_list', [Request::get('switchers-radio-is-for'), $delivery_id]));
}
@ -183,10 +186,11 @@ class OrderController extends Controller
UserService::initCustomerYard($shopping_user, $for);
} else {
$shipping_country_id = Shop::checkShoppingCountry($for, $id);
if (!$shipping_country_id) {
if (! $shipping_country_id) {
$country = Shop::getDeliveryCountry($for, $id);
\Session()->flash('custom-error', $country . ": " . __('validation.custom.shipping_not_found'));
\Session()->flash('custom-error', $country.': '.__('validation.custom.shipping_not_found'));
Log::channel(self::LOG_CHANNEL)->warning("Shipping country not found for user #{$user->id}, country: {$country}");
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
}
UserService::initUserYard($user, $shipping_country_id, $for);
@ -221,7 +225,6 @@ class OrderController extends Controller
];
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return back()->withErrors($validator)->withInput(Request::all());
}
@ -229,23 +232,23 @@ class OrderController extends Controller
try {
$this->checkSendYardForPayment($data, $id);
} catch (\Exception $e) {
Log::channel(self::LOG_CHANNEL)->error("Error checking yard for payment: " . $e->getMessage(), [
Log::channel(self::LOG_CHANNEL)->error('Error checking yard for payment: '.$e->getMessage(), [
'user_id' => $user->id,
'for' => $for,
'id' => $id
'id' => $id,
]);
return back()->with('error', $e->getMessage());
return back()->withErrors(['error' => $e->getMessage()])->withInput(Request::all());
}
if (Yard::instance('shopping')->getNumComp() > 0) {
if (!isset($data['switchers-comp-product'])) {
if (! isset($data['switchers-comp-product'])) {
$validator->errors()->add('switchers-comp-product', __('msg.please_select_compensation_product'));
} else if (!is_array($data['switchers-comp-product'])) {
} elseif (! is_array($data['switchers-comp-product'])) {
$validator->errors()->add('switchers-comp-product', __('msg.please_select_compensation_product'));
} else if (count($data['switchers-comp-product']) !== Yard::instance('shopping')->getNumComp()) {
} elseif (count($data['switchers-comp-product']) !== Yard::instance('shopping')->getNumComp()) {
$validator->errors()->add('switchers-comp-product', __('mdg.please_select_count_compensation_products', ['count' => Yard::instance('shopping')->getNumComp()]));
}
if ($validator->errors()->count()) {
return back()->withErrors($validator)->withInput(Request::all());
}
@ -268,7 +271,6 @@ class OrderController extends Controller
// Remove unnecessary data
unset($data['quantity']);
unset($data['_token']);
if ($for === 'ot-customer' || $for === 'abo-ot-customer') {
return $this->processCustomerPayment($user, $identifier, $data, $id, $for);
} else {
@ -281,13 +283,14 @@ class OrderController extends Controller
*/
private function processCustomerPayment($user, $identifier, $data, $id, $for)
{
$shopping_user = ShoppingUser::find($id);
$shopping_instance = ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => $user->shop->id,
'payment' => 6, // Berater Shop to Customer Shop
'subdomain' => $user->shop->getSubdomain(),
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'language' => \App::getLocale(),
'language' => $shopping_user->getLocale(), // hier wird die Sprache des Kunden verwendet
'amount' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
'status' => 0,
'shopping_user_id' => $id,
@ -302,9 +305,9 @@ class OrderController extends Controller
try {
$this->customPaymentSendMail($user, $identifier, $yard_shopping_items, $data);
} catch (\Exception $e) {
Log::channel(self::LOG_CHANNEL)->error("Failed to send custom payment email: " . $e->getMessage(), [
Log::channel(self::LOG_CHANNEL)->error('Failed to send custom payment email: '.$e->getMessage(), [
'identifier' => $identifier,
'user_id' => $user->id
'user_id' => $user->id,
]);
}
@ -314,7 +317,7 @@ class OrderController extends Controller
'status' => 1,
'product_id' => null,
'identifier' => $identifier,
'is_abo' => $data['is_abo']
'is_abo' => $data['is_abo'],
]);
return redirect(route('user_order_my_custom_payment', ['identifier' => $identifier]));
@ -333,7 +336,7 @@ class OrderController extends Controller
'payment' => 2, // Berater Shop
'subdomain' => url('/'),
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'language' => \App::getLocale(),
'language' => \App::getLocale(), // das ist richtig, hier wird die App-Locale verwendet da es vom user kommt
'amount' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
'status' => 0,
'shopping_user_id' => $id,
@ -349,10 +352,11 @@ class OrderController extends Controller
'status' => 1,
'product_id' => null,
'identifier' => $identifier,
'is_abo' => $data['is_abo']
'is_abo' => $data['is_abo'],
]);
$path = route('checkout.checkout_card', ['identifier' => $identifier]);
return redirect()->secure($path);
}
@ -369,68 +373,68 @@ class OrderController extends Controller
}
$shipping_country_id = Shop::checkShoppingCountry($data['shipping_is_for'], $id);
if (!$shipping_country_id) {
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
if (! $shipping_country_id) {
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
Yard::instance('shopping')->store($identifier);
$logData = [
'user_id' => Auth::user()->id,
'shopping_user_id' => $id,
'yard_identifier' => $identifier
'yard_identifier' => $identifier,
];
MyLog::writeLog('payment', 'error', 'no shipping_country_id found | Yard identifier: ' . $identifier, $data);
Log::channel(self::LOG_CHANNEL)->error("Shipping country not found", $logData);
MyLog::writeLog('payment', 'error', 'no shipping_country_id found | Yard identifier: '.$identifier, $data);
Log::channel(self::LOG_CHANNEL)->error('Shipping country not found', $logData);
throw new \Exception(__('msg.shipping_country_was_not_found'));
}
// Must be the same shipping country
if ($shipping_country_id != Yard::instance('shopping')->getShippingCountryId()) {
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
Yard::instance('shopping')->store($identifier);
$logData = [
'user_id' => Auth::user()->id,
'shopping_user_id' => $id,
'yard_identifier' => $identifier,
'expected' => $shipping_country_id,
'actual' => Yard::instance('shopping')->getShippingCountryId()
'actual' => Yard::instance('shopping')->getShippingCountryId(),
];
MyLog::writeLog('payment', 'error', 'shipping_country_id is not the same from Yard | Yard identifier: ' . $identifier, $data);
Log::channel(self::LOG_CHANNEL)->error("Shipping country mismatch", $logData);
MyLog::writeLog('payment', 'error', 'shipping_country_id is not the same from Yard | Yard identifier: '.$identifier, $data);
Log::channel(self::LOG_CHANNEL)->error('Shipping country mismatch', $logData);
throw new \Exception(__('msg.shipping_country_was_not_correctly'));
}
if ($data['shipping_is_for'] !== 'ot-customer') {
if (Yard::instance('shopping')->shipping_free) {
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
Yard::instance('shopping')->store($identifier);
$logData = [
'user_id' => Auth::user()->id,
'shopping_user_id' => $id,
'yard_identifier' => $identifier
'yard_identifier' => $identifier,
];
MyLog::writeLog('payment', 'error', 'Yard can by not shipping_free | Yard identifier: ' . $identifier, $data);
Log::channel(self::LOG_CHANNEL)->error("Yard cannot be shipping free", $logData);
MyLog::writeLog('payment', 'error', 'Yard can by not shipping_free | Yard identifier: '.$identifier, $data);
Log::channel(self::LOG_CHANNEL)->error('Yard cannot be shipping free', $logData);
throw new \Exception(__('msg.shopping_cart_was_shipping_free'));
}
}
if ($data['shipping_is_for'] === 'ot-customer') {
if (!$user->shop) {
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
if (! $user->shop) {
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
Yard::instance('shopping')->store($identifier);
$logData = [
'user_id' => Auth::user()->id,
'shopping_user_id' => $id,
'yard_identifier' => $identifier
'yard_identifier' => $identifier,
];
MyLog::writeLog('payment', 'error', 'User has no Shop for an User to Customer order| Yard identifier: ' . $identifier, $data);
Log::channel(self::LOG_CHANNEL)->error("User has no shop for customer order", $logData);
MyLog::writeLog('payment', 'error', 'User has no Shop for an User to Customer order| Yard identifier: '.$identifier, $data);
Log::channel(self::LOG_CHANNEL)->error('User has no shop for customer order', $logData);
throw new \Exception(__('msg.shopping_cart_was_not_user_shop'));
}
@ -438,107 +442,130 @@ class OrderController extends Controller
$shipping_price = Shop::getShippingPriceByShippingCountryId($shipping_country_id, Yard::instance('shopping')->weight());
// For other and has weight - check
// For other and has weight - check
if (strpos($data['shipping_is_for'], 'ot') !== false && $data['shipping_is_for'] !== 'ot-customer' && Yard::instance('shopping')->weight() > 0) {
if (!Yard::instance('shopping')->getShippingPrice() || Yard::instance('shopping')->getShippingPrice() == 0) {
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
Yard::instance('shopping')->store($identifier);
$logData = [
'user_id' => Auth::user()->id,
'shopping_user_id' => $id,
'yard_identifier' => $identifier,
'weight' => Yard::instance('shopping')->weight()
];
// Prüfe ob Versandkostenfreiheit durch Freigrenze legitimiert ist
$shipping_free = Yard::instance('shopping')->getShippingFree();
$total = Yard::instance('shopping')->total(2, '.', '');
$isFreeDueToThreshold = $shipping_free && $total >= $shipping_free && Yard::instance('shopping')->weightByFreeShipping() == 0;
MyLog::writeLog('payment', 'error', 'Yard OT shipping_price is 0 | Yard identifier: ' . $identifier, $data);
Log::channel(self::LOG_CHANNEL)->error("Shipping price cannot be zero for order with weight", $logData);
if (! Yard::instance('shopping')->getShippingPrice() || Yard::instance('shopping')->getShippingPrice() == 0) {
// Nur Fehler werfen, wenn Versandpreis 0 NICHT durch Freigrenze legitimiert ist
if (! $isFreeDueToThreshold) {
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
Yard::instance('shopping')->store($identifier);
$logData = [
'user_id' => Auth::user()->id,
'shopping_user_id' => $id,
'yard_identifier' => $identifier,
'weight' => Yard::instance('shopping')->weight(),
'total' => $total,
'shipping_free' => $shipping_free,
];
throw new \Exception(__('msg.shipping_cost_cannot_be_0'));
MyLog::writeLog('payment', 'error', 'Yard OT shipping_price is 0 | Yard identifier: '.$identifier, $data);
Log::channel(self::LOG_CHANNEL)->error('Shipping price cannot be zero for order with weight', $logData);
throw new \Exception(__('msg.shipping_cost_cannot_be_0'));
}
}
if (Yard::instance('shopping')->getShippingPrice() != $shipping_price->price) {
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
// Preisvergleich nur durchführen, wenn NICHT versandkostenfrei durch Freigrenze
if (! $isFreeDueToThreshold && Yard::instance('shopping')->getShippingPrice() != $shipping_price->price) {
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
Yard::instance('shopping')->store($identifier);
$logData = [
'user_id' => Auth::user()->id,
'shopping_user_id' => $id,
'yard_identifier' => $identifier,
'expected' => $shipping_price->price,
'actual' => Yard::instance('shopping')->getShippingPrice()
'actual' => Yard::instance('shopping')->getShippingPrice(),
];
MyLog::writeLog('payment', 'error', 'Yard OT shipping_price is not the same from shipping_price | Yard identifier: ' . $identifier, $data);
Log::channel(self::LOG_CHANNEL)->error("Shipping price mismatch", $logData);
MyLog::writeLog('payment', 'error', 'Yard OT shipping_price is not the same from shipping_price | Yard identifier: '.$identifier, $data);
Log::channel(self::LOG_CHANNEL)->error('Shipping price mismatch', $logData);
throw new \Exception(__('msg.shipping_costs_were_not_calculated_correctly'));
}
}
if (($data['shipping_is_for'] == 'me' || $data['shipping_is_for'] == 'abo-me') && Yard::instance('shopping')->weight() > 0) {
if (!Yard::instance('shopping')->getShippingPrice() || Yard::instance('shopping')->getShippingPrice() == 0) {
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
Yard::instance('shopping')->store($identifier);
$logData = [
'user_id' => Auth::user()->id,
'shopping_user_id' => $id,
'yard_identifier' => $identifier,
'weight' => Yard::instance('shopping')->weight()
];
// Prüfe ob Versandkostenfreiheit durch Freigrenze legitimiert ist
$shipping_free = Yard::instance('shopping')->getShippingFree();
$total = Yard::instance('shopping')->total(2, '.', '');
$isFreeDueToThreshold = $shipping_free && $total >= $shipping_free && Yard::instance('shopping')->weightByFreeShipping() == 0;
MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is 0 | Yard identifier: ' . $identifier, $data);
Log::channel(self::LOG_CHANNEL)->error("Shipping price cannot be zero for personal order with weight", $logData);
if (! Yard::instance('shopping')->getShippingPrice() || Yard::instance('shopping')->getShippingPrice() == 0) {
// Nur Fehler werfen, wenn Versandpreis 0 NICHT durch Freigrenze legitimiert ist
if (! $isFreeDueToThreshold) {
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
Yard::instance('shopping')->store($identifier);
$logData = [
'user_id' => Auth::user()->id,
'shopping_user_id' => $id,
'yard_identifier' => $identifier,
'weight' => Yard::instance('shopping')->weight(),
'total' => $total,
'shipping_free' => $shipping_free,
];
throw new \Exception(__('msg.shipping_cost_cannot_be_0'));
MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is 0 | Yard identifier: '.$identifier, $data);
Log::channel(self::LOG_CHANNEL)->error('Shipping price cannot be zero for personal order with weight', $logData);
throw new \Exception(__('msg.shipping_cost_cannot_be_0'));
}
}
if (Shop::isCompProducts($data['shipping_is_for'])) {
if (Yard::instance('shopping')->getShippingPrice() != $shipping_price->price_comp) {
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
// Preisvergleich nur durchführen, wenn NICHT versandkostenfrei durch Freigrenze
if (! $isFreeDueToThreshold && Yard::instance('shopping')->getShippingPrice() != $shipping_price->price_comp) {
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
Yard::instance('shopping')->store($identifier);
$logData = [
'user_id' => Auth::user()->id,
'shopping_user_id' => $id,
'yard_identifier' => $identifier,
'expected' => $shipping_price->price_comp,
'actual' => Yard::instance('shopping')->getShippingPrice()
'actual' => Yard::instance('shopping')->getShippingPrice(),
];
MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is not the same from shipping_price with comp products | Yard identifier: ' . $identifier, $data);
Log::channel(self::LOG_CHANNEL)->error("Shipping price mismatch for personal order", $logData);
MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is not the same from shipping_price with comp products | Yard identifier: '.$identifier, $data);
Log::channel(self::LOG_CHANNEL)->error('Shipping price mismatch for personal order', $logData);
throw new \Exception(__('msg.shipping_costs_were_not_calculated_correctly'));
}
if (Yard::instance('shopping')->getNumComp() != $shipping_price->num_comp) {
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
Yard::instance('shopping')->store($identifier);
$logData = [
'user_id' => Auth::user()->id,
'shopping_user_id' => $id,
'yard_identifier' => $identifier,
'expected' => $shipping_price->num_comp,
'actual' => Yard::instance('shopping')->getNumComp()
'actual' => Yard::instance('shopping')->getNumComp(),
];
MyLog::writeLog('payment', 'error', 'Yard num_comp is not correct | Yard identifier: ' . $identifier, $data);
Log::channel(self::LOG_CHANNEL)->error("Compensation product count mismatch", $logData);
MyLog::writeLog('payment', 'error', 'Yard num_comp is not correct | Yard identifier: '.$identifier, $data);
Log::channel(self::LOG_CHANNEL)->error('Compensation product count mismatch', $logData);
throw new \Exception(__('msg.compensation_products_cannot_be_0'));
}
} else {
if (Yard::instance('shopping')->getShippingPrice() != $shipping_price->price) {
$identifier = 'error-' . time() . mt_rand(1000000, 9999999);
// Preisvergleich nur durchführen, wenn NICHT versandkostenfrei durch Freigrenze
if (! $isFreeDueToThreshold && Yard::instance('shopping')->getShippingPrice() != $shipping_price->price) {
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
Yard::instance('shopping')->store($identifier);
$logData = [
'user_id' => Auth::user()->id,
'shopping_user_id' => $id,
'yard_identifier' => $identifier,
'expected' => $shipping_price->price,
'actual' => Yard::instance('shopping')->getShippingPrice()
'actual' => Yard::instance('shopping')->getShippingPrice(),
];
MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is not the same from shipping_price without comp products | Yard identifier: ' . $identifier, $data);
Log::channel(self::LOG_CHANNEL)->error("Shipping price mismatch for personal order", $logData);
MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is not the same from shipping_price without comp products | Yard identifier: '.$identifier, $data);
Log::channel(self::LOG_CHANNEL)->error('Shipping price mismatch for personal order', $logData);
throw new \Exception(__('msg.shipping_costs_were_not_calculated_correctly'));
}
@ -593,15 +620,16 @@ class OrderController extends Controller
$cartItem = Yard::instance('shopping')->getCartItemByProduct($product->id);
$qty = isset($cartItem->qty) ? $cartItem->qty : 0;
$rowId = isset($cartItem->rowId) ? $cartItem->rowId : '';
return '<strong>' . $product->getLang('name') . '</strong><br>
return '<strong>'.$product->getLang('name').'</strong><br>
<div class="no-line-break input-group-min-w">
<div class="input-group d-inline-flex w-auto">
<span class="input-group-prepend">
<button type="button" class="btn btn-secondary icon-btn md-btn-extra remove-product-basket" data-row-id="' . $rowId . '" data-product-id="' . $product->id . '">-</button>
<button type="button" class="btn btn-secondary icon-btn md-btn-extra remove-product-basket" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'">-</button>
</span>
<input type="text" class="form-control text-center input-extra table-input-event-onchange" name="product_qty_' . $product->id . '" data-row-id="' . $rowId . '" data-product-id="' . $product->id . '" value="' . $qty . '">
<input type="text" class="form-control text-center input-extra table-input-event-onchange" name="product_qty_'.$product->id.'" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'" value="'.$qty.'">
<span class="input-group-append">
<button type="button" class="btn btn-secondary icon-btn md-btn-extra add-product-basket" data-row-id="' . $rowId . '" data-product-id="' . $product->id . '">+</button>
<button type="button" class="btn btn-secondary icon-btn md-btn-extra add-product-basket" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'">+</button>
</span>
</div>
</div>';
@ -611,39 +639,40 @@ class OrderController extends Controller
})
->addColumn('picture', function (Product $product) {
if (count($product->images)) {
return '<img class="img-fluid img-extra" alt="" src="' . route('product_image', [$product->images->first()->slug]) . '">';
return '<img class="img-fluid img-extra" alt="" src="'.route('product_image', [$product->images->first()->slug]).'">';
}
return "";
return '';
})
->addColumn('points', function (Product $product) {
return '<span class="no-line-break">' . $product->getFormattedPoints() . '</span>';
return '<span class="no-line-break">'.$product->getFormattedPoints().'</span>';
})
->addColumn('price_net', function (Product $product) {
return '<span class="no-line-break">' . $product->getFormattedPriceWith(true, true, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(true, true, Yard::instance('shopping')->getUserCountry()) . '</span>';
return '<span class="no-line-break">'.$product->getFormattedPriceWith(true, true, Yard::instance('shopping')->getUserCountry()).' €</span>'.'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(true, true, Yard::instance('shopping')->getUserCountry()).'</span>';
})
->addColumn('price_gross', function (Product $product) {
return '<span class="no-line-break">' . $product->getFormattedPriceWith(false, true, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(false, true, Yard::instance('shopping')->getUserCountry()) . '</span>';
return '<span class="no-line-break">'.$product->getFormattedPriceWith(false, true, Yard::instance('shopping')->getUserCountry()).' €</span>'.'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(false, true, Yard::instance('shopping')->getUserCountry()).'</span>';
})
->addColumn('price_vk_gross', function (Product $product) {
return '<span class="no-line-break">' . $product->getFormattedPriceWith(false, false, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(false, false, Yard::instance('shopping')->getUserCountry()) . '</span>';
return '<span class="no-line-break">'.$product->getFormattedPriceWith(false, false, Yard::instance('shopping')->getUserCountry()).' €</span>'.'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(false, false, Yard::instance('shopping')->getUserCountry()).'</span>';
})
->addColumn('customer_price_net', function (Product $product) {
return '<span class="no-line-break">' . $product->getFormattedPriceWith(true, false, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(true, false, Yard::instance('shopping')->getUserCountry()) . '</span>';
return '<span class="no-line-break">'.$product->getFormattedPriceWith(true, false, Yard::instance('shopping')->getUserCountry()).' €</span>'.'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(true, false, Yard::instance('shopping')->getUserCountry()).'</span>';
})
->addColumn('customer_price_gross', function (Product $product) {
return '<span class="no-line-break">' . $product->getFormattedPriceWith(false, false, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(false, false, Yard::instance('shopping')->getUserCountry()) . '</span>';
return '<span class="no-line-break">'.$product->getFormattedPriceWith(false, false, Yard::instance('shopping')->getUserCountry()).' €</span>'.'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(false, false, Yard::instance('shopping')->getUserCountry()).'</span>';
})
->addColumn('my_commission_net', function (Product $product) {
return '<span class="no-line-break">' . $product->getFormattedPriceWith(true, false, Yard::instance('shopping')->getUserCountry(), true) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(true, false, Yard::instance('shopping')->getUserCountry(), true) . '</span>';
return '<span class="no-line-break">'.$product->getFormattedPriceWith(true, false, Yard::instance('shopping')->getUserCountry(), true).' €</span>'.'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(true, false, Yard::instance('shopping')->getUserCountry(), true).'</span>';
})
->addColumn('action', function (Product $product) {
return '<button class="btn btn-default btn-sm icon-btn md-btn-flat product-tooltip" title="details" data-modal="modal-lg"
data-toggle="modal" data-target="#modals-load-content" data-id="' . $product->id . '" data-route="' . route('modal_load') . '"
data-toggle="modal" data-target="#modals-load-content" data-id="'.$product->id.'" data-route="'.route('modal_load').'"
data-action="user-order-show-product" data-view="customer"><i class="ion ion-md-eye"></i></button>';
})
->filterColumn('product', function ($query, $keyword) {
if ($keyword != "") {
$query->where('name', 'LIKE', '%' . $keyword . '%');
if ($keyword != '') {
$query->where('name', 'LIKE', '%'.$keyword.'%');
}
})
->orderColumn('name', 'name $1')
@ -668,8 +697,9 @@ class OrderController extends Controller
*/
public function performRequest()
{
if (!Request::ajax()) {
Log::channel(self::LOG_CHANNEL)->warning("Non-AJAX request to performRequest method");
if (! Request::ajax()) {
Log::channel(self::LOG_CHANNEL)->warning('Non-AJAX request to performRequest method');
return response()->json(['response' => false, 'message' => 'Only AJAX requests are allowed']);
}
@ -678,9 +708,9 @@ class OrderController extends Controller
$data['for'] = $is_for;
$data['comp_products'] = Shop::getCompProducts($is_for);
Log::channel(self::LOG_CHANNEL)->info("Performing cart action", [
Log::channel(self::LOG_CHANNEL)->info('Performing cart action', [
'action' => $data['action'] ?? 'unknown',
'is_for' => $is_for
'is_for' => $is_for,
]);
if ($data['action'] === 'updateCart' && isset($data['product_id'])) {
@ -689,6 +719,7 @@ class OrderController extends Controller
if ($data['action'] === 'clearCart') {
Yard::instance('shopping')->destroy();
return response()->json(['response' => true, 'data' => Yard::instance('shopping')->count(), 'html_card' => '', 'html_comp' => '']);
}
@ -700,7 +731,8 @@ class OrderController extends Controller
return $this->handleUpdateCompProduct($data, $is_for);
}
Log::channel(self::LOG_CHANNEL)->warning("Unknown action in performRequest", ['action' => $data['action'] ?? 'not set']);
Log::channel(self::LOG_CHANNEL)->warning('Unknown action in performRequest', ['action' => $data['action'] ?? 'not set']);
return response()->json(['response' => false, 'data' => $data]);
}
@ -710,12 +742,13 @@ class OrderController extends Controller
private function handleUpdateCart($data, $is_for)
{
$product = Product::find($data['product_id']);
if (!$product) {
Log::channel(self::LOG_CHANNEL)->warning("Product not found for cart update", ['product_id' => $data['product_id']]);
if (! $product) {
Log::channel(self::LOG_CHANNEL)->warning('Product not found for cart update', ['product_id' => $data['product_id']]);
return response()->json(['response' => false, 'message' => 'Product not found']);
}
$image = "";
$image = '';
if ($product->images->count()) {
$image = $product->images->first()->slug;
}
@ -730,7 +763,7 @@ class OrderController extends Controller
round($product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), 1),
false,
false,
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping, 'show_on' => $product->show_on]
);
} else {
$cartItem = Yard::instance('shopping')
@ -741,7 +774,7 @@ class OrderController extends Controller
$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), true, Yard::instance('shopping')->getUserCountry()),
false,
false,
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping, 'show_on' => $product->show_on]
);
}
@ -761,8 +794,8 @@ class OrderController extends Controller
Yard::instance('shopping')->reCalculateShippingPrice();
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
$html_card = view("user.order.yard_view_form", $data)->render();
$html_comp = view("user.order.comp_product", $data)->render();
$html_card = view('user.order.yard_view_form', $data)->render();
$html_comp = view('user.order.comp_product', $data)->render();
return response()->json(['response' => true, 'data' => $data, 'html_card' => $html_card, 'html_comp' => $html_comp]);
}
@ -778,14 +811,14 @@ class OrderController extends Controller
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country->id, $is_for);
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
} else {
Log::channel(self::LOG_CHANNEL)->warning("Shipping country not found", [
'shipping_country_id' => $data['shipping_country_id']
Log::channel(self::LOG_CHANNEL)->warning('Shipping country not found', [
'shipping_country_id' => $data['shipping_country_id'],
]);
}
}
$html_card = view("user.order.yard_view_form", $data)->render();
$html_comp = view("user.order.comp_product", $data)->render();
$html_card = view('user.order.yard_view_form', $data)->render();
$html_comp = view('user.order.comp_product', $data)->render();
return response()->json(['response' => true, 'data' => $data, 'html_card' => $html_card, 'html_comp' => $html_comp]);
}
@ -798,8 +831,8 @@ class OrderController extends Controller
$this->updateCompProduct($data);
Yard::instance('shopping')->reCalculateShippingPrice();
$html_card = view("user.order.yard_view_form", $data)->render();
$html_comp = view("user.order.comp_product", $data)->render();
$html_card = view('user.order.yard_view_form', $data)->render();
$html_comp = view('user.order.comp_product', $data)->render();
return response()->json(['response' => true, 'data' => $data, 'html_card' => $html_card, 'html_comp' => $html_comp]);
}
@ -826,8 +859,8 @@ class OrderController extends Controller
foreach (Yard::instance('shopping')->content() as $row) {
// If count_comp_products is smaller, the product was removed due to quantity
// if comp_num equals the comp product, the product was removed due to new shipping costs
//count_comp_products wie viele comp products werden gebraucht
//comp_num welches comp product wird hinzugefügt
// count_comp_products wie viele comp products werden gebraucht
// comp_num welches comp product wird hinzugefügt
if ($row->options->comp && ($row->options->comp == intval($data['comp_num']) || $row->options->comp > intval($data['count_comp_products']))) {
Yard::instance('shopping')->remove($row->rowId);
}
@ -836,7 +869,7 @@ class OrderController extends Controller
if (isset($data['comp_product_id'])) {
$product = Product::find($data['comp_product_id']);
if ($product) {
$image = "";
$image = '';
if ($product->images->count()) {
$image = $product->images->first()->slug;
}
@ -853,14 +886,14 @@ class OrderController extends Controller
'weight' => 0,
'points' => 0,
'comp' => intval($data['comp_num']),
'product_id' => $product->id
'product_id' => $product->id,
]
);
Yard::setTax($cartItem->rowId, 0);
} else {
Log::channel(self::LOG_CHANNEL)->warning("Compensation product not found", [
'comp_product_id' => $data['comp_product_id']
Log::channel(self::LOG_CHANNEL)->warning('Compensation product not found', [
'comp_product_id' => $data['comp_product_id'],
]);
}
}
@ -873,9 +906,10 @@ class OrderController extends Controller
{
try {
$data = OrderPaymentService::getCustomPayment($identifier);
return view('user.order.payment.custom_payment', $data);
} catch (\Exception $e) {
Log::channel(self::LOG_CHANNEL)->error("Error accessing custom payment: " . $e->getMessage(), ['identifier' => $identifier]);
Log::channel(self::LOG_CHANNEL)->error('Error accessing custom payment: '.$e->getMessage(), ['identifier' => $identifier]);
abort(404, 'Custom payment not found');
}
}
@ -888,22 +922,22 @@ class OrderController extends Controller
$bcc = [];
$shopping_instance = ShoppingInstance::where('identifier', $identifier)->first();
if (!$shopping_instance) {
Log::channel(self::LOG_CHANNEL)->error("Shopping instance not found for email", ['identifier' => $identifier]);
if (! $shopping_instance) {
Log::channel(self::LOG_CHANNEL)->error('Shopping instance not found for email', ['identifier' => $identifier]);
throw new \Exception(__('msg.shopping_instance_not_found'));
}
$shopping_user = $data['shopping_user_id'] ? ShoppingUser::find($data['shopping_user_id']) : null;
if (!$shopping_user) {
Log::channel(self::LOG_CHANNEL)->error("Shopping user not found for email", ['shopping_user_id' => $data['shopping_user_id']]);
if (! $shopping_user) {
Log::channel(self::LOG_CHANNEL)->error('Shopping user not found for email', ['shopping_user_id' => $data['shopping_user_id']]);
throw new \Exception(__('msg.shopping_user_not_found'));
}
$route = route('checkout.checkout_card', ['identifier' => $identifier]);
$billing_email = $shopping_user->billing_email;
if (!$billing_email) {
if (! $billing_email) {
$billing_email = $data['mode'] === 'test' ? config('app.checkout_test_mail') : config('app.checkout_mail');
}