Advertisement
VEKIA

Prestashop blockcurrencies.php

Nov 9th, 2013
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Smarty 2.29 KB | None | 0 0
  1. <?php
  2. /*
  3. * 2007-2013 PrestaShop
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Academic Free License (AFL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/afl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@prestashop.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
  18. * versions in the future. If you wish to customize PrestaShop for your
  19. * needs please refer to http://www.prestashop.com for more information.
  20. *
  21. *  @author PrestaShop SA <contact@prestashop.com>
  22. *  @copyright  2007-2013 PrestaShop SA
  23. *  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
  24. *  International Registered Trademark & Property of PrestaShop SA
  25. */
  26.  
  27. if (!defined('_PS_VERSION_'))
  28.     exit;
  29.  
  30. class BlockCurrencies extends Module
  31. {
  32.     public function __construct()
  33.     {
  34.         $this->name = 'blockcurrencies';
  35.         $this->tab = 'front_office_features';
  36.         $this->version = 0.1;
  37.         $this->author = 'PrestaShop';
  38.         $this->need_instance = 0;
  39.  
  40.         parent::__construct();
  41.  
  42.         $this->displayName = $this->l('Currency block');
  43.         $this->description = $this->l('Adds a block allowing customers to choose their preferred shopping currency.');
  44.     }
  45.  
  46.     public function install()
  47.     {
  48.         return parent::install() && $this->registerHook('top') && $this->registerHook('header');
  49.     }
  50.  
  51.     private function _prepareHook($params)
  52.     {
  53.         if (Configuration::get('PS_CATALOG_MODE'))
  54.             return false;
  55.  
  56.         if (!count(Currency::getCurrencies()))
  57.             return false;
  58.  
  59.         $this->smarty->assign('blockcurrencies_sign', $this->context->currency->sign);
  60.    
  61.         return true;
  62.     }
  63.  
  64.     /**
  65.     * Returns module content for header
  66.     *
  67.     * @param array $params Parameters
  68.     * @return string Content
  69.     */
  70.     public function hookTop($params)
  71.     {
  72.         if ($this->_prepareHook($params))
  73.             return $this->display(__FILE__, 'blockcurrencies.tpl');
  74.     }
  75.  
  76.     public function hookHeader($params)
  77.     {
  78.         if (Configuration::get('PS_CATALOG_MODE'))
  79.             return;
  80.         $this->context->controller->addCSS(($this->_path).'blockcurrencies.css', 'all');
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement