Skip to content

Commit

Permalink
IMP website_sale_suggest_create_account buttons cleanup:
Browse files Browse the repository at this point in the history
Always show 'Process Checkout', not highlighted if user not logged in
Suggest to login or signup, according to 'invitation_scope', avoiding too many buttons in cart page
  • Loading branch information
eLBati committed Oct 1, 2018
1 parent 35729b3 commit 3fcaf91
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 35 deletions.
14 changes: 2 additions & 12 deletions website_sale_suggest_create_account/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,14 @@ the buyer to log in or create an account, but without forcing him to do it.
This way you can avoid duplication of partners in your database and offer your
users a better experience without blocking 1-time buyers.

However, the *Checkout without sign in* button is not highlighted, to
implicitly encourage users to create the account.
However, the *Process Checkout* button is not highlighted, to
implicitly encourage users to create the account or log in.

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure this module, you need to:

* *Settings > Configuration > General Settings* and enable *Allow external
users to sign up*.

Otherwise you will notice no change after installing this module.

Usage
=====

Expand Down
6 changes: 0 additions & 6 deletions website_sale_suggest_create_account/readme/CONFIGURE.rst

This file was deleted.

4 changes: 2 additions & 2 deletions website_sale_suggest_create_account/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ the buyer to log in or create an account, but without forcing him to do it.
This way you can avoid duplication of partners in your database and offer your
users a better experience without blocking 1-time buyers.

However, the *Checkout without sign in* button is not highlighted, to
implicitly encourage users to create the account.
However, the *Process Checkout* button is not highlighted, to
implicitly encourage users to create the account or log in.
25 changes: 10 additions & 15 deletions website_sale_suggest_create_account/views/website_sale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
website_sale_order.website_order_line"/>

<t t-set="suggest_create_account" t-value="not user_authenticated and signup_allowed and can_checkout" />
<t t-set="suggest_login" t-value="not user_authenticated and not signup_allowed and can_checkout" />
</xpath>

<!-- Show normal "Checkout" button if user is logged in or external login
is disabled -->
<xpath expr="//div[hasclass('oe_cart')]//a[@href='/shop/checkout?express=1']" position="attributes">
<attribute name="t-if">(user_authenticated or not signup_allowed) and can_checkout</attribute>
<attribute name="class"/>
<attribute name="t-attf-class">#{'btn btn-primary float-right d-none d-xl-inline-block' if user_authenticated else 'btn btn-default float-right d-none d-xl-inline-block'}</attribute>
</xpath>

<!-- Show choice in other cases -->
<xpath expr="//div[hasclass('oe_cart')]//a[@href='/shop/checkout?express=1']" position="after">
<a t-if="not user_authenticated" role="button"
<a t-if="suggest_login" role="button"
class="btn btn-primary pull-right mb32 d-none d-xl-inline-block"
href="/web/login?redirect=/shop/checkout?express=1">
<span>Log in and checkout</span>
Expand All @@ -30,18 +32,16 @@
<span>Sign up and checkout</span>
<span class="fa fa-long-arrow-right"/>
</a>
<a id="anonymous_checkout" class="btn btn-default mb32 d-none d-xl-inline-block" href="/shop/checkout?express=1">
<span>Checkout without sign up</span>
</a>
</t>
</xpath>

<!-- Buttons for small screens, same modifications as above -->
<xpath expr="//div[hasclass('col-12','col-xl-4')]//a[@href='/shop/checkout?express=1']" position="attributes">
<attribute name="t-if">(user_authenticated or not signup_allowed) and can_checkout</attribute>
<attribute name="class"/>
<attribute name="t-attf-class">#{'btn btn-primary float-right' if user_authenticated else 'btn btn-default float-right'}</attribute>
</xpath>
<xpath expr="//div[hasclass('col-12','col-xl-4')]//a[@href='/shop/checkout?express=1']" position="after">
<a t-if="not user_authenticated" role="button"
<a t-if="suggest_login" role="button"
class="btn btn-primary pull-right mb32 d-xl-none"
href="/web/login?redirect=/shop/checkout?express=1">
<span>Log in and checkout</span>
Expand All @@ -53,9 +53,6 @@
<span>Sign up and checkout</span>
<span class="fa fa-long-arrow-right"/>
</a>
<a id="anonymous_checkout" class="btn btn-default mb32 d-xl-none" href="/shop/checkout?express=1">
<span>Checkout without sign up</span>
</a>
</t>
</xpath>

Expand All @@ -64,10 +61,11 @@
<!-- Cart summary -->
<template id="short_cart_summary" inherit_id="website_sale.short_cart_summary">
<xpath expr="//a[@href='/shop/checkout?express=1']" position="attributes">
<attribute name="t-if">(user_authenticated or not signup_allowed) and can_checkout</attribute>
<attribute name="class"/>
<attribute name="t-attf-class">#{'btn btn-secondary float-right d-none d-xl-inline-block' if user_authenticated else 'btn btn-default float-right d-none d-xl-inline-block'}</attribute>
</xpath>
<xpath expr="//a[@href='/shop/checkout?express=1']" position="after">
<a t-if="not user_authenticated" role="button"
<a t-if="suggest_login" role="button"
class="btn btn-secondary float-right d-none d-xl-inline-block"
href="/web/login?redirect=/shop/checkout?express=1">
<span>Log in and checkout</span>
Expand All @@ -77,9 +75,6 @@
href="/web/signup?redirect=/shop/checkout?express=1" style="margin-top:3px">
<span>Sign up and checkout</span>
</a>
<a id="anonymous_checkout" class="btn btn-default float-right d-none d-xl-inline-block" href="/shop/checkout?express=1">
<span>Checkout without sign up</span>
</a>
</t>
</xpath>
</template>
Expand Down

0 comments on commit 3fcaf91

Please sign in to comment.