Skip to content

Commit

Permalink
// refacto on few get params
Browse files Browse the repository at this point in the history
  • Loading branch information
gRoussac committed Aug 28, 2014
1 parent ba0d1d4 commit 734c1d4
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 21 deletions.
2 changes: 1 addition & 1 deletion classes/controller/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1310,4 +1310,4 @@ protected function getColorsListCacheId($id_product)
{
return Product::getColorsListCacheId($id_product);
}
}
}
7 changes: 3 additions & 4 deletions controllers/front/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ public function postProcess()
*/
protected function processSubmitLogin()
{

Hook::exec('actionBeforeAuthentication');
$passwd = trim(Tools::getValue('passwd'));
$email = trim(Tools::getValue('email'));
Expand Down Expand Up @@ -459,7 +458,7 @@ protected function processSubmitAccount()
Tools::redirect(html_entity_decode($back));
// redirection: if cart is not empty : redirection to the cart
if (count($this->context->cart->getProducts(true)) > 0)
Tools::redirect('index.php?controller=order&multi-shipping='.(int)Tools::getValue('multi-shipping'));
Tools::redirect('index.php?controller=order'.($multi = (int)Tools::getValue('multi-shipping') ? '&multi-shipping='.$multi : ''));
// else : redirection to the account
else
Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account'));
Expand Down Expand Up @@ -621,7 +620,7 @@ protected function processSubmitAccount()

// redirection: if cart is not empty : redirection to the cart
if (count($this->context->cart->getProducts(true)) > 0)
Tools::redirect('index.php?controller=order&multi-shipping='.(int)Tools::getValue('multi-shipping'));
Tools::redirect('index.php?controller=order'.($multi = (int)Tools::getValue('multi-shipping') ? '&multi-shipping='.$multi : ''));
// else : redirection to the account
else
Tools::redirect('index.php?controller='.(($this->authRedirection !== false) ? urlencode($this->authRedirection) : 'my-account'));
Expand Down Expand Up @@ -719,4 +718,4 @@ protected function sendConfirmationMail(Customer $customer)
$customer->firstname.' '.$customer->lastname
);
}
}
}
17 changes: 14 additions & 3 deletions controllers/front/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,19 @@ public function init()
}
if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3)))
{
$back_url = $this->context->link->getPageLink('order', true, (int)$this->context->language->id, array('step' => $this->step, 'multi-shipping' => (int)Tools::getValue('multi-shipping')));
$params = array('multi-shipping' => (int)Tools::getValue('multi-shipping'), 'display_guest_checkout' => (int)Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'back' => $back_url);

$params = array();
if ($this->step)
$params['step'] = (int)$this->step;
if ($multi = (int)Tools::getValue('multi-shipping'))
$params['multi-shipping'] = $multi;
$back_url = $this->context->link->getPageLink('order', true, (int)$this->context->language->id, $params);

$params = array('back' => $back_url);
if ($multi)
$params['multi-shipping'] = $multi;
if ($guest = (int)Configuration::get('PS_GUEST_CHECKOUT_ENABLED'))
$params['display_guest_checkout'] = $guest;
Tools::redirect($this->context->link->getPageLink('authentication', true, (int)$this->context->language->id, $params));
}

Expand Down Expand Up @@ -405,4 +416,4 @@ public function setMedia()
if ($this->step == 2)
$this->addJS(_THEME_JS_DIR_.'order-carrier.js');
}
}
}
15 changes: 12 additions & 3 deletions controllers/front/ParentOrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ protected function _assignAddress()
Tools::redirect('');
}
else if (!Customer::getAddressesTotalById($this->context->customer->id))
Tools::redirect('index.php?controller=address&back='.urlencode('order.php?step=1&multi-shipping='.(int)Tools::getValue('multi-shipping')));
Tools::redirect('index.php?controller=address&back='.urlencode('order.php?step=1'.($multi = (int)Tools::getValue('multi-shipping') ? '&multi-shipping='.$multi : '')));
$customer = $this->context->customer;
if (Validate::isLoadedObject($customer))
{
Expand Down Expand Up @@ -423,8 +423,17 @@ protected function _assignAddress()
$bad_delivery = false;
if (($bad_delivery = (bool)!Address::isCountryActiveById((int)$this->context->cart->id_address_delivery)) || !Address::isCountryActiveById((int)$this->context->cart->id_address_invoice))
{
$back_url = $this->context->link->getPageLink('order', true, (int)$this->context->language->id, array('step' => Tools::getValue('step'), 'multi-shipping' => (int)Tools::getValue('multi-shipping')));
$params = array('multi-shipping' => (int)Tools::getValue('multi-shipping'), 'id_address' => ($bad_delivery ? (int)$this->context->cart->id_address_delivery : (int)$this->context->cart->id_address_invoice), 'back' => $back_url);
$params = array();
if ($this->step)
$params['step'] = (int)$this->step;
if ($multi = (int)Tools::getValue('multi-shipping'))
$params['multi-shipping'] = $multi;
$back_url = $this->context->link->getPageLink('order', true, (int)$this->context->language->id, $params);

$params = array('back' => $back_url, 'id_address' => ($bad_delivery ? (int)$this->context->cart->id_address_delivery : (int)$this->context->cart->id_address_invoice));
if ($multi)
$params['multi-shipping'] = $multi;

Tools::redirect($this->context->link->getPageLink('address', true, (int)$this->context->language->id, $params));
}
}
Expand Down
4 changes: 2 additions & 2 deletions themes/default-bootstrap/order-address-multishipping.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
<input type="hidden" class="hidden" name="step" value="2" />
<input type="hidden" name="back" value="{$back}" />
{if $back}
<a href="{$link->getPageLink('order', true, NULL, "step=0&amp;back={$back}")|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default"><i class="icon-chevron-left"></i>{l s='Continue Shopping'}</a>
<a href="{$link->getPageLink('order', true, NULL, "back={$back}")|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default"><i class="icon-chevron-left"></i>{l s='Continue Shopping'}</a>
{else}
<a href="{$link->getPageLink('order', true, NULL, "step=0")|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default"><i class="icon-chevron-left"></i>{l s='Continue Shopping'}</a>
<a href="{$link->getPageLink('order', true, NULL)|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default"><i class="icon-chevron-left"></i>{l s='Continue Shopping'}</a>
{/if}
<button type="submit" name="processAddress" class="button btn btn-default button-medium"><span>{l s='Proceed to checkout'}<i class="icon-chevron-right right"></i></span></button>
</p>
Expand Down
2 changes: 1 addition & 1 deletion themes/default-bootstrap/order-address.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<p class="cart_navigation clearfix">
<input type="hidden" class="hidden" name="step" value="2" />
<input type="hidden" name="back" value="{$back}" />
<a href="{$link->getPageLink($back_order_page, true, NULL, "step=0{if $back}&back={$back}{/if}")|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default">
<a href="{$link->getPageLink($back_order_page, true, NULL, "{if $back}back={$back}{/if}")|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default">
<i class="icon-chevron-left"></i>
{l s='Continue Shopping'}
</a>
Expand Down
8 changes: 4 additions & 4 deletions themes/default-bootstrap/order-carrier.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<h1 class="page-heading">{l s='Shipping:'}</h1>
{include file="$tpl_dir./order-steps.tpl"}
{include file="$tpl_dir./errors.tpl"}
<form id="form" action="{$link->getPageLink('order', true, NULL, "multi-shipping={$multi_shipping}")|escape:'html':'UTF-8'}" method="post" name="carrier_area">
<form id="form" action="{$link->getPageLink('order', true, NULL, "{if $multi_shipping}multi-shipping={$multi_shipping}{/if}")|escape:'html':'UTF-8'}" method="post" name="carrier_area">
{else}
<div id="carrier_area" class="opc-main-block">
<h1 class="page-heading step-num"><span>2</span> {l s='Delivery methods'}</h1>
Expand Down Expand Up @@ -342,18 +342,18 @@
<input type="hidden" name="back" value="{$back}" />
{if !$is_guest}
{if $back}
<a href="{$link->getPageLink('order', true, NULL, "step=1&back={$back}&multi-shipping={$multi_shipping}")|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default">
<a href="{$link->getPageLink('order', true, NULL, "step=1&back={$back}{if $multi_shipping}&multi-shipping={$multi_shipping}{/if}")|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default">
<i class="icon-chevron-left"></i>
{l s='Continue shopping'}
</a>
{else}
<a href="{$link->getPageLink('order', true, NULL, "step=1&multi-shipping={$multi_shipping}")|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default">
<a href="{$link->getPageLink('order', true, NULL, "step=1{if $multi_shipping}&multi-shipping={$multi_shipping}{/if}")|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default">
<i class="icon-chevron-left"></i>
{l s='Continue shopping'}
</a>
{/if}
{else}
<a href="{$link->getPageLink('order', true, NULL, "multi-shipping={$multi_shipping}")|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default">
<a href="{$link->getPageLink('order', true, NULL, "{if $multi_shipping}multi-shipping={$multi_shipping}{/if}")|escape:'html':'UTF-8'}" title="{l s='Previous'}" class="button-exclusive btn btn-default">
<i class="icon-chevron-left"></i>
{l s='Continue shopping'}
</a>
Expand Down
6 changes: 3 additions & 3 deletions themes/default-bootstrap/order-steps.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</li>
<li class="{if $current_step=='login'}step_current{elseif $current_step=='address'}step_done step_done_last{else}{if $current_step=='payment' || $current_step=='shipping' || $current_step=='address'}step_done{else}step_todo{/if}{/if} second">
{if $current_step=='payment' || $current_step=='shipping' || $current_step=='address'}
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&step=1&multi-shipping={$multi_shipping}")|escape:'html':'UTF-8'}">
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&step=1{if $multi_shipping}&multi-shipping={$multi_shipping}{/if}")|escape:'html':'UTF-8'}">
<em>02.</em> {l s='Sign in'}
</a>
{else}
Expand All @@ -55,7 +55,7 @@
</li>
<li class="{if $current_step=='address'}step_current{elseif $current_step=='shipping'}step_done step_done_last{else}{if $current_step=='payment' || $current_step=='shipping'}step_done{else}step_todo{/if}{/if} third">
{if $current_step=='payment' || $current_step=='shipping'}
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&step=1&multi-shipping={$multi_shipping}")|escape:'html':'UTF-8'}">
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&step=1{if $multi_shipping}&multi-shipping={$multi_shipping}{/if}")|escape:'html':'UTF-8'}">
<em>03.</em> {l s='Address'}
</a>
{else}
Expand All @@ -64,7 +64,7 @@
</li>
<li class="{if $current_step=='shipping'}step_current{else}{if $current_step=='payment'}step_done step_done_last{else}step_todo{/if}{/if} four">
{if $current_step=='payment'}
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&step=2&multi-shipping={$multi_shipping}")|escape:'html':'UTF-8'}">
<a href="{$link->getPageLink('order', true, NULL, "{$smarty.capture.url_back}&step=2{if $multi_shipping}&multi-shipping={$multi_shipping}{/if}")|escape:'html':'UTF-8'}">
<em>04.</em> {l s='Shipping'}
</a>
{else}
Expand Down

0 comments on commit 734c1d4

Please sign in to comment.