10.April 2026

This commit is contained in:
Kevin Adametz 2026-04-10 17:15:27 +02:00
parent 4a8f4b4abc
commit 396d049439
203 changed files with 18098 additions and 2911 deletions

View file

@ -2,46 +2,49 @@
namespace App\Http\Controllers\Web;
use Yard;
use Request;
use App\Http\Controllers\Controller;
use App\Models\Product;
use App\Models\ShoppingInstance;
use App\Models\ShoppingUser;
use App\Services\ProductOrderContext;
use App\Services\Shop;
use App\Services\Util;
use App\Models\Product;
use App\Models\ShoppingUser;
use App\Models\ShoppingInstance;
use App\Http\Controllers\Controller;
use Request;
use Yard;
class CardController extends Controller
{
private $instance = 'webshop';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
}
public function __construct() {}
//Cart::instance('wishlist')->add('sdjk922', 'Product 2', 1, 19.95, ['size' => 'medium']);
// Cart::instance('wishlist')->add('sdjk922', 'Product 2', 1, 19.95, ['size' => 'medium']);
public function addToCardGet($id, $quantity = 1, $product_slug = false)
{
$product = Product::find($id);
if($product){
$image = "";
if($product->images->count()){
if ($product && ProductOrderContext::isProductAllowedInCustomerWebshop($product)) {
$image = '';
if ($product->images->count()) {
$image = $product->images->first()->slug;
}
$cartItem = Yard::instance($this->instance)
->add($product->id, $product->getLang('name'), $quantity,
$product->getPriceWith(Yard::instance($this->instance)->getUserTaxFree(), false, Yard::instance($this->instance)->getUserCountry()), false, false,
['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]);
if(Yard::instance($this->instance)->getUserTaxFree()){
->add(
$product->id,
$product->getLang('name'),
$quantity,
$product->getPriceWith(Yard::instance($this->instance)->getUserTaxFree(), false, Yard::instance($this->instance)->getUserCountry()),
false,
false,
['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]
);
if (Yard::instance($this->instance)->getUserTaxFree()) {
Yard::setTax($cartItem->rowId, 0);
}else{
} else {
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance($this->instance)->getUserCountry()));
}
Yard::instance($this->instance)->reCalculateShippingPrice();
@ -50,7 +53,6 @@ class CardController extends Controller
}
return back();
}
public function addToCardPost($id)
@ -58,39 +60,45 @@ class CardController extends Controller
$product = Product::find($id);
if($product){
$image = "";
if($product->images->count()){
if ($product && ProductOrderContext::isProductAllowedInCustomerWebshop($product)) {
$image = '';
if ($product->images->count()) {
$image = $product->images->first()->slug;
}
$quantity = Request::get('quantity') ? Request::get('quantity') : 1;
$cartItem = Yard::instance($this->instance)
->add($product->id, $product->getLang('name'), $quantity,
$product->getPriceWith(Yard::instance($this->instance)->getUserTaxFree(), false, Yard::instance($this->instance)->getUserCountry()), false, false,
['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]);
if(Yard::instance($this->instance)->getUserTaxFree()){
->add(
$product->id,
$product->getLang('name'),
$quantity,
$product->getPriceWith(Yard::instance($this->instance)->getUserTaxFree(), false, Yard::instance($this->instance)->getUserCountry()),
false,
false,
['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]
);
if (Yard::instance($this->instance)->getUserTaxFree()) {
Yard::setTax($cartItem->rowId, 0);
}else{
} else {
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance($this->instance)->getUserCountry()));
}
Yard::instance($this->instance)->reCalculateShippingPrice();
\Session()->flash('show-card-after-add', true);
}
return back();
}
public function showCard(){
public function showCard()
{
if(Request::get('selected_country')){
if (Request::get('selected_country')) {
Yard::instance($this->instance)->setShippingCountryWithPrice(Request::get('selected_country'));
}else{
} else {
Yard::instance($this->instance)->reCalculateShippingPrice();
}
//show konflikt wenn user eingeloggt ist und country nicht gesetzt ist
// show konflikt wenn user eingeloggt ist und country nicht gesetzt ist
$shipping_error = $this->checkShippingError();
$data = [
'user_shop' => Util::getUserShop(),
@ -98,30 +106,49 @@ class CardController extends Controller
'yard_instance' => $this->instance,
'shipping_error' => $shipping_error ?? false,
];
return view('web.templates.card', $data);
}
public function updateCard(){
public function updateCard()
{
$data = Request::all();
if(isset($data['quantity'])){
foreach ($data['quantity'] as $rowId => $qty){
if (isset($data['quantity'])) {
foreach ($data['quantity'] as $rowId => $qty) {
$cartItem = Yard::instance($this->instance)->get($rowId);
if ($cartItem) {
$product = Product::find($cartItem->id);
if ($product && $product->is_membership_only) {
$qty = 1;
}
}
Yard::instance($this->instance)->update($rowId, $qty);
Yard::instance($this->instance)->reCalculateShippingPrice();
}
}else{
$this->deleteCard();
} else {
$this->deleteCard();
}
return back();
}
public function checkoutServer(){
public function checkoutServer()
{
foreach (Yard::instance($this->instance)->content() as $row) {
$product = Product::find($row->id);
if (! $product || ! ProductOrderContext::isProductAllowedInCustomerWebshop($product)) {
\Session::flash('alert-error', __('msg.cart_product_not_allowed_for_order_type'));
return redirect()->back();
}
}
$user_shop = Util::getUserShop();
do {
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
} while (ShoppingInstance::where('identifier', $identifier)->count());
$data = [];
$data['is_from'] = 'shopping';
@ -130,7 +157,7 @@ class CardController extends Controller
ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => $user_shop->id,
'payment' => 1, //Customer Shop Payment
'payment' => 1, // Customer Shop Payment
'subdomain' => url('/'),
'country_id' => Yard::instance($this->instance)->getShippingCountryId(),
'language' => \App::getLocale(),
@ -138,55 +165,63 @@ class CardController extends Controller
'back' => url()->previous(),
]);
Yard::instance($this->instance)->store($identifier);
//add to DB
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
if(strpos($path, 'https') === false){
// add to DB
$path = route('checkout.checkout_card', ['identifier' => $identifier]);
if (strpos($path, 'https') === false) {
$path = str_replace('http', 'https', $path);
}
return redirect()->secure($path);
}
public function backToShop(){
public function backToShop()
{
$this->deleteCard();
return redirect(url('/'));
return redirect(url('/'));
}
public function removeCard($rowId){
public function removeCard($rowId)
{
Yard::instance($this->instance)->remove($rowId);
return back();
}
public function deleteCard(){
public function deleteCard()
{
$setCode = Shop::getUserShopLang(null, $this->instance);
$mylangs = Shop::getLangChange($this->instance);
foreach($mylangs as $code => $country){
if(strtolower($setCode) === strtolower($code)){
foreach ($mylangs as $code => $country) {
if (strtolower($setCode) === strtolower($code)) {
Shop::initUserShopLang($country, $this->instance);
return back();
}
}
}
private function checkShippingError(){
private function checkShippingError()
{
$shipping_error = false;
if(\Auth::guard('customers')->check()){
if (\Auth::guard('customers')->check()) {
$user = \Auth::guard('customers')->user();
if($user->shopping_user_id){
if ($user->shopping_user_id) {
$shopping_user = ShoppingUser::find($user->shopping_user_id);
if($shopping_user->same_as_billing){
if($shopping_user->billing_country_id != Yard::instance($this->instance)->getUserCountryId()){
if ($shopping_user->same_as_billing) {
if ($shopping_user->billing_country_id != Yard::instance($this->instance)->getUserCountryId()) {
$user_country = Yard::instance($this->instance)->getUserCountry();
$user_country_name = $user_country ? $user_country->getLocated() : '';
$billing_country = $shopping_user->billing_country;
$country_name = $billing_country ? $billing_country->getLocated() : '';
$shipping_error = __('website.shipping_error_billing', ['shipping_country' => $user_country_name, 'billing_country' => $country_name]);
}
}else{
if($shopping_user->shipping_country_id != Yard::instance($this->instance)->getUserCountryId()){
} else {
if ($shopping_user->shipping_country_id != Yard::instance($this->instance)->getUserCountryId()) {
$user_country = Yard::instance($this->instance)->getUserCountry();
$user_country_name = $user_country ? $user_country->getLocated() : '';
$shipping_country = $shopping_user->shipping_country;
@ -194,9 +229,9 @@ class CardController extends Controller
$shipping_error = __('website.shipping_error_delivery', ['shipping_country' => $user_country_name, 'billing_country' => $country_name]);
}
}
}
}
return $shipping_error;
}
}
}

View file

@ -2,26 +2,24 @@
namespace App\Http\Controllers\Web;
use Yard;
use Request;
use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\IqSite;
use App\Models\Product;
use App\Models\ProductCategory;
use App\Services\LocaleGuard;
use App\Services\Shop;
use App\Services\Util;
use App\Models\Product;
use App\Models\Category;
use App\Models\ProductCategory;
use App\Http\Controllers\Controller;
use Request;
class SiteController extends Controller
{
public function index()
{
$this->setIPInfo();
$products = ['aloe-vera-gel-99', 'aloe-vera-saft-500-ml', 'aloe-vera-lippenbalsam'];
// $set_products = ['aloe-vera-cleaner-set', 'aloe-vera-koerper-set', 'aloe-vera-repair-set'];
$set_products = ['aloe-vera-koerper-set', 'baby-set', 'aloe-vera-gel-set'];
$set_products = ['aloe-vera-koerper-set', 'baby-set', 'aloe-vera-gel-set'];
$data = [
'products' => Product::whereIn('slug', $products)->where('active', true)->whereJsonContains('show_on', '1')->get(),
'set_products' => Product::whereIn('slug', $set_products)->where('active', true)->whereJsonContains('show_on', '1')->get(),
@ -34,9 +32,9 @@ class SiteController extends Controller
return view('web.index', $data);
}
public function domainCheck()
public function domainCheck()
{
die("checked");
exit('checked');
}
public function changeLang()
@ -48,8 +46,12 @@ class SiteController extends Controller
if (strtolower($data['change_country_id']) === strtolower($code)) {
\Session::put('user_init_country', strtolower($code));
\Session::forget('user_init_country_options');
\Session::put('locale', strtolower($data['change_locale_id']));
$locale = LocaleGuard::normalize($data['change_locale_id'] ?? null);
if ($locale !== null) {
\Session::put('locale', $locale);
}
Shop::initUserShopLang($country, 'webshop');
return back();
}
}
@ -58,40 +60,41 @@ class SiteController extends Controller
private function setIPinfo()
{
//wurde schon gesetzt //cache
// wurde schon gesetzt //cache
$country = strtolower(Shop::getIPDatabaseInfo());
if (\Session::has('user_init_country')) {
return;
}
if (config('app.ipinfo')) {
$country = strtolower(Shop::getIPDatabaseInfo());
if ($country === 'de') { //$locale de - init AT
if ($country === 'de') { // $locale de - init AT
\Session::put('user_init_country', $country);
return;
}
if ($country === 'error') { //$locale at - init AT
if ($country === 'error') { // $locale at - init AT
$country = 'de';
}
} else {
$country = 'de';
}
//$locale = strtolower(\App::getLocale());
//ist default
// $locale = strtolower(\App::getLocale());
// ist default
//sprache
// sprache
if (array_key_exists($country, \App\Services\UserService::getTransChange())) {
\Session::put('user_init_country', $country);
\Session::put('locale', $country);
\App::setLocale($country);
} else {
//default EN
// default EN
\Session::put('user_init_country', 'de');
\Session::put('locale', 'de');
\App::setLocale('de');
}
//bestelland / versandland
// bestelland / versandland
if (array_key_exists($country, Shop::getLangChange('webshop'))) {
\Session::put('user_init_country_options', $country);
} else {
@ -119,6 +122,7 @@ class SiteController extends Controller
'p_count' => Product::where('active', true)->whereJsonContains('show_on', '1')->count(),
'yard_instance' => 'webshop',
];
return view('web.templates.produkte-show', $data);
}
}
@ -131,7 +135,7 @@ class SiteController extends Controller
$headline_image = $category->iq_image;
}
$product_categories = ProductCategory::where('category_id', $category->id)->whereHas('product', function ($query) use ($category) {
$product_categories = ProductCategory::where('category_id', $category->id)->whereHas('product', function ($query) {
$query->where('active', true)->whereJsonContains('show_on', '1');
})->orderBy('pos', 'DESC')->get();
@ -147,7 +151,8 @@ class SiteController extends Controller
'headline_image' => $headline_image,
'yard_instance' => 'webshop',
];
return view('web.templates.' . $site, $data);
return view('web.templates.'.$site, $data);
}
}
dd($subsite);
@ -163,7 +168,8 @@ class SiteController extends Controller
'headline_image' => false,
'yard_instance' => 'webshop',
];
return view('web.templates.' . $site, $data);
return view('web.templates.'.$site, $data);
}
$data = [
'user_shop' => Util::getUserShop(),
@ -171,14 +177,16 @@ class SiteController extends Controller
'yard_instance' => 'webshop',
];
if ($subsite) {
if (!view()->exists('web.templates.' . $subsite)) {
if (! view()->exists('web.templates.'.$subsite)) {
abort(404);
}
return view('web.templates.' . $subsite, $data);
return view('web.templates.'.$subsite, $data);
}
if (!view()->exists('web.templates.' . $site)) {
if (! view()->exists('web.templates.'.$site)) {
abort(404);
}
return view('web.templates.' . $site, $data);
return view('web.templates.'.$site, $data);
}
}