Skip to content

Commit

Permalink
porting website_sale_suggest_create_account to 12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eLBati committed Oct 1, 2018
1 parent f530fa3 commit f8986d4
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 88 deletions.
75 changes: 0 additions & 75 deletions website_sale_suggest_create_account/README.rst

This file was deleted.

2 changes: 1 addition & 1 deletion website_sale_suggest_create_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Suggest to create user account when buying",
"summary": "Suggest users to create an account when buying in the website",
"version": "11.0.1.0.0",
"version": "12.0.1.0.0",
"category": "Website",
"website": "https://www.tecnativa.com",
"author": "Tecnativa, "
Expand Down
6 changes: 6 additions & 0 deletions website_sale_suggest_create_account/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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.
4 changes: 4 additions & 0 deletions website_sale_suggest_create_account/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Rafael Blasco <rafabn@antiun.com>
* Jairo Llopis <yajo.sk8@gmail.com>
* Dave Lasley <dave@laslabs.com>
* Oscar Alcala <oscar@vauxoo.com>
8 changes: 8 additions & 0 deletions website_sale_suggest_create_account/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This module extends the functionality of e-Commerce to suggest
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.
7 changes: 7 additions & 0 deletions website_sale_suggest_create_account/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To use this module, you need to:

* Log out.
* Buy something from your website.
* Go to your cart.

There you will see the new options.
69 changes: 57 additions & 12 deletions website_sale_suggest_create_account/views/website_sale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,81 @@
<template id="cart" inherit_id="website_sale.cart">
<xpath expr="//div[@id='wrap']" position="before">
<t t-set="user_authenticated" t-value="user_id != website.user_id"/>
<t t-set="signup_allowed" t-value="env['ir.config_parameter'].sudo().get_param('auth_signup.allow_uninvited') == 'True' "/>
<!-- TODO: optional_products has to be removed since odoo 12.0 at least. See https://github.com/odoo/odoo/pull/21461 -->
<t t-set="can_checkout" t-value="not optional_products
and website_sale_order and
<t t-set="signup_allowed" t-value="env['ir.config_parameter'].sudo().get_param('auth_signup.invitation_scope') == 'b2c' "/>
<t t-set="can_checkout" t-value="website_sale_order and
website_sale_order.website_order_line"/>

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

<!-- Show normal "Checkout" button if user is logged in or external login
is disabled -->
<xpath expr="//a[@href='/shop/checkout']" position="attributes">
<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>
</xpath>

<!-- Show choice in other cases -->
<xpath expr="//a[@href='/shop/checkout']" position="after">
<a t-if="not user_authenticated"
class="btn btn-primary pull-right mb32"
href="/web/login?redirect=/shop/checkout">
<xpath expr="//div[hasclass('oe_cart')]//a[@href='/shop/checkout?express=1']" position="after">
<a t-if="not user_authenticated" 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>
<span class="fa fa-long-arrow-right"/>
</a>
<t t-if="suggest_create_account">
<a class="btn btn-primary pull-right mb32"
href="/web/signup?redirect=/shop/checkout">
<a class="btn btn-primary pull-right mb32 d-none d-xl-inline-block" role="button"
href="/web/signup?redirect=/shop/checkout?express=1">
<span>Sign up and checkout</span>
<span class="fa fa-long-arrow-right"/>
</a>
<a id="anonymous_checkout" class="btn btn-default mb32" href="/shop/checkout">
<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>
</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"
class="btn btn-primary pull-right mb32 d-xl-none"
href="/web/login?redirect=/shop/checkout?express=1">
<span>Log in and checkout</span>
<span class="fa fa-long-arrow-right"/>
</a>
<t t-if="suggest_create_account">
<a class="btn btn-primary pull-right mb32 d-xl-none" role="button"
href="/web/signup?redirect=/shop/checkout?express=1">
<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>

</template>

<!-- 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>
</xpath>
<xpath expr="//a[@href='/shop/checkout?express=1']" position="after">
<a t-if="not user_authenticated" 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>
</a>
<t t-if="suggest_create_account">
<a class="btn btn-secondary float-right d-none d-xl-inline-block" role="button"
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>
Expand Down

0 comments on commit f8986d4

Please sign in to comment.