Country Prices | Homeparty | Shop | Order

This commit is contained in:
Kevin Adametz 2021-08-27 18:53:12 +02:00
parent 51d81d8ec6
commit 39d1e93416
284 changed files with 784 additions and 216 deletions

View file

@ -2,18 +2,20 @@
namespace App\Http\Controllers;
use App\Mail\MailInfo;
use App\Models\Product;
use App\Models\ShoppingInstance;
use App\Models\UserHistory;
use App\User;
use Auth;
use Carbon;
use Config;
use Illuminate\Validation\Rules\In;
use Request;
use Util;
use Yard;
use Carbon;
use Config;
use Request;
use App\User;
use App\Mail\MailInfo;
use App\Models\Product;
use App\Models\UserHistory;
use App\Services\UserService;
use App\Models\ShippingCountry;
use App\Models\ShoppingInstance;
use Illuminate\Validation\Rules\In;
use Illuminate\Support\Facades\Mail;
@ -43,6 +45,13 @@ class MembershipController extends Controller
$userHistoryUpgradeOrder = UserHistory::whereUserId($user->id)->whereAction('upgrade_order')->get()->last();
$userHistoryDeleteMembership = UserHistory::whereUserId($user->id)->whereAction('delete_membership')->whereStatus(50)->get()->last();
$shipping_country_id = $this->checkShoppingCountry($user);
if(!$shipping_country_id){
abort(403, __('validation.custom.shipping_not_found'));
}
UserService::checkUserTaxShippingCountry($user, $shipping_country_id);
$data = [
'user' => $user,
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
@ -51,11 +60,27 @@ class MembershipController extends Controller
'userHistoryPaymentOrder' => $userHistoryPaymentOrder,
'userHistoryUpgradeOrder' => $userHistoryUpgradeOrder,
'userHistoryDeleteMembership' => $userHistoryDeleteMembership,
'yard_info' => UserService::getYardInfo(),
];
return view('user.membership.index', $data);
}
private function checkShoppingCountry($user ){
$country_id = null;
if($user->account->same_as_billing){
$country_id = $user->account->country_id;
}else{
$country_id = $user->account->shipping_country_id;
}
if($country_id){
if($shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
return $shipping_country->id;
}
}
return false;
}
public function storePayment($action){
@ -90,13 +115,29 @@ class MembershipController extends Controller
$user->abo_options = true;
$user->save();
}
$shipping_country_id = $this->checkShoppingCountry($user);
if(!$shipping_country_id){
abort(403, __('validation.custom.shipping_not_found'));
}
UserService::checkUserTaxShippingCountry($user, $shipping_country_id);
Yard::instance('shopping')->setUserPriceInfos(UserService::getYardInfo());
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country_id);
if($product && $product->active){
$image = "";
if($product->images->count()){
$image = $product->images->first()->slug;
}
$qty = Request::get('qty') ? Request::get('qty') : 1;
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
if(\App\Services\UserService::getTaxFree()){
Yard::setTax($cartItem->rowId, 0);
}else{
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
}
do {
$identifier = Util::getToken();
@ -105,6 +146,7 @@ class MembershipController extends Controller
$data = [];
$data['is_from'] = 'membership';
$data['is_for'] = 'me';
$data['user_price_infos'] = \App\Services\UserService::getUserPriceInfos();
ShoppingInstance::create([
'identifier' => $identifier,

View file

@ -460,7 +460,8 @@ class HomepartyController extends Controller
$date = date('d.m.Y H:i:s', $time);
$user = User::find(Auth::user()->id);
Yard::instance('shopping')->destroy();
Yard::instance('shopping')->add($homeparty->id, 'Bestellung Homeparty '.$date, 1, \App\Services\HomepartyCart::$ek_price, ['image' => "", 'slug' => $time, 'weight' => 0]);
$cartItem = Yard::instance('shopping')->add($homeparty->id, 'Bestellung Homeparty '.$date, 1, \App\Services\HomepartyCart::$ek_price, ['image' => "", 'slug' => $time, 'weight' => 0]);
Yard::setTax($cartItem->rowId, 0);
do {
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
@ -469,10 +470,22 @@ class HomepartyController extends Controller
$data = [];
$data['is_from'] = 'homeparty';
$data['shop_price_net'] = HomepartyCart::getFormattedEkPriceNet();
$data['shop_price_tax'] = HomepartyCart::getFormattedEkPriceTax();
if($homeparty->getCardInfo('user_tax_free')){
$data['shop_price'] = HomepartyCart::getFormattedEkPrice();
$data['shop_price_net'] = HomepartyCart::getFormattedEkPrice();
$data['shop_price_tax'] = 0;
$data['user_tax_free'] = true;
}else{
$data['shop_price'] = HomepartyCart::getFormattedEkPrice();
$data['shop_price_net'] = HomepartyCart::getFormattedEkPriceNet();
$data['shop_price_tax'] = HomepartyCart::getFormattedEkPriceTax();
$data['user_tax_free'] = false;
}
$data['homeparty_id'] = $homeparty->id;
$data['is_for'] = 'hp';
$data['user_price_infos'] = $homeparty->card_info;
ShoppingInstance::create([
'identifier' => $identifier,

View file

@ -251,7 +251,10 @@ class OrderController extends Controller
}
if($country_id){
if($shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
return $shipping_country->id;
if($shipping_country->shipping && $shipping_country->shipping->active){
return $shipping_country->id;
}
}
}
return false;

View file

@ -3,12 +3,13 @@
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Product;
use App\Models\ShoppingInstance;
use App\Services\Util;
use Yard;
use Request;
use App\Services\Shop;
use App\Services\Util;
use App\Models\Product;
use App\Models\ShoppingInstance;
use App\Http\Controllers\Controller;
class CardController extends Controller
{
@ -32,8 +33,12 @@ class CardController extends Controller
if($product->images->count()){
$image = $product->images->first()->slug;
}
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product_slug, 'weight' => $product->weight]);
Yard::setTax($cartItem->rowId, $product->tax);
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
if(Yard::instance('shopping')->getUserTaxFree()){
Yard::setTax($cartItem->rowId, 0);
}else{
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance('shopping')->getUserCountry()));
}
Yard::instance('shopping')->reCalculateShippingPrice();
\Session()->flash('show-card-after-add', true);
@ -55,7 +60,12 @@ class CardController extends Controller
}
$quantity = Request::get('quantity') ? Request::get('quantity') : 1;
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
Yard::setTax($cartItem->rowId, $product->tax);
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
if(Yard::instance('shopping')->getUserTaxFree()){
Yard::setTax($cartItem->rowId, 0);
}else{
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance('shopping')->getUserCountry()));
}
Yard::instance('shopping')->reCalculateShippingPrice();
\Session()->flash('show-card-after-add', true);
@ -74,6 +84,8 @@ class CardController extends Controller
}
$data = [
'user_shop' => Util::getUserShop(),
'mylangs' => Shop::getLangChange(),
];
return view('web.templates.card', $data);
}
@ -103,6 +115,8 @@ class CardController extends Controller
$data = [];
$data['is_from'] = 'shopping';
$data['user_price_infos'] = Yard::instance('shopping')->getUserPriceInfos();
ShoppingInstance::create([
'identifier' => $identifier,

View file

@ -89,6 +89,13 @@ class CheckoutController extends Controller
$shopping_user->same_as_billing = false;
}
if(!$shopping_user->billing_country){
$shopping_user->billing_country = Yard::instance('shopping')->getUserCountry();
}
if(!$shopping_user->shipping_country){
$shopping_user->shipping_country = Yard::instance('shopping')->getUserCountry();
}
if(old('selected_country') && old('selected_country') === 'change'){
\Session::forget('_old_input.selected_country');
$shopping_user->billing_state = old('billing_state');
@ -479,7 +486,7 @@ class CheckoutController extends Controller
'subtotal_ws' => 0,
'tax' => 0,
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
'points' => $homeparty->order['points'],
'points' => $homeparty->order['points'] - $homeparty->order['bonus_points_diff'],
'weight' => 0,
'txaction' => 'prev',
'mode' => Util::getUserShoppingMode(),

View file

@ -3,13 +3,14 @@
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Mail\MailContact;
use GuzzleHttp\Client;
use Request;
use Illuminate\Support\Facades\Mail;
use App\Services\Util;
use Validator;
use App\Services\Shop;
use App\Services\Util;
use GuzzleHttp\Client;
use App\Mail\MailContact;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Mail;
class ContactController extends Controller
@ -27,11 +28,14 @@ class ContactController extends Controller
}
public function create()
{
$data = [
'GOOGLE_ReCAPTCHA_KEY' => $this->GOOGLE_ReCAPTCHA_KEY,
'user_shop' => Util::getUserShop(),
'mylangs' => Shop::getLangChange(),
];
return view('web.templates.kontakt', $data);
}
@ -91,6 +95,7 @@ class ContactController extends Controller
$data = [
'user_shop' => Util::getUserShop(),
'mylangs' => Shop::getLangChange(),
];
return view('web.templates.contact-final', $data);

View file

@ -3,35 +3,29 @@
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Models\Category;
use Yard;
use Request;
use App\Models\IqSite;
use App\Models\Product;
use App\Models\ProductCategory;
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;
class SiteController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
}
public function index()
{
$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'];
$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(),
'user_shop' => Util::getUserShop(),
'mylangs' => Shop::getLangChange(),
'site' => IqSite::find(1),
];
return view('web.index', $data);
@ -40,6 +34,20 @@ class SiteController extends Controller
public function domainCheck(){
die("checked");
}
public function changeLang(){
$data = Request::all();
if(isset($data['change_country_id'])){
$mylangs = Shop::getLangChange();
foreach($mylangs as $code => $country){
if(strtolower($data['change_country_id']) === strtolower($code)){
Shop::initUserShopLang($country);
return back();
}
}
}
}
public function site($site, $subsite = false, $product_slug = false)
{
$subsite = trim($subsite, '/');
@ -52,11 +60,11 @@ class SiteController extends Controller
$data = [
'user_shop' => Util::getUserShop(),
'mylangs' => Shop::getLangChange(),
'subsite' => $subsite,
'categories' => Category::where('active', true)->orderBy('pos', 'ASC')->get(),
'product' => $product,
'p_count' => Product::where('active', true)->whereJsonContains('show_on', '1')->count(),
];
return view('web.templates.produkte-show', $data);
}
@ -79,6 +87,7 @@ class SiteController extends Controller
$data = [
'user_shop' => Util::getUserShop(),
'mylangs' => Shop::getLangChange(),
'subsite' => $subsite,
'categories' => Category::where('active', true)->orderBy('pos', 'DESC')->get(),
'products' => false,
@ -93,6 +102,7 @@ class SiteController extends Controller
}
$data = [
'user_shop' => Util::getUserShop(),
'mylangs' => Shop::getLangChange(),
'subsite' => 'alle-produkte',
'categories' => Category::where('active', true)->orderBy('pos', 'DESC')->get(),
'products' => Product::where('active', true)->whereJsonContains('show_on', '1')->orderBy('pos', 'DESC')->get(),
@ -104,7 +114,8 @@ class SiteController extends Controller
return view('web.templates.'.$site, $data);
}
$data = [
'user_shop' => Util::getUserShop()
'user_shop' => Util::getUserShop(),
'mylangs' => Shop::getLangChange(),
];
if($subsite){
if(!view()->exists('web.templates.'.$subsite)){

View file

@ -2,21 +2,23 @@
namespace App\Http\Controllers;
use App\Mail\MailReleaseAccount;
use App\Models\File;
use App\Models\Product;
use App\Models\ShoppingInstance;
use App\Models\UserAccount;
use App\Models\UserHistory;
use App\Repositories\FileRepository;
use App\Services\Util;
use App\User;
use Auth;
use Hash;
use Illuminate\Support\Facades\Mail;
use Request;
use Validator;
use Yard;
use Request;
use App\User;
use Validator;
use App\Models\File;
use App\Services\Util;
use App\Models\Product;
use App\Models\UserAccount;
use App\Models\UserHistory;
use App\Services\UserService;
use App\Models\ShippingCountry;
use App\Mail\MailReleaseAccount;
use App\Models\ShoppingInstance;
use App\Repositories\FileRepository;
use Illuminate\Support\Facades\Mail;
class WizardController extends Controller
{
@ -120,14 +122,25 @@ class WizardController extends Controller
$userHistoryWizardPayment = UserHistory::whereUserId($user->id)->whereAction('wizard_payment')->get()->last();
$shipping_country_id = $this->checkShoppingCountry($user);
if(!$shipping_country_id){
abort(403, __('validation.custom.shipping_not_found'));
}
UserService::checkUserTaxShippingCountry($user, $shipping_country_id);
//Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country_id, $for);
//Yard::instance('shopping')->setUserPriceInfos(UserService::getYardInfo());
$data = [
'user' => Auth::user(),
'step' => 0,
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),
'userHistoryWizardPayment' => $userHistoryWizardPayment,
'yard_info' => UserService::getYardInfo(),
];
if($user->wizard == 20){
return view('user.wizard.register_payment', $data);
}
@ -135,6 +148,22 @@ class WizardController extends Controller
return redirect(route('/'));
}
private function checkShoppingCountry($user ){
$country_id = null;
if($user->account->same_as_billing){
$country_id = $user->account->country_id;
}else{
$country_id = $user->account->shipping_country_id;
}
if($country_id){
if($shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
return $shipping_country->id;
}
}
return false;
}
public function storeRegister($step = false)
{
@ -433,13 +462,29 @@ class WizardController extends Controller
$user->save();
}
$shipping_country_id = $this->checkShoppingCountry($user);
if(!$shipping_country_id){
abort(403, __('validation.custom.shipping_not_found'));
}
UserService::checkUserTaxShippingCountry($user, $shipping_country_id);
Yard::instance('shopping')->setUserPriceInfos(UserService::getYardInfo());
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country_id);
if($product && $product->active){
//set membership product
$image = "";
if($product->images->count()){
$image = $product->images->first()->slug;
}
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
if(\App\Services\UserService::getTaxFree()){
Yard::setTax($cartItem->rowId, 0);
}else{
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
}
//set onboarding products
if(Request::get('products_on_board')){
@ -449,7 +494,12 @@ class WizardController extends Controller
if($product_on_board->images->count()){
$image = $product_on_board->images->first()->slug;
}
Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->price, ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight]);
$cartItem = Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight]);
if(\App\Services\UserService::getTaxFree()){
Yard::setTax($cartItem->rowId, 0);
}else{
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
}
}
}
@ -457,11 +507,10 @@ class WizardController extends Controller
$identifier = Util::getToken();
} while( ShoppingInstance::where('identifier', $identifier)->count() );
$data = [];
$data['is_from'] = 'wizard';
$data['is_for'] = 'me';
$data['user_price_infos'] = \App\Services\UserService::getUserPriceInfos();
ShoppingInstance::create([
'identifier' => $identifier,

View file

@ -342,11 +342,54 @@ class Product extends Model
return $ctax !== null ? $ctax : $tax;
}
public function getFormattedPriceOldWith(Bool $net = true, Bool $ufactor = true, $country = null)
{
$price = isset($this->attributes['price_old']) ? $this->attributes['price_old'] : null;
$cprice = $country ? $this->getCPriceOld($country) : null;
$price = $cprice ? $cprice : $price;
$price = $net ? $this->calcPriceNet($price, $country) : $price;
$price = $ufactor ? $this->calcPriceUserFactor($price) : $price;
$price = round($price, 2);
return isset($price) ? Util::formatNumber($price) : "";
}
public function getFormattedTax($country = null)
{
return isset($this->attributes['tax']) ? Util::formatNumber($this->getTaxWith($country), 0) : "";
}
public function getBasePriceFormattedFullWith(Bool $net = true, Bool $ufactor = true, $country = null){
$price = $this->getPriceWith($net, $ufactor, $country);
if($price = $this->getBasePriceWith($price)){
$unit = $this->attributes['unit'];
//ml g
if($unit === 1 || $unit === 2){
return Util::formatNumber($price) . ' € / 100 '.$this->getUnitType();
}
//l kg
if($unit === 3 || $unit === 4){
return Util::formatNumber($price) . ' € / 1 '.$this->getUnitType();
}
}
return "";
}
public function getBasePriceWith($price){
if(isset($this->attributes['unit']) && isset($this->attributes['contents_total']) && $this->attributes['contents_total'] != 0){
$unit = $this->attributes['unit'];
//ml g
if($unit === 1 || $unit === 2){
return $price * 100 / $this->attributes['contents_total'];
}
//l kg
if($unit === 3 || $unit === 4){
return $price * 1000 / $this->attributes['contents_total'];
}
}
return "";
}
public function getBasePriceFormattedFull(){
if($price = $this->getBasePrice()){
$unit = $this->attributes['unit'];
@ -383,6 +426,8 @@ class Product extends Model
}
return "";
}
public function getUnitType(){
return isset($this->unitTypes[$this->unit]) ? $this->unitTypes[$this->unit] : '-';
}

View file

@ -276,6 +276,11 @@ class HomepartyCart
'voucher_price' => self::$voucher_price,
'voucher_name' => self::$voucher_name,
];
if(self::$homeparty->getCardInfo('user_tax_free')){
$data['price_net'] = round(self::$price, 2);
$data['ek_price_net'] = round(self::$ek_price, 2);
$data['shipping_price_net'] = self::$shipping_total;
}
$user_data = [];
foreach (self::$homeparty->homeparty_users as $homeparty_user){
@ -439,6 +444,7 @@ class HomepartyCart
case 'EkPriceTax':
$rNumber = (self::$ek_price - self::$ek_price_net)* $faktor;
break;
}
}

