本文整理汇总了PHP中XLite类的典型用法代码示例。如果您正苦于以下问题:PHP XLite类的具体用法?PHP XLite怎么用?PHP XLite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XLite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetTotalRate
public function testGetTotalRate()
{
$tax = \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\VAT\\Model\\Tax')->getTax();
foreach ($tax->getRates() as $rate) {
\XLite\Core\Database::getEM()->remove($rate);
}
$tax->getRates()->clear();
$tax->setEnabled(true);
$rate = new \XLite\Module\CDev\VAT\Model\Tax\Rate();
$rate->setValue(10);
$rate->setPosition(1);
\XLite\Core\Database::getEM()->persist($rate);
$tax->addRates($rate);
$rate->setTax($tax);
$rate = new \XLite\Module\CDev\VAT\Model\Tax\Rate();
$rate->setValue(20);
$rate->setPosition(0);
\XLite\Core\Database::getEM()->persist($rate);
$tax->addRates($rate);
$rate->setTax($tax);
$memberships = \XLite\Core\Database::getRepo('XLite\\Model\\Membership')->findAll();
$membership = array_shift($memberships);
$rate->setMembership($membership);
$tax->setVATMembership($membership);
\XLite\Core\Database::getEM()->flush();
$method = new \XLite\Model\Shipping\Method();
$method->setEnabled(true);
$rate = new \XLite\Model\Shipping\Rate();
$rate->setBaseRate(10);
$rate->setMarkupRate(10);
$rate->setMethod($method);
$this->assertEquals(16.67, \XLite::getInstance()->getCurrency()->formatValue($rate->getTotalRate()), 'check cost');
}
示例2: getGaqOptions
/**
* Get _gaq options list
*
* @return array
*/
protected function getGaqOptions()
{
$list = array(sprintf('\'_setAccount\', \'%s\'', \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics->ga_account));
if (2 == \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics->ga_tracking_type) {
$list[] = '\'_setDomainName\', \'.\' + self.location.host.replace(/^[^\\.]+\\./, \'\')';
} elseif (3 == \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics->ga_tracking_type) {
$list[] = '\'_setDomainName\', \'none\'';
$list[] = '\'_setAllowLinker\', true';
}
$list[] = '\'_trackPageview\'';
$controller = \XLite::getController();
if ($this->isEcommercePartEnabled() && $controller instanceof \XLite\Controller\Customer\CheckoutSuccess) {
$orders = \XLite\Core\Session::getInstance()->gaProcessedOrders;
if (!is_array($orders)) {
$orders = array();
}
$order = $this->getOrder();
if ($order->getProfile() && !in_array($order->getOrderId(), $orders)) {
$bAddress = $order->getProfile()->getBillingAddress();
$city = $bAddress ? $bAddress->getCity() : '';
$state = $bAddress && $bAddress->getState() ? $bAddress->getState()->getState() : '';
$country = $bAddress && $bAddress->getCountry() ? $bAddress->getCountry()->getCountry() : '';
$tax = $order->getSurchargeSumByType(\XLite\Model\Base\Surcharge::TYPE_TAX);
$shipping = $order->getSurchargeSumByType(\XLite\Model\Base\Surcharge::TYPE_SHIPPING);
$list[] = '\'_addTrans\', ' . '\'' . $order->getOrderNumber() . '\', ' . '\'' . $this->escapeJavascript(\XLite\Core\Config::getInstance()->Company->company_name) . '\', ' . '\'' . $order->getTotal() . '\', ' . '\'' . $tax . '\', ' . '\'' . $shipping . '\', ' . '\'' . $this->escapeJavascript($city) . '\', ' . '\'' . $this->escapeJavascript($state) . '\', ' . '\'' . $this->escapeJavascript($country) . '\'';
foreach ($order->getItems() as $item) {
$list[] = '\'_addItem\', ' . '\'' . $order->getOrderNumber() . '\', ' . '\'' . $this->escapeJavascript($item->getSku()) . '\', ' . '\'' . $this->escapeJavascript($item->getName()) . '\', ' . '\'\', ' . '\'' . $item->getPrice() . '\', ' . '\'' . $item->getAmount() . '\'';
}
$list[] = '\'_trackTrans\'';
$orders[] = $order->getOrderId();
\XLite\Core\Session::getInstance()->gaProcessedOrders = $orders;
}
}
return $list;
}
示例3: getTabberPages
/**
* Get prepared pages array for tabber
*
* @return void
*/
protected function getTabberPages()
{
$pages = array();
$url = $this->get('url');
$switch = $this->getParam(self::PARAM_SWITCH);
$functionName = $this->getParam(self::PARAM_TAB_PAGES);
// $functionName - from PARAM_TAB_PAGES parameter
$dialogPages = \XLite::getController()->{$functionName}();
if (is_array($dialogPages)) {
foreach ($dialogPages as $page => $title) {
$p = new \XLite\Base();
$pageURL = preg_replace('/' . $switch . '=(\\w+)/', $switch . '=' . $page, $url);
$p->set('url', $pageURL);
$p->set('title', $title);
$pageSwitch = sprintf($switch . '=' . $page);
$p->set('selected', preg_match('/' . preg_quote($pageSwitch) . '(\\Z|&)/Ss', $url));
$pages[] = $p;
}
}
// if there is only one tab page, set it as a seleted with the default URL
if (1 == count($pages) || 'default' === $this->getPage()) {
$pages[0]->set('selected', $url);
}
return $pages;
}
示例4: addEnabledCondition
/**
* Adds additional condition to the query for checking if method is enabled
*
* @param \Doctrine\ORM\QueryBuilder $qb Query builder object
* @param string $alias Entity alias OPTIONAL
*
* @return \Doctrine\ORM\QueryBuilder
*/
protected function addEnabledCondition(\Doctrine\ORM\QueryBuilder $qb, $alias = 'm')
{
if (!\XLite::getInstance()->isAdminZone()) {
$qb->andWhere($alias . '.enabled = 1');
}
return $qb;
}
示例5: getMarketplaceURL
protected function getMarketplaceURL($module)
{
list(, $limit) = $this->getWidget(array(), 'XLite\\View\\Pager\\Admin\\Module\\Install')->getLimitCondition()->limit;
$pageId = $module->getRepository()->getMarketplacePageId($module->getAuthor(), $module->getName(), $limit);
$params = array('clearCnd' => 1, 'clearSearch' => 1, \XLite\View\Pager\APager::PARAM_PAGE_ID => $pageId, \XLite\View\ItemsList\AItemsList::PARAM_SORT_BY => \XLite\View\ItemsList\Module\AModule::SORT_OPT_ALPHA);
return \XLite::getInstance()->getShopURL(sprintf('%s#%s', \XLite\Core\Converter::buildURL('addons_list_marketplace', '', $params), $module->getName()));
}
示例6: connect
/**
* Connect
*
* @return void
*/
public function connect()
{
if (\XLite::isAdminZone()) {
\Includes\Utils\ConfigParser::registerConfigFile('config.demo.php');
}
parent::connect();
}
示例7: getFormButtons
/**
* Return list of the "Button" widgets
*
* @return array
*/
protected function getFormButtons()
{
$result = parent::getFormButtons();
if ($this->getModule() && 'CDev\\Bestsellers' == $this->getModule()->getActualName()) {
$result['sales_calculation'] = new \XLite\View\Button\Link(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Sales calculation', \XLite\View\Button\Link::PARAM_LOCATION => $this->buildURL('sales_calculation', 'sales', array(\XLite::FORM_ID => \XLite::getFormId())), \XLite\View\Button\AButton::PARAM_STYLE => 'action always-enabled'));
}
return $result;
}
示例8: getName
/**
* 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;
}
示例9: getDefaultTemplate
/**
* Return widget default template
*
* @return string
*/
protected function getDefaultTemplate()
{
if (!\XLite::isAdminZone() && method_exists('\\XLite\\Core\\Request', 'isMobileDevice') && \XLite\Core\Request::isMobileDevice()) {
return 'modules/Amazon/PayWithAmazon/checkout_mobile.tpl';
} else {
return 'modules/Amazon/PayWithAmazon/checkout.tpl';
}
}
示例10: getCSSFiles
/**
* Return list of required CSS files
*
* @return array
*/
public function getCSSFiles()
{
$list = parent::getCSSFiles();
if (!\XLite::isAdminZone()) {
$list[] = 'common/grid-list.css';
}
return $list;
}
示例11: getDefaultParams
/**
* Return list of the form default parameters
*
* @return array
*/
protected function getDefaultParams()
{
$params = array();
if (\XLite::isAdminZone()) {
$params = array('profile_id' => \XLite\Core\Request::getInstance()->profile_id);
}
return $params;
}
示例12: getTotalRate
/**
* Get total rate
*
* @return float
*/
public function getTotalRate()
{
$total = parent::getTotalRate();
if (!\XLite::isAdminZone() && $this->getMethod()) {
$total = \XLite\Module\CDev\VAT\Logic\Shipping\Tax::getInstance()->calculateRateCost($this, $total);
}
return $total;
}
示例13: getDefaultParams
/**
* Return list of the form default parameters
*
* @return array
*/
protected function getDefaultParams()
{
$params = array();
if (\XLite::isAdminZone()) {
$params = array('amount' => \XLite\Core\Request::getInstance()->amount, 'order_number' => \XLite\Core\Request::getInstance()->order_number);
}
return $params;
}
示例14: getRequiredFieldsByType
/**
* Get required fields by address type
*
* @param string $atype Address type code
*
* @return array
*/
public function getRequiredFieldsByType($atype)
{
$list = parent::getRequiredFieldsByType($atype);
if ('express_checkout_return' === \XLite::getController()->getAction()) {
$list = array_diff($list, array('phone'));
}
return $list;
}
示例15: getCommonJSData
/**
* Return common data to send to JS
*
* @return array
*/
protected function getCommonJSData()
{
$data = parent::getCommonJSData();
if (!\XLite::isAdminZone()) {
$data += $this->getCloudSearchInitData();
}
return $data;
}