testemich Promotion
This commit is contained in:
parent
38e7fd504a
commit
a0f4eda6ea
83 changed files with 1690 additions and 504 deletions
|
|
@ -121,6 +121,11 @@ class Yard extends Cart
|
|||
$this->putYardExtra('global_tax_rate', $this->global_tax_rate);
|
||||
}
|
||||
|
||||
public function getGlobalTaxRate(){
|
||||
$this->global_tax_rate;
|
||||
|
||||
}
|
||||
|
||||
public function setShippingOption($value){
|
||||
$this->shipping_option = $value;
|
||||
$this->putYardExtra('shipping_option', $this->shipping_option);
|
||||
|
|
@ -199,6 +204,10 @@ class Yard extends Cart
|
|||
/* * ***** */
|
||||
|
||||
public function calculateMargins(){
|
||||
|
||||
if($this->shipping_is_for === 'cr'){
|
||||
return;
|
||||
}
|
||||
//get user monthy amount
|
||||
$monthy_amount = UserMarign::getMontlyAmount($this->user);
|
||||
|
||||
|
|
@ -288,7 +297,6 @@ class Yard extends Cart
|
|||
|
||||
$margin->setCommission($this->yard_commission);
|
||||
$margin->calculate();
|
||||
|
||||
$this->yard_margin = $margin;
|
||||
$this->putYardExtra('yard_margin', $this->yard_margin);
|
||||
|
||||
|
|
@ -319,18 +327,17 @@ class Yard extends Cart
|
|||
$this->payment_credit = $payment_credit;
|
||||
$this->putYardExtra('user', $user);
|
||||
$this->putYardExtra('payment_credit', $payment_credit);
|
||||
|
||||
}
|
||||
|
||||
public function getPaymentCredit(){
|
||||
if($this->payment_credit && $this->user->payment_credit > 0){
|
||||
return $this->user->payment_credit;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
private function calculateShippingPrice(){
|
||||
|
||||
//keine Verandkosten
|
||||
if($this->shipping_option && $this->shipping_option === 'pick_up'){
|
||||
$this->shipping_price = 0;
|
||||
$this->shipping_tax_rate = 0;
|
||||
|
|
@ -339,6 +346,15 @@ class Yard extends Cart
|
|||
$this->putShippingPrices();
|
||||
return;
|
||||
}
|
||||
//keine Verandkosten
|
||||
if($this->shipping_is_for === 'cr' || $this->shipping_is_for === 'mp'){
|
||||
$this->shipping_price = 0;
|
||||
$this->shipping_tax_rate = 0;
|
||||
$this->shipping_price_net = 0;
|
||||
$this->shipping_tax = 0;
|
||||
$this->putShippingPrices();
|
||||
return;
|
||||
}
|
||||
|
||||
$shippingCountry = ShippingCountry::find($this->shipping_country_id);
|
||||
if(!$shippingCountry){
|
||||
|
|
@ -396,6 +412,42 @@ class Yard extends Cart
|
|||
}
|
||||
}
|
||||
|
||||
public function preCalcuShippingPrice(){
|
||||
$shippingCountry = ShippingCountry::find($this->shipping_country_id);
|
||||
if(!$shippingCountry){
|
||||
return false;
|
||||
}
|
||||
$shipping = $shippingCountry->shipping;
|
||||
$shipping_price_for = 1;
|
||||
if($this->shipping_is_for === 'shop'){
|
||||
$shipping_price_for = 2;
|
||||
}
|
||||
if($this->weight() == 0){
|
||||
$shipping_price = $shipping->getShippingPricesBy($shipping_price_for)->first();
|
||||
if(!$shipping_price){
|
||||
$shipping_price = new \App\Models\ShippingPrice();
|
||||
}
|
||||
$shipping_price->price = 0;
|
||||
}else{
|
||||
//first by price
|
||||
$shipping_price = $this->shippingPriceBySubTotal($shipping->getShippingPricesBy($shipping_price_for), $this->subtotal(2, '.', ''));
|
||||
//sec by weight
|
||||
if(!$shipping_price){
|
||||
$shipping_price = $this->shippingPriceByWeight($shipping->getShippingPricesBy($shipping_price_for), $this->weight());
|
||||
}
|
||||
//default
|
||||
if(!$shipping_price){
|
||||
$shipping_price = $shipping->getShippingPricesBy($shipping_price_for)->first();
|
||||
}
|
||||
|
||||
}
|
||||
if($shipping_price){
|
||||
return $shipping_price->price;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private function putShippingPrices(){
|
||||
$this->putYardExtra('num_comp', $this->num_comp);
|
||||
$this->putYardExtra('shipping_price', $this->shipping_price);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue