Country Prices | Homeparty | Shop | Order
This commit is contained in:
parent
51d81d8ec6
commit
39d1e93416
284 changed files with 784 additions and 216 deletions
|
|
@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue