Jump to content

Proceed to checkout destination login instead of summary


Jurist

Recommended Posts

Hello,

 

I would like to make customers who click on Proceed to checkout button in cart module to land on login page instead of summary. 

 

How to make Proceed to checkout button redirect yoursite.com/order?step=1&display_guest_checkout=1 instead of yoursite.com/order ?

 

Should I edit blockcart.tpl 

 

<p id="cart-buttons">
{if $order_process == 'order'}<a href="{$link->getPageLink("$order_process", true)|escape:'html'}" class="button_small" title="{l s='View my shopping cart' mod='blockcart'}" rel="nofollow">{l s='Cart' mod='blockcart'}</a>{/if}
<a href="{$link->getPageLink("$order_process", true)|escape:'html'}" id="button_order_cart" class="exclusive{if $order_process == 'order-opc'}_large{/if}" title="{l s='Check out' mod='blockcart'}" rel="nofollow"><span></span>{l s='Check out' mod='blockcart'}</a>
</p>

or rather order-steps.tpl ?

 

<li class="{if $current_step=='summary'}step_current {elseif $current_step=='login'}step_done_last step_done{else}{if $current_step=='payment' || $current_step=='shipping' || $current_step=='address' || $current_step=='login'}step_done{else}step_todo{/if}{/if} first">
{if $current_step=='payment' || $current_step=='shipping' || $current_step=='address' || $current_step=='login'}
<a href="{$link->getPageLink('order', true)}">
<em>01.</em> {l s='Summary'}
</a>
{else}
<span><em>01.</em> {l s='Summary'}</span>
{/if}
</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'}">
<em>02.</em> {l s='Login'}
</a>
{else}
<span><em>02.</em> {l s='Login'}</span>
{/if}
</li>

Any tip will be greatly appreciated. 

Link to comment
Share on other sites

You could try changing the {$link->getPageLink("$order_process", true)|escape:'html'} in blockcart.tpl to {$link->getPageLink("authentication", true)|escape:'html'}&back={$link->getPageLink("$order_process", true)|escape:'html'}. I haven't tested this, but it should go to the login page and then redirect back to the order page after logging in.

  • Like 1
Link to comment
Share on other sites

Hello,

 

Many thanks for your instruction, I partially solved my problem. However this link should be only present where the user is not logged and not guest. I added condition but it doesn't work:

 

{if !$logged && ($isGuest == 0)} 
<a class="btn btn-default button button-medium" href="{$link->getPageLink("authentication", true)|escape:'html'}?display_guest_checkout=1#order_step" title="{l s='Proceed to checkout' mod='blockcart'}" rel="nofollow">
<span>
{l s='Proceed to checkout' mod='blockcart'}<i class="icon-chevron-right right"></i>
</span>
</a> 
{else} 
<a class="btn btn-default button button-medium" href="{$link->getPageLink("$order_process", true)|escape:"html":"UTF-8"}" title="{l s='Proceed to checkout' mod='blockcart'}" rel="nofollow">
<span>
{l s='Proceed to checkout' mod='blockcart'}<i class="icon-chevron-right right"></i>
</span>
</a> 
{/if}

Any idea why it's not working?

Link to comment
Share on other sites

I don't think there's any need to check whether the customer is a guest, only whether they are logged in. On my PrestaShop v1.6.1.6 test site, I changed the following code on line 193 of themes/default-bootstrap/modules/blockcart/blockcart.tpl from:

							<a id="button_order_cart" class="btn btn-default button button-small" href="{$link->getPageLink("$order_process", true)}" title="{l s='Check out' mod='blockcart'}" rel="nofollow">

to:

							<a id="button_order_cart" class="btn btn-default button button-small" href="{if !$logged}{$link->getPageLink("authentication", true)|escape:'html'}?back={/if}{$link->getPageLink("$order_process", true)}" title="{l s='Check out' mod='blockcart'}" rel="nofollow">

and line 326 from:

					<a class="btn btn-default button button-medium"	href="{$link->getPageLink("$order_process", true)|escape:"html":"UTF-8"}" title="{l s='Proceed to checkout' mod='blockcart'}" rel="nofollow">

to:

					<a class="btn btn-default button button-medium"	href="{if !$logged}{$link->getPageLink("authentication", true)|escape:'html'}?back={/if}{$link->getPageLink("$order_process", true)|escape:"html":"UTF-8"}" title="{l s='Proceed to checkout' mod='blockcart'}" rel="nofollow">

This appears to be working on my test site. When I click on the "Check out" button in the cart or the "Proceed to checkout" button on the popup without being logged in, it goes to the authentication page and after logging in, clicking the button goes to the quick order page instead.

Link to comment
Share on other sites

The problem is when I am adding guest checkout on landing login page.

 

{$link->getPageLink("authentication", true)|escape:'html'}?display_guest_checkout=1

 

if there's a guest and he clicks proceed to checkout gain he will have login page again 

Link to comment
Share on other sites

No, I added ?display_guest_checkout=1 to url by purpose to make customers see login and address fields after clicking proceed to checkout button. It works fine, on my site after clicking Proceed to checkout customer lands there but when he goes to see the product and then clicks proceed to checkout again there are login fields again.

 

The problem I currently have is how to check if user has guest account and why conditions I used are not working.

 

Thank you very much for your time

Link to comment
Share on other sites

Unfortunately it didn't help. I tried to leave only {if !$logged} and created account to check if it works and suprisingly no. It looks like it's cached somewhere, not checked with every page refresh. That's odd because I used similar conditions on other parts of the site and they work without problems. Is there any way to force smarty to always check conditions for part of the code?

 

Thanks for your help again. Appreciated.

Link to comment
Share on other sites

I wouldn't expect those values to be cached. The Smarty variables are created on lines 457-458 (in PrestaShop v1.6.1.6) of classes/FrontController.php:

            'is_logged'           => (bool)$this->context->customer->isLogged(),
            'is_guest'            => (bool)$this->context->customer->isGuest(),

I don't understand why it isn't working.

  • Like 1
Link to comment
Share on other sites

I've noticed one thing today - condition works only on order step pages, for e.g. addresses or carriers. If I am a guest user on step 03. Adress button proceed to checkout leads to /order page like it should but after clicking on home page same button link to /order?login page

 

With firebug I can see that isLogged = 0 and isGuest = 1, there's {if !$logged && !$is_guest} condition in blockcart.pl and the wrong button is still displayed. Even if customer is guest user there's still {if !$logged && !$is_guest} button {/if} visible. 

 

Is there any options to force smarty to check condition before displaying part of .tpl file?

 

Thank you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...