/** * Get surcharge name * * @param \XLite\Model\Base\Surcharge $surcharge Surcharge * * @return \XLite\DataSet\Transport\Order\Surcharge */ public function getSurchargeInfo(\XLite\Model\Base\Surcharge $surcharge) { $info = new \XLite\DataSet\Transport\Order\Surcharge(); if (0 === strpos($surcharge->getCode(), $this->code . '.')) { $id = intval(substr($surcharge->getCode(), strlen($this->code) + 1)); $tax = \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\SalesTax\\Model\\Tax')->find($id); $info->name = $tax ? $tax->getName() : \XLite\Core\Translation::lbl('Sales tax'); } else { $info->name = \XLite\Core\Translation::lbl('Sales tax'); } $info->notAvailableReason = \XLite\Core\Translation::lbl('Billing address is not defined'); return $info; }
/** * Replace surcharge * * @param \XLite\Model\Base\Surcharge $surcharge Surcharge for replacing * * @return void */ public function replaceSurcharge(\XLite\Model\Base\Surcharge $surcharge) { $this->map($surcharge->getReplacedProperties()); $owner = $surcharge->getOwner(); $owner->removeSurcharge($surcharge); $owner->addSurcharges($this); $this->setOwner($owner); }
/** * Check - modifier is specified surcharge owner or not * * @param \XLite\Model\Base\Surcharge $surcharge Surcharge * * @return boolean */ public function isSurchargeOwner(\XLite\Model\Base\Surcharge $surcharge) { return $this->identificationPattern && preg_match($this->identificationPattern, $surcharge->getCode()) || $surcharge->getCode() === $this->getCode(); }
/** * Get surcharge name * * @param \XLite\Model\Order\Surcharge $surcharge Surcharge * * @return \XLite\DataSet\Transport\Order\Surcharge */ public function getSurchargeInfo(\XLite\Model\Base\Surcharge $surcharge) { $info = new \XLite\DataSet\Transport\Order\Surcharge(); if (preg_match($this->identificationPattern, $surcharge->getCode(), $match)) { $id = intval($match[1]); $code = isset($match[2]) && $match[2] ? $match[2] : null; $tax = \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\VAT\\Model\\Tax')->find($id); $info->name = $tax ? $tax->getName() : \XLite\Core\Translation::lbl('VAT'); } else { $info->name = \XLite\Core\Translation::lbl('VAT'); } $info->notAvailableReason = \XLite\Core\Translation::lbl('Billing address is not defined'); return $info; }