View file

@ -2,14 +2,6 @@
namespace App\Services;
use App\Models\HomepartyUser;
use App\Models\Product;
use App\Models\ShippingCountry;
use \Gloudemans\Shoppingcart\Cart;
use Gloudemans\Shoppingcart\CartItem;
use Gloudemans\Shoppingcart\Contracts\Buyable;
use Illuminate\Session\SessionManager;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Support\Collection;
class HomepartyUserCart
@ -101,6 +93,11 @@ class HomepartyUserCart
return formatNumber($this->ek_price);
}
public function getFormattedEkPriceWithout()
{
return formatNumber($this->ek_price - $this->shipping_price);
}
public function getFormattedIncomePrice()
{
return formatNumber($this->income_price);
@ -146,6 +143,9 @@ class HomepartyUserCart
case 'EkPrice':
$rNumber = $this->ek_price * $faktor;
break;
case 'EkPriceWithout':
$rNumber = ($this->ek_price - $this->shipping_price) * $faktor;
break;
}
}

View file

@ -2,13 +2,18 @@
namespace App\Services;
use Yard;
use App\Models\Country;
use App\Models\ShippingCountry;
use App\Models\ShoppingUser;
use Gloudemans\Shoppingcart\CartItem;
use App\Models\ShippingCountry;
class Shop
{
public static $user_country;
public static $shipping_country;
public static $user_tax_free;
public static $user_reverse_charge = false;
public static function userOrders() {
$shopping_users = ShoppingUser::whereHas('shopping_order', function($q) {
$q->where('txaction', 'paid')->OrWhere('txaction', 'appointed')->OrWhere('txaction', 'extern')->OrWhere('txaction', 'invoice_open')->OrWhere('txaction', 'invoice_paid');
@ -60,4 +65,66 @@ class Shop
return ShippingCountry::all()->first()->id;
}
public static function getLangChange(){
$ret = [];
$countries = Country::whereActive(true)->whereSwitch(true)->get();
$first_country = null;
foreach($countries as $country){
$ShippingCountry = ShippingCountry::whereCountryId($country->id)->first();
if($ShippingCountry && $ShippingCountry->shipping && $ShippingCountry->shipping->active){
if(!$first_country){
$first_country = $country;
}
$ret[strtolower($country->code)] = $country;
}
}
Shop::getUserShopLang($first_country);
return $ret;
}
public static function getUserShopLang($country = null){
if(\Session::has('user_shop_lang')){
if($user_shop_lang = \Session::get('user_shop_lang')){
return $user_shop_lang;
}
}
if($country){
Shop::initUserShopLang($country);
return strtolower($country->code);
}
return false;
}
public static function initUserShopLang($country){
Yard::instance('shopping')->destroy();
\Session::put('user_shop_lang', strtolower($country->code));
//init Yard
self::initUserShopYard($country);
}
public static function initUserShopYard($country){
//Lieferadresse im Drittland?
self::$user_tax_free = $country->supply_country ? true : false;
$ShippingCountry = ShippingCountry::whereCountryId($country->id)->first();
self::$shipping_country = $ShippingCountry;
self::$user_country = $country;
Yard::instance('shopping')->setShippingCountryWithPrice($ShippingCountry->id);
Yard::instance('shopping')->setUserPriceInfos(Shop::getYardInfo());
}
public static function getYardInfo(){
return [
'user_tax_free' => self::$user_tax_free,
'user_reverse_charge' => self::$user_reverse_charge,
'user_country_id' => self::$user_country->id,
'shipping_country_id' => self::$shipping_country->id,
];
}
}

View file

@ -67,6 +67,18 @@ class UserService
];
}
public static function getTaxFree(){
return self::$user_tax_free ? true : false;
}
public static function getUserPriceInfos(){
return [
'user_tax_free' => self::$user_tax_free,
'user_reverse_charge' => self::$user_reverse_charge,
'user_country_id' => self::$user_country->id,
];
}
public static function getOrderInfo($key = false){
switch ($key) {

View file

@ -1,9 +1,11 @@
<?php
namespace App\Services;
use Yard;
use App\Models\Country;
use App\Models\UserHistory;
use Illuminate\Support\Str;
use Yard;
use App\Models\ShippingCountry;
class Util
{

View file

@ -189,7 +189,7 @@ class Yard extends Cart
public function getUserTaxFree()
{
return $this->user_tax_free;
return $this->user_tax_free ? true : false;
}
private function calculateShippingPrice(){
@ -505,6 +505,9 @@ class Yard extends Cart
case 'subtotal':
$rNumber = (float) ($this->subtotal(2, '.', '')) * $faktor;
break;
case 'price':
$rNumber = (float) $row->price * $faktor;
break;
case 'shippingNet':
$rNumber = (float) ($this->shippingNet(2, '.', '')) * $faktor;
break;

BIN
public/images/flags/ad.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

BIN
public/images/flags/ae.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

BIN
public/images/flags/af.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

BIN
public/images/flags/ag.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

BIN
public/images/flags/ai.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

BIN
public/images/flags/al.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

BIN
public/images/flags/am.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

BIN
public/images/flags/an.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

BIN
public/images/flags/ao.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

BIN
public/images/flags/ar.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

BIN
public/images/flags/as.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

BIN
public/images/flags/at.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

BIN
public/images/flags/au.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

BIN
public/images/flags/aw.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

BIN
public/images/flags/ax.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

BIN
public/images/flags/az.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

BIN
public/images/flags/ba.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

BIN
public/images/flags/bb.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

BIN
public/images/flags/bd.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

BIN
public/images/flags/be.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

BIN
public/images/flags/bf.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

BIN
public/images/flags/bg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

BIN
public/images/flags/bh.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 B

BIN
public/images/flags/bi.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

BIN
public/images/flags/bj.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

BIN
public/images/flags/bm.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

BIN
public/images/flags/bn.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

BIN
public/images/flags/bo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

BIN
public/images/flags/br.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

BIN
public/images/flags/bs.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

BIN
public/images/flags/bt.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

BIN
public/images/flags/bv.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

BIN
public/images/flags/bw.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

BIN
public/images/flags/by.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

BIN
public/images/flags/bz.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

BIN
public/images/flags/ca.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

BIN
public/images/flags/catalonia.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

BIN
public/images/flags/cc.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

BIN
public/images/flags/cd.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

BIN
public/images/flags/cf.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

BIN
public/images/flags/cg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

BIN
public/images/flags/ch.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

BIN
public/images/flags/ci.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

BIN
public/images/flags/ck.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

BIN
public/images/flags/cl.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

BIN
public/images/flags/cm.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

BIN
public/images/flags/cn.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

BIN
public/images/flags/co.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

BIN
public/images/flags/cr.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

BIN
public/images/flags/cs.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

BIN
public/images/flags/cu.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

BIN
public/images/flags/cv.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

BIN
public/images/flags/cx.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

BIN
public/images/flags/cy.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

BIN
public/images/flags/cz.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

BIN
public/images/flags/de.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

BIN
public/images/flags/dj.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

BIN
public/images/flags/dk.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

BIN
public/images/flags/dm.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 B

BIN
public/images/flags/do.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

BIN
public/images/flags/dz.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

BIN
public/images/flags/ec.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

BIN
public/images/flags/ee.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

BIN
public/images/flags/eg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

BIN
public/images/flags/eh.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

BIN
public/images/flags/england.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 B

BIN
public/images/flags/er.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

BIN
public/images/flags/es.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

BIN
public/images/flags/et.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

BIN
public/images/flags/fam.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

BIN
public/images/flags/fi.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

BIN
public/images/flags/fj.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

BIN
public/images/flags/fk.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

BIN
public/images/flags/fm.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

BIN
public/images/flags/fo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

BIN
public/images/flags/fr.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

BIN
public/images/flags/ga.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

BIN
public/images/flags/gb.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

BIN
public/images/flags/gd.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

BIN
public/images/flags/ge.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

BIN
public/images/flags/gf.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

BIN
public/images/flags/gh.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

BIN
public/images/flags/gi.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

BIN
public/images/flags/gl.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Some files were not shown because too many files have changed in this diff Show more