Skip to content

Commit

Permalink
Add the possibility to enable or not the ajax cart
Browse files Browse the repository at this point in the history
  • Loading branch information
tpeigne committed Jul 24, 2013
1 parent 098187d commit 3e53527
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
51 changes: 49 additions & 2 deletions modules/responsivetopbar/responsivetopbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,51 @@ public function __construct()

public function install()
{
return (parent::install() AND $this->registerHook('top') AND $this->registerHook('header'));
// Install Module
if (!parent::install() OR !$this->registerHook('top') OR !$this->registerHook('header'))
return false;

//configuration update
if (Configuration::updateValue('RESPONSIVE_BLOCK_CART_AJAX', 1) == false)
return false;

return true;
}

public function getContent()
{
$output = '<h2>'.$this->displayName.'</h2>';
if (Tools::isSubmit('submitResponsiveBlockCart'))
{
$ajax = Tools::getValue('cart_ajax');
if ($ajax != 0 && $ajax != 1)
$output .= '<div class="alert error">'.$this->l('Ajax : Invalid choice.').'</div>';
else
Configuration::updateValue('RESPONSIVE_BLOCK_CART_AJAX', (int)($ajax));
$output .= '<div class="conf confirm">'.$this->l('Settings updated').'</div>';
}
return $output.$this->displayForm();
}

public function displayForm()
{
return '
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post">
<fieldset>
<legend>'.$this->l('Settings').'</legend>
<label>'.$this->l('Ajax cart').'</label>
<div class="margin-form">
<input type="radio" name="cart_ajax" id="ajax_on" value="1" '.(Tools::getValue('cart_ajax', Configuration::get('RESPONSIVE_BLOCK_CART_AJAX')) ? 'checked="checked" ' : '').'/>
<label class="t" for="ajax_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
<input type="radio" name="cart_ajax" id="ajax_off" value="0" '.(!Tools::getValue('cart_ajax', Configuration::get('RESPONSIVE_BLOCK_CART_AJAX')) ? 'checked="checked" ' : '').'/>
<label class="t" for="ajax_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
<p class="clear">'.$this->l('Activate AJAX mode for cart (compatible with the default theme)').'</p>
</div>
<center><input type="submit" name="submitResponsiveBlockCart" value="'.$this->l('Save').'" class="button" /></center>
</fieldset>
</form>';
}

public function hookTop($params)
Expand Down Expand Up @@ -171,7 +215,10 @@ public function assignContentVars(&$params)
public function hookHeader($params)
{
$this->context->controller->addCSS(($this->_path).'responsivetopbar.css');
$this->context->controller->addJs(($this->_path).'ajax-cart.js');

if ((int)(Configuration::get('RESPONSIVE_BLOCK_CART_AJAX'))) {
$this->context->controller->addJs(($this->_path).'ajax-cart.js');
}
}
}

Expand Down
9 changes: 8 additions & 1 deletion modules/responsivetopbar/translations/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
$_MODULE = array();
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_a51a9d164f0ded9abd07025c620bf9e2'] = 'Responsive top bar';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_e227615234794355a6009819491515d3'] = 'Ajoute une top barre menu en haut de votre site';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_c26dfd7d0b30d8437cf4ef7dd8f3b7cf'] = 'Pour activer le panier ajax, vous devez placer le module blockcart dans votre dossier modules.';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_eb4ae207521bbe6403f7fe9564d38cda'] = 'Ajax : choix non valable.';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_c888438d14855d7d96a2724ee9c306bd'] = 'Paramètres mis à jour';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_f4f70727dc34561dfde1a3c529b6205c'] = 'Paramètres';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_614a8820aa4ac08ce2ee398a41b10778'] = 'Panier Ajax';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Activé';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_b9f5c797ebbf55adccdd8539a65a0241'] = 'Désactivé';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_dba281afb9a38e654ea9dab4cd6cb0ca'] = 'Activer le mode Ajax du panier (compatible avec le thème par défaut)';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_c9cc8cce247e49bae79f15173ce97354'] = 'Enregistrer';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_20351b3328c35ab617549920f5cb4939'] = 'Personnalisation n°';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_ed6e9a09a111035684bb23682561e12d'] = 'supprimer cet article du panier';
$_MODULE['<{responsivetopbar}prestashop>responsivetopbar_c6995d6cc084c192bc2e742f052a5c74'] = 'Livraison gratuite !';
Expand Down

0 comments on commit 3e53527

Please sign in to comment.