order = $order; $this->preOrderDeduction = $preOrderDeduction; parent::__construct($weight); } function getKey() { return $this->preOrderDeduction->getCode() . 'FreightDeduction'; } /** * @return mixed * @throws \app\common\exceptions\AppException */ function getPrice() { if ($this->preOrderDeduction->isChecked() && $this->preOrderDeduction->openFreightDeduction()) { return max($this->order->getPriceBefore($this->getKey()) - $this->preOrderDeduction->getUsableFreightDeduction()->getMoney(),0); } else { return $this->order->getPriceBefore($this->getKey()); } } }