/** * Returns shipping carrier settings url * * @param \XLite\Model\Shipping\Method $method Shipping method * * @return string */ protected function getSettingsURL(\XLite\Model\Shipping\Method $method) { $module = $method->getProcessorModule(); if ($module && $module->isInstalled() && $module->getEnabled()) { $url = $method->getProcessorObject() ? $method->getProcessorObject()->getSettingsURL() : ''; } elseif ($module && $module->isInstalled()) { $url = $module->getInstalledURL(); } else { $url = $module->getMarketplaceURL(); } return $url; }
/** * get Shipping Method name * for Canada Post add '(Canada Post)' (except admin area, shipping methods page) * * @return string */ public function getName() { $name = parent::getName(); if ('capost' == $this->getProcessor() && !(\XLite::isAdminZone() && \XLite::getController() instanceof \XLite\Controller\Admin\ShippingMethods)) { $name = 'Canada Post ' . $name; } return $name; }
/** * Return true if shipping method is 'Freight fixed fee' * * @param \XLite\Model\Shipping\Method $method Shipping method * * @return boolean */ protected function isFixedFeeMethod($method) { return \XLite\Model\Shipping\Method::METHOD_TYPE_FIXED_FEE == $method->getCode() && 'offline' == $method->getProcessor(); }
/** * getClasses * * @param \XLite\Model\Shipping\Method $method ____param_comment____ * * @return \Doctrine\Common\Collections\ArrayCollection */ protected function getClasses(\XLite\Model\Shipping\Method $method) { $classes = new \Doctrine\Common\Collections\ArrayCollection(); $postedData = $this->getPostedData('class_ids'); foreach ((array) $postedData[$method->getMethodId()] as $classId) { $class = \XLite\Core\Database::getRepo('\\XLite\\Model\\ProductClass')->findOneById($classId); if ($class) { if (!$class->getShippingMethods()->contains($method)) { $class->getShippingMethods()->add($method); } $classes->add($class); } } return $classes; }
/** * Check - is shipping method is support "Delivery to Post Office" feature * * @param \XLite\Model\Shipping\Method $method Shipping method object * * @return boolean */ protected function isMethodSupportDeliveryToPO(\XLite\Model\Shipping\Method $method) { return 'capost' == $method->getProcessor() && in_array($method->getCode(), \XLite\Module\XC\CanadaPost\Core\API::getAllowedForDelivetyToPOMethodCodes()); }
/** * Add online method * * @param \XLite\Model\Shipping\Method $method Shipping method * * @return void */ protected function addOnlineMethod($method) { if ($method && !$method->isAdded()) { $method->setAdded(true); $method->update(); } }
/** * {@inheritDoc} */ public function prepareEntityBeforeCommit($type) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'prepareEntityBeforeCommit', array($type)); return parent::prepareEntityBeforeCommit($type); }
/** * Returns list of zones as a string * * @param \XLite\Model\Shipping\Method $entity Shipping method * * @return string */ protected function getZonesList($entity) { $result = ''; $zones = array(); foreach ($entity->getShippingMarkups() as $markup) { if ($markup && $markup->getZone() && !in_array($markup->getZone()->getZoneName(), $zones, true)) { $zones[] = $markup->getZone()->getZoneName(); } } if (count($zones)) { sort($zones); $result = implode(', ', $zones); } return $result; }