Free Shipping, Business Levels correction, Products Buying, Fonts
This commit is contained in:
parent
3f2fbd6d5b
commit
0341c9c189
197 changed files with 9161 additions and 329 deletions
|
|
@ -109,6 +109,10 @@ class BusinessUserItem
|
|||
$this->b_user->total_qual_tp = $this->total_tp + $this->getRestQualKP();
|
||||
$commission_total = 0;
|
||||
$qualUserLevel = UserLevel::where('qual_tp', '<=', $this->total_qual_tp)->where('pos', '<=', $this->user_level_active_pos)->orderBy('qual_tp', 'desc')->first();
|
||||
$nextQualUserLevel = UserLevel::where('qual_tp', '<=', $this->total_qual_tp)->where('pos', '>', $this->user_level_active_pos)->orderBy('qual_tp', 'desc')->first();
|
||||
if($nextQualUserLevel){
|
||||
$this->b_user->next_qual_user_level = $nextQualUserLevel->toArray();
|
||||
}
|
||||
if($qualUserLevel){
|
||||
$this->b_user->qual_user_level = $qualUserLevel->toArray();
|
||||
foreach($this->business_lines as $line => $object){
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ class SalesPointsVolume
|
|||
$user_sales_volume->points = intval($data['points']);
|
||||
|
||||
$user_sales_volume->message = 'geändert: '.date('d.m.Y');
|
||||
$user_sales_volume->info = $data['info'];
|
||||
|
||||
$syslog = $user_sales_volume->syslog;
|
||||
$syslog[date('d.m.Y-h:i:s')] = 'edit points: #'.$old_points.' '.$user_sales_volume->points .' total: #'.$old_total_net.' '.$user_sales_volume->total_ne;
|
||||
|
|
@ -221,6 +222,7 @@ class SalesPointsVolume
|
|||
'points' => $points,
|
||||
'total_net' => $total_net,
|
||||
'message' => 'hinzugefügt: '.date('d.m.Y'),
|
||||
'info' => $data['info'],
|
||||
'syslog' => $syslog,
|
||||
'status' => 4,
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -280,8 +280,8 @@ class TreeCalcBot
|
|||
<strong>'.$item->first_name.' '.$item->last_name.'</strong> <a href="mailto: '.$item->email.'">'.$item->email.'</a> <span class="badge badge-outline-default '.($item->active_account ? '' : 'text-muted').'">'.$item->user_level_name.' | '.$item->m_account.'</span>
|
||||
<br><span class="small">'.
|
||||
($item->active_account ?
|
||||
'<strong>Gesamte Points: '.$item->sales_volume_points_sum.'</strong> | B: '.$item->sales_volume_points.' | S: '.$item->sales_volume_points_shop.' <strong>
|
||||
| Umsatz netto: '.formatNumber($item->sales_volume_total_sum).' €</strong> | B: '.formatNumber($item->sales_volume_total).' € | S: '.formatNumber($item->sales_volume_total_shop).' €'.
|
||||
'<strong>Gesamte Points: '.$item->sales_volume_points_sum.'</strong> | E: '.$item->sales_volume_points.' | S: '.$item->sales_volume_points_shop.' <strong>
|
||||
| Umsatz netto: '.formatNumber($item->sales_volume_total_sum).' €</strong> | E: '.formatNumber($item->sales_volume_total).' € | S: '.formatNumber($item->sales_volume_total_shop).' €'.
|
||||
$button
|
||||
:
|
||||
'Account bis: '.$item->payment_account_date).
|
||||
|
|
@ -324,8 +324,8 @@ class TreeCalcBot
|
|||
<strong>'.$item->first_name.' '.$item->last_name.'</strong> <a href="mailto: '.$item->email.'">'.$item->email.'</a> <span class="badge badge-outline-default '.($item->active_account ? '' : 'text-muted').'">'.$item->user_level_name.' | '.$item->m_account.'</span>
|
||||
<br><span class="small">'.
|
||||
($item->active_account ?
|
||||
'<strong>Gesamte Points: '.$item->sales_volume_points_sum.'</strong> | B: '.$item->sales_volume_points.' | S: '.$item->sales_volume_points_shop.' <strong>
|
||||
| Umsatz netto: '.formatNumber($item->sales_volume_total_sum).' €</strong> | B: '.formatNumber($item->sales_volume_total).' € | S: '.formatNumber($item->sales_volume_total_shop).' €'.
|
||||
'<strong>Gesamte Points: '.$item->sales_volume_points_sum.'</strong> | E: '.$item->sales_volume_points.' | S: '.$item->sales_volume_points_shop.' <strong>
|
||||
| Umsatz netto: '.formatNumber($item->sales_volume_total_sum).' €</strong> | E: '.formatNumber($item->sales_volume_total).' € | S: '.formatNumber($item->sales_volume_total_shop).' €'.
|
||||
' | <button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$item->user_id.'"
|
||||
data-action="business-user-detail"
|
||||
|
|
@ -356,8 +356,8 @@ class TreeCalcBot
|
|||
if($this->init_from === 'admin'){
|
||||
$ret .= '<br><span class="small">'.
|
||||
($this->sponsor->active_account ?
|
||||
'<strong>Gesamte Points: '.$this->sponsor->sales_volume_points_sum.'</strong> | B: '.$this->sponsor->sales_volume_points.' | S: '.$this->sponsor->sales_volume_points_shop.' <strong>
|
||||
| Umsatz netto: '.formatNumber($this->sponsor->sales_volume_total_sum).' €</strong> | B: '.formatNumber($this->sponsor->sales_volume_total).' € | S: '.formatNumber($this->sponsor->sales_volume_total_shop).' €'
|
||||
'<strong>Gesamte Points: '.$this->sponsor->sales_volume_points_sum.'</strong> | E: '.$this->sponsor->sales_volume_points.' | S: '.$this->sponsor->sales_volume_points_shop.' <strong>
|
||||
| Umsatz netto: '.formatNumber($this->sponsor->sales_volume_total_sum).' €</strong> | E: '.formatNumber($this->sponsor->sales_volume_total).' € | S: '.formatNumber($this->sponsor->sales_volume_total_shop).' €'
|
||||
:
|
||||
'Account bis: '.$this->sponsor->payment_account_date).
|
||||
'</span>';
|
||||
|
|
|
|||
|
|
@ -31,20 +31,24 @@ class CustomerPriority
|
|||
}
|
||||
|
||||
public static function checkOne($shopping_user, $mail=false, $newCustomer = true, $entryExistsLike = false){
|
||||
//ist die Mail ein Berater, dann sich selbst zuweisen.
|
||||
if(self::entryIsMember($shopping_user)){
|
||||
return 'self';
|
||||
}
|
||||
//look for entry
|
||||
if($entryExistsLike){
|
||||
if(self::entryExistsLike($shopping_user)){
|
||||
if(self::entryExistsLike($shopping_user)){ //existiert die Email bei einem anderem member?
|
||||
if($mail){ //send mail
|
||||
Mail::to(config('app.info_mail'))->send(new MailInfo($shopping_user, 'check_is_like_customer'));
|
||||
}
|
||||
return 'exists';
|
||||
}
|
||||
}else{
|
||||
if(self::entryExists($shopping_user)){
|
||||
if(self::entryExists($shopping_user)){ //Berater zuweisen, wenn die Mail existiert
|
||||
return 'exists';
|
||||
}
|
||||
}
|
||||
if(self::entryLike($shopping_user)){
|
||||
if(self::entryLike($shopping_user)){ //existiert die Adresse bei einem anderem member?
|
||||
if($mail){ //send mail
|
||||
Mail::to(config('app.info_mail'))->send(new MailInfo($shopping_user, 'check_is_like_customer'));
|
||||
}
|
||||
|
|
@ -181,8 +185,9 @@ class CustomerPriority
|
|||
|
||||
}
|
||||
|
||||
public static function checkNewOne($shopping_user, $mail=false){
|
||||
|
||||
|
||||
public static function checkNewOne($shopping_user, $mail=false){
|
||||
if(self::entryLike($shopping_user)){
|
||||
if($mail){ //send mail
|
||||
Mail::to(config('app.info_mail'))->send(new MailInfo($shopping_user, 'check_is_like_customer'));
|
||||
|
|
@ -194,6 +199,19 @@ class CustomerPriority
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function entryIsMember($shopping_user){
|
||||
if($user = User::whereEmail($shopping_user->billing_email)->first()){
|
||||
$member_id = $user->id;
|
||||
$shopping_user->member_id = $member_id;
|
||||
$shopping_user->number = self::nextNumber();
|
||||
$shopping_user->save();
|
||||
$shopping_user->shopping_order->member_id = $member_id;
|
||||
$shopping_user->shopping_order->save();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function entryExists($shopping_user){
|
||||
//check same email
|
||||
$matches = ShoppingUser::where('auth_user_id', '=', NULL)
|
||||
|
|
@ -218,6 +236,7 @@ class CustomerPriority
|
|||
|
||||
private static function entryExistsLike($shopping_user)
|
||||
{
|
||||
//existiert die Email bei einem anderem member?
|
||||
$matches = ShoppingUser::where('auth_user_id', '=', NULL)
|
||||
->where('number', '!=', NULL) //has number
|
||||
->where('id', '!=', $shopping_user->id)
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ namespace App\Services;
|
|||
|
||||
|
||||
|
||||
use App\Models\Homeparty;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Homeparty;
|
||||
|
||||
class HomepartyCart
|
||||
{
|
||||
|
|
@ -43,7 +43,6 @@ class HomepartyCart
|
|||
|
||||
|
||||
private static $bonus_coupon = 0;
|
||||
private static $bonus_value = 30;
|
||||
|
||||
private static $voucher_price = 0;
|
||||
public static $voucher_name = "";
|
||||
|
|
@ -54,7 +53,10 @@ class HomepartyCart
|
|||
private static $bonus_coupon_fault = 0;
|
||||
private static $bonus_coupon_next_step = 0;
|
||||
private static $bonus_coupon_next_value = 0;
|
||||
private static $bonus_start = 230;
|
||||
private static $bonus_start = 230; //230
|
||||
private static $bonus_value = 30; //30
|
||||
|
||||
|
||||
private static $bonusTable = [
|
||||
295 => 15,
|
||||
350 => 20,
|
||||
|
|
@ -63,8 +65,20 @@ class HomepartyCart
|
|||
670 => 40,
|
||||
780 => 50,
|
||||
];
|
||||
public static function calculateHomeparty(Homeparty $homeparty){
|
||||
|
||||
public static function init(){
|
||||
self::$bonus_value = Setting::getContentBySlug('hp-bonus-value');
|
||||
self::$bonus_start = Setting::getContentBySlug('hp-bonus-start');
|
||||
if($hpBonusSteps = Setting::getContentBySlug('hp-bonus-steps')){
|
||||
self::$bonusTable = [];
|
||||
for ($i=1; $i <= $hpBonusSteps; $i++) {
|
||||
self::$bonusTable[Setting::getContentBySlug('hp-bonus-step-start-'.$i)] = Setting::getContentBySlug('hp-bonus-step-value-'.$i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function calculateHomeparty(Homeparty $homeparty){
|
||||
self::init();
|
||||
self::$homeparty = $homeparty;
|
||||
foreach ($homeparty->homeparty_users as $homeparty_user){
|
||||
if($homeparty_user->is_host){
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class MyPDFMerger
|
|||
|
||||
$fpdi->AddPage($orientation, array($size['width'], $size['height']));
|
||||
if($theme){
|
||||
$fpdi->setSourceFile('pdf/'.$theme.'-'.$first.'.pdf');
|
||||
$fpdi->setSourceFile(__DIR__ . '/../../public/pdf/'.$theme.'-'.$first.'.pdf');
|
||||
if($first == 1){
|
||||
$first = 2;
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ class MyPDFMerger
|
|||
|
||||
$fpdi->AddPage($orientation, array($size['w'], $size['h']));
|
||||
if($theme){
|
||||
$fpdi->setSourceFile('pdf/'.$theme.'-'.$first.'.pdf');
|
||||
$fpdi->setSourceFile(__DIR__ . '/../../public/pdf/'.$theme.'-'.$first.'.pdf');
|
||||
if($first == 1){
|
||||
$first = 2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ namespace App\Services;
|
|||
|
||||
|
||||
use App\User;
|
||||
use App\Models\UserLevel;
|
||||
use App\Mail\MailCheckout;
|
||||
use App\Models\ProductBuying;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\UserCreditItem;
|
||||
use App\Models\ShoppingPayment;
|
||||
|
|
@ -96,6 +98,26 @@ class Payment
|
|||
]);
|
||||
}
|
||||
|
||||
public static function addBuyingRestriction(User $user, $product_id){
|
||||
ProductBuying::create([
|
||||
'user_id' => $user->id,
|
||||
'product_id' => $product_id,
|
||||
'amount' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
public static function updateUserLevel(User $user, $to_level_id){
|
||||
//nur updaten, wenn der user->m_level kleiner ist als $to_level_id
|
||||
if($user->user_level){
|
||||
$ToUserLevel = UserLevel::find($to_level_id);
|
||||
if($user->user_level->pos < $ToUserLevel->pos){
|
||||
$user->m_level = $to_level_id;
|
||||
}
|
||||
}else{
|
||||
$user->m_level = $to_level_id;
|
||||
}
|
||||
$user->save();
|
||||
}
|
||||
/*
|
||||
Wir bei Zahlung aufgerufen.
|
||||
Betätigung durch Payone oder Zahlung auf MIVITA Rechnung
|
||||
|
|
@ -113,9 +135,12 @@ class Payment
|
|||
if($shopping_order->shopping_order_items && $shopping_order->auth_user_id){
|
||||
foreach($shopping_order->shopping_order_items as $shopping_order_item){
|
||||
if($shopping_order_item->product){
|
||||
$user = User::findOrFail($shopping_order->auth_user_id);
|
||||
$user->save();
|
||||
if($shopping_order_item->product->buying_restriction){
|
||||
self::addBuyingRestriction($user, $shopping_order_item->product->id);
|
||||
}
|
||||
if($shopping_order_item->product->action){
|
||||
$user = User::findOrFail($shopping_order->auth_user_id);
|
||||
$user->save();
|
||||
$send_link = true;
|
||||
//new date
|
||||
$date = \Carbon::now()->modify('1 year');
|
||||
|
|
@ -144,7 +169,7 @@ class Payment
|
|||
}
|
||||
if($shopping_order_item->product->getActionName($do) === 'payment_for_lead_upgrade'){
|
||||
if($shopping_order_item->product->upgrade_to_id){
|
||||
$user->m_level = $shopping_order_item->product->upgrade_to_id;
|
||||
self::updateUserLevel($user, $shopping_order_item->product->upgrade_to_id);
|
||||
}
|
||||
}
|
||||
$user->save();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class Shop
|
|||
public static $user_country;
|
||||
public static $shipping_country;
|
||||
public static $user_tax_free;
|
||||
public static $shipping_free;
|
||||
public static $user_reverse_charge = false;
|
||||
|
||||
public static function userOrders() {
|
||||
|
|
@ -51,7 +52,6 @@ class Shop
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static function getShippingCountryCountryId($shipping_country_id){
|
||||
$shippingCountry = ShippingCountry::find($shipping_country_id);
|
||||
if($shippingCountry && $shippingCountry->country){
|
||||
|
|
@ -111,19 +111,21 @@ class Shop
|
|||
//Lieferadresse im Drittland?
|
||||
self::$user_tax_free = $country->supply_country ? true : false;
|
||||
$ShippingCountry = ShippingCountry::whereCountryId($country->id)->first();
|
||||
self::$shipping_free = $ShippingCountry->shipping->free;
|
||||
self::$shipping_country = $ShippingCountry;
|
||||
self::$user_country = $country;
|
||||
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($ShippingCountry->id);
|
||||
Yard::instance('shopping')->setUserPriceInfos(Shop::getYardInfo());
|
||||
Yard::instance('shopping')->setUserPriceInfos(Shop::getShopYardInfo());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static function getYardInfo(){
|
||||
public static function getShopYardInfo(){
|
||||
return [
|
||||
'user_tax_free' => self::$user_tax_free,
|
||||
'shipping_free' => self::$shipping_free,
|
||||
'user_reverse_charge' => self::$user_reverse_charge,
|
||||
'user_country_id' => self::$user_country->id,
|
||||
'shipping_country_id' => self::$shipping_country->id,
|
||||
|
|
|
|||
|
|
@ -70,10 +70,10 @@ class ShopApiOrderCart
|
|||
|
||||
$shop_item->tax_rate = $tax_rate;
|
||||
$shop_item->points = $item->points;
|
||||
$shop_item->user_price_net = $user_price_net;
|
||||
$shop_item->user_price_total_net = $user_price_net_qty;
|
||||
$shop_item->user_tax = $user_tax;
|
||||
$shop_item->user_tax_total = $user_tax_qty;
|
||||
$shop_item->user_price_net = round($user_price_net, 2);
|
||||
$shop_item->user_price_total_net = round($user_price_net_qty, 2);
|
||||
$shop_item->user_tax = round($user_tax, 2);
|
||||
$shop_item->user_tax_total = round($user_tax_qty, 2);
|
||||
$shop_item->points_total = ($item->points * $item->qty);
|
||||
}
|
||||
|
||||
|
|
|
|||
80
app/Services/SyS/BuyingsProducts.php
Normal file
80
app/Services/SyS/BuyingsProducts.php
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
namespace App\Services\SyS;
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Models\SySetting;
|
||||
use App\Models\ProductBuying;
|
||||
use App\Cron\BusinessUsersStore;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
|
||||
class BuyingsProducts
|
||||
{
|
||||
|
||||
public static function show()
|
||||
{
|
||||
|
||||
$data = [
|
||||
];
|
||||
|
||||
return view('sys.tools.buyings_products', $data);
|
||||
}
|
||||
|
||||
|
||||
public static function store()
|
||||
{
|
||||
|
||||
$ShoppingOrderItems = ShoppingOrderItem::where('product_id', 37)->get();
|
||||
$count = 0;
|
||||
foreach($ShoppingOrderItems as $ShoppingOrderItem){
|
||||
if(!ProductBuying::where('user_id', $ShoppingOrderItem->shopping_order->auth_user_id)->where('product_id', $ShoppingOrderItem->product_id)->count()){
|
||||
ProductBuying::create([
|
||||
'user_id' => $ShoppingOrderItem->shopping_order->auth_user_id,
|
||||
'product_id' => 37,
|
||||
'amount' => 1
|
||||
]);
|
||||
$count ++;
|
||||
}
|
||||
|
||||
}
|
||||
dump("ADD ".$count." product_id 37");
|
||||
|
||||
$ShoppingOrderItems = ShoppingOrderItem::where('product_id', 100)->get();
|
||||
$count = 0;
|
||||
foreach($ShoppingOrderItems as $ShoppingOrderItem){
|
||||
if(!ProductBuying::where('user_id', $ShoppingOrderItem->shopping_order->auth_user_id)->where('product_id', $ShoppingOrderItem->product_id)->count()){
|
||||
ProductBuying::create([
|
||||
'user_id' => $ShoppingOrderItem->shopping_order->auth_user_id,
|
||||
'product_id' => 118,
|
||||
'amount' => 1
|
||||
]);
|
||||
$count ++;
|
||||
}
|
||||
|
||||
}
|
||||
dump("ADD ".$count." product_id 100 to 118");
|
||||
|
||||
|
||||
$ShoppingOrderItems = ShoppingOrderItem::where('product_id', 118)->get();
|
||||
$count = 0;
|
||||
foreach($ShoppingOrderItems as $ShoppingOrderItem){
|
||||
if(!ProductBuying::where('user_id', $ShoppingOrderItem->shopping_order->auth_user_id)->where('product_id', $ShoppingOrderItem->product_id)->count()){
|
||||
ProductBuying::create([
|
||||
'user_id' => $ShoppingOrderItem->shopping_order->auth_user_id,
|
||||
'product_id' => 118,
|
||||
'amount' => 1
|
||||
]);
|
||||
$count ++;
|
||||
}
|
||||
|
||||
}
|
||||
dump("ADD ".$count." product_id 118");
|
||||
|
||||
|
||||
die();
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('sysadmin_tool', ['buyings_products']));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -97,6 +97,20 @@ class DomainSSL
|
|||
|
||||
}
|
||||
|
||||
if(isset($data['update_ssl'])){
|
||||
$user_shop = UserShop::findOrFail($data['update_ssl']);
|
||||
$subdomain_name = $user_shop->slug.'.mivita.care';
|
||||
$kas = new KasController();
|
||||
$ssl = KasSLLController::getApiSSLParameter();
|
||||
$pra = array(
|
||||
'hostname' => $subdomain_name
|
||||
);
|
||||
$pra = array_merge($pra, $ssl);
|
||||
$value = $kas->action('update_ssl', $pra);
|
||||
\Session()->flash('alert-success', 'update SSL: '.$value.'');
|
||||
|
||||
}
|
||||
|
||||
|
||||
return back();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ class UserService
|
|||
|
||||
public static function getYardInfo(){
|
||||
return [
|
||||
'shipping_free' => false,
|
||||
'user_tax_free' => self::$user_tax_free,
|
||||
'user_reverse_charge' => self::$user_reverse_charge,
|
||||
'user_country_id' => self::$user_country->id,
|
||||
|
|
|
|||
|
|
@ -65,6 +65,17 @@ class Util
|
|||
}
|
||||
|
||||
|
||||
public static function maxStrLength($str, $length = 40){
|
||||
|
||||
if(strlen($str) > $length){
|
||||
$str = substr($str, 0, $length);
|
||||
//$str = substr($str, 0, strrpos($str, " "));
|
||||
$str = $str." ...";
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
public static function reFormatNumber($value){
|
||||
return (float) str_replace(',', '.', self::_format_number($value));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class Yard extends Cart
|
|||
private $num_comp;
|
||||
private $ysession;
|
||||
private $user_tax_free;
|
||||
private $shipping_free;
|
||||
private $user_reverse_charge;
|
||||
private $user_country_id;
|
||||
private $user_country;
|
||||
|
|
@ -62,6 +63,9 @@ class Yard extends Cart
|
|||
if($this->getYardExtra('user_tax_free')){
|
||||
$this->user_tax_free = $this->getYardExtra('user_tax_free');
|
||||
}
|
||||
if($this->getYardExtra('shipping_free')){
|
||||
$this->shipping_free = $this->getYardExtra('shipping_free');
|
||||
}
|
||||
if($this->getYardExtra('user_reverse_charge')){
|
||||
$this->user_reverse_charge = $this->getYardExtra('user_reverse_charge');
|
||||
}
|
||||
|
|
@ -159,14 +163,17 @@ class Yard extends Cart
|
|||
|
||||
public function setUserPriceInfos($setUserPriceInfos = [])
|
||||
{
|
||||
$this->shipping_free = isset($setUserPriceInfos['shipping_free']) ? $setUserPriceInfos['shipping_free'] : false;
|
||||
$this->putYardExtra('shipping_free', $this->shipping_free);
|
||||
|
||||
$this->user_tax_free = $setUserPriceInfos['user_tax_free'];
|
||||
$this->putYardExtra('user_tax_free', $setUserPriceInfos['user_tax_free']);
|
||||
$this->putYardExtra('user_tax_free', $this->user_tax_free);
|
||||
|
||||
$this->user_reverse_charge = $setUserPriceInfos['user_reverse_charge'];
|
||||
$this->putYardExtra('user_reverse_charge', $setUserPriceInfos['user_reverse_charge']);
|
||||
$this->putYardExtra('user_reverse_charge', $this->user_reverse_charge);
|
||||
|
||||
$this->user_country_id = $setUserPriceInfos['user_country_id'];
|
||||
$this->putYardExtra('user_country_id', $setUserPriceInfos['user_country_id']);
|
||||
$this->putYardExtra('user_country_id', $this->user_country_id);
|
||||
|
||||
$this->user_country = Country::findOrFail($setUserPriceInfos['user_country_id']);
|
||||
$this->putYardExtra('user_country', $this->user_country);
|
||||
|
|
@ -177,6 +184,7 @@ class Yard extends Cart
|
|||
'user_tax_free' =>$this->user_tax_free,
|
||||
'user_reverse_charge' =>$this->user_reverse_charge,
|
||||
'user_country_id' =>$this->user_country_id,
|
||||
'shipping_free' => $this->shipping_free,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -195,6 +203,11 @@ class Yard extends Cart
|
|||
return $this->user_tax_free ? true : false;
|
||||
}
|
||||
|
||||
public function getShippingFree()
|
||||
{
|
||||
return $this->shipping_free;
|
||||
}
|
||||
|
||||
private function calculateShippingPrice(){
|
||||
|
||||
$shippingCountry = ShippingCountry::find($this->shipping_country_id);
|
||||
|
|
@ -202,19 +215,29 @@ class Yard extends Cart
|
|||
return;
|
||||
}
|
||||
$shipping = $shippingCountry->shipping;
|
||||
$shipping_price = $shipping->shipping_prices->first();
|
||||
if(!$shipping_price){
|
||||
return;
|
||||
}
|
||||
if($this->weight() == 0){
|
||||
$shipping_price = $shipping->shipping_prices->first();
|
||||
if(!$shipping_price){
|
||||
return;
|
||||
}
|
||||
$shipping_price->price = 0;
|
||||
$shipping_price->price_comp = 0;
|
||||
}else{
|
||||
//first by price
|
||||
$shipping_price = $this->shippingPriceByTotal($shipping->shipping_prices, $this->total(2, '.', ''));
|
||||
//sec by weight
|
||||
if(!$shipping_price){
|
||||
if($this->shipping_free && $this->total(2, '.', '') >= $this->shipping_free){
|
||||
if($this->weightByFreeShipping() == 0){
|
||||
$shipping_price->price = 0;
|
||||
$shipping_price->price_comp = 0;
|
||||
}else{
|
||||
$shipping_price = $this->shippingPriceByWeight($shipping->shipping_prices, $this->weightByFreeShipping());
|
||||
}
|
||||
|
||||
}else{
|
||||
$shipping_price = $this->shippingPriceByWeight($shipping->shipping_prices, $this->weight());
|
||||
//first by price
|
||||
//$shipping_price = $this->shippingPriceByTotal($shipping->shipping_prices, $this->total(2, '.', ''));
|
||||
//sec by weight
|
||||
//if(!$shipping_price){
|
||||
//}
|
||||
}
|
||||
//default
|
||||
if(!$shipping_price){
|
||||
|
|
@ -338,6 +361,18 @@ class Yard extends Cart
|
|||
return $total;
|
||||
}
|
||||
|
||||
public function weightByFreeShipping($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
{
|
||||
$content = $this->getContent();
|
||||
$total = $content->reduce(function ($total, CartItem $cartItem) {
|
||||
if($cartItem->options->no_free_shipping){
|
||||
return $total + ($cartItem->options->weight ? ($cartItem->options->weight*$cartItem->qty) : 0);
|
||||
}
|
||||
return $total;
|
||||
}, 0);
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function points()
|
||||
{
|
||||
$content = $this->getContent();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue