commit 08-2025
This commit is contained in:
parent
9ae662f63e
commit
480fdc65ed
404 changed files with 65310 additions and 2600431 deletions
|
|
@ -8,11 +8,13 @@ use Request;
|
|||
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;
|
||||
|
||||
class CardController extends Controller
|
||||
{
|
||||
private $instance = 'webshop';
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
|
|
@ -33,16 +35,16 @@ class CardController extends Controller
|
|||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')
|
||||
$cartItem = Yard::instance($this->instance)
|
||||
->add($product->id, $product->getLang('name'), $quantity,
|
||||
$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false,
|
||||
$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('shopping')->getUserTaxFree()){
|
||||
if(Yard::instance($this->instance)->getUserTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance('shopping')->getUserCountry()));
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance($this->instance)->getUserCountry()));
|
||||
}
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
Yard::instance($this->instance)->reCalculateShippingPrice();
|
||||
|
||||
\Session()->flash('show-card-after-add', true);
|
||||
}
|
||||
|
|
@ -62,16 +64,16 @@ class CardController extends Controller
|
|||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$quantity = Request::get('quantity') ? Request::get('quantity') : 1;
|
||||
$cartItem = Yard::instance('shopping')
|
||||
$cartItem = Yard::instance($this->instance)
|
||||
->add($product->id, $product->getLang('name'), $quantity,
|
||||
$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false,
|
||||
$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('shopping')->getUserTaxFree()){
|
||||
if(Yard::instance($this->instance)->getUserTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance('shopping')->getUserCountry()));
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance($this->instance)->getUserCountry()));
|
||||
}
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
Yard::instance($this->instance)->reCalculateShippingPrice();
|
||||
|
||||
\Session()->flash('show-card-after-add', true);
|
||||
}
|
||||
|
|
@ -83,15 +85,18 @@ class CardController extends Controller
|
|||
public function showCard(){
|
||||
|
||||
if(Request::get('selected_country')){
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice(Request::get('selected_country'));
|
||||
Yard::instance($this->instance)->setShippingCountryWithPrice(Request::get('selected_country'));
|
||||
}else{
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
Yard::instance($this->instance)->reCalculateShippingPrice();
|
||||
}
|
||||
|
||||
//show konflikt wenn user eingeloggt ist und country nicht gesetzt ist
|
||||
$shipping_error = $this->checkShippingError();
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'mylangs' => Shop::getLangChange(),
|
||||
|
||||
'mylangs' => Shop::getLangChange($this->instance),
|
||||
'yard_instance' => $this->instance,
|
||||
'shipping_error' => $shipping_error ?? false,
|
||||
];
|
||||
return view('web.templates.card', $data);
|
||||
}
|
||||
|
|
@ -101,8 +106,8 @@ class CardController extends Controller
|
|||
$data = Request::all();
|
||||
if(isset($data['quantity'])){
|
||||
foreach ($data['quantity'] as $rowId => $qty){
|
||||
Yard::instance('shopping')->update($rowId, $qty);
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
Yard::instance($this->instance)->update($rowId, $qty);
|
||||
Yard::instance($this->instance)->reCalculateShippingPrice();
|
||||
}
|
||||
}else{
|
||||
$this->deleteCard();
|
||||
|
|
@ -111,31 +116,30 @@ class CardController extends Controller
|
|||
}
|
||||
|
||||
public function checkoutServer(){
|
||||
|
||||
|
||||
|
||||
$user_shop = Util::getUserShop();
|
||||
|
||||
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while( ShoppingInstance::where('identifier', $identifier)->count() );
|
||||
|
||||
$data = [];
|
||||
$data['is_from'] = 'shopping';
|
||||
$data['user_price_infos'] = Yard::instance('shopping')->getUserPriceInfos();
|
||||
$data['user_price_infos'] = Yard::instance($this->instance)->getUserPriceInfos();
|
||||
|
||||
ShoppingInstance::create([
|
||||
'identifier' => $identifier,
|
||||
'user_shop_id' => $user_shop->id,
|
||||
'payment' => 1, //Customer Shop Payment
|
||||
'subdomain' => url('/'),
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'country_id' => Yard::instance($this->instance)->getShippingCountryId(),
|
||||
'language' => \App::getLocale(),
|
||||
'shopping_data' => $data,
|
||||
'back' => url()->previous(),
|
||||
|
||||
]);
|
||||
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
|
||||
Yard::instance($this->instance)->store($identifier);
|
||||
//add to DB
|
||||
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||
if(strpos($path, 'https') === false){
|
||||
|
|
@ -151,19 +155,48 @@ class CardController extends Controller
|
|||
}
|
||||
public function removeCard($rowId){
|
||||
|
||||
Yard::instance('shopping')->remove($rowId);
|
||||
Yard::instance($this->instance)->remove($rowId);
|
||||
return back();
|
||||
}
|
||||
|
||||
public function deleteCard(){
|
||||
|
||||
$setCode = Shop::getUserShopLang();
|
||||
$mylangs = Shop::getLangChange();
|
||||
$setCode = Shop::getUserShopLang(null, $this->instance);
|
||||
$mylangs = Shop::getLangChange($this->instance);
|
||||
foreach($mylangs as $code => $country){
|
||||
if(strtolower($setCode) === strtolower($code)){
|
||||
Shop::initUserShopLang($country);
|
||||
Shop::initUserShopLang($country, $this->instance);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function checkShippingError(){
|
||||
$shipping_error = false;
|
||||
if(\Auth::guard('customers')->check()){
|
||||
$user = \Auth::guard('customers')->user();
|
||||
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()){
|
||||
$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()){
|
||||
$user_country = Yard::instance($this->instance)->getUserCountry();
|
||||
$user_country_name = $user_country ? $user_country->getLocated() : '';
|
||||
$shipping_country = $shopping_user->shipping_country;
|
||||
$country_name = $shipping_country ? $shipping_country->getLocated() : '';
|
||||
$shipping_error = __('website.shipping_error_delivery', ['shipping_country' => $user_country_name, 'billing_country' => $country_name]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return $shipping_error;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue