Country Prices | Homeparty | Shop | Order
This commit is contained in:
parent
2ffc33dcd6
commit
2d9db4e52e
284 changed files with 784 additions and 216 deletions
|
|
@ -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){
|
||||
|
||||
|
|
@ -438,7 +443,8 @@ class HomepartyCart
|
|||
break;
|
||||
case 'EkPriceTax':
|
||||
$rNumber = (self::$ek_price - self::$ek_price_net)* $faktor;
|
||||
break;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -145,7 +142,10 @@ class HomepartyUserCart
|
|||
break;
|
||||
case 'EkPrice':
|
||||
$rNumber = $this->ek_price * $faktor;
|
||||
break;
|
||||
break;
|
||||
case 'EkPriceWithout':
|
||||
$rNumber = ($this->ek_price - $this->shipping_price) * $faktor;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue