[IMP] website_sale: review cart button design and templates

Move it in an external view to be able to place it at a different
location depending on the header template.

Part of https://github.com/odoo/odoo/pull/56427
task-2264627

X-original-commit: d5617a1acac9a8371fc9d9b8115e90c4059ded7d
This commit is contained in:
Cocographique
2020-08-28 08:19:38 +00:00
committed by Xavier-Do
parent 4e53f861a2
commit cb6e07a573
2 changed files with 23 additions and 13 deletions
@@ -101,8 +101,8 @@
<div data-selector="#wrapwrap > header"
data-no-check="true"
groups="website.group_website_designer">
<we-checkbox string="Always Show Cart"
data-customize-website-views="website_sale.hide_cart_if_empty|"
<we-checkbox string="Show Empty Cart"
data-customize-website-views="website_sale.header_hide_empty_cart_link|"
data-no-preview="true"
data-reload="/"/>
</div>
+21 -11
View File
@@ -73,21 +73,31 @@
</xpath>
</template>
<template id="header" inherit_id="website.layout" name="Header Shop My Cart Link">
<template id="layout" inherit_id="website.layout">
<xpath expr="//header//ul[@id='top_menu']/t[@t-foreach='website.menu_id.child_id']" position="after">
<t t-set="website_sale_order" t-value="website.sale_get_order()" />
<t t-set="show_cart" t-value="true"/>
<li class="nav-item divider d-none"/> <!-- Make sure the cart and related menus are not folded (see autohideMenu) -->
<li t-attf-class="nav-item o_wsale_my_cart #{not show_cart and 'd-none'}">
<a href="/shop/cart" class="nav-link">
<i class="fa fa-shopping-cart"></i>
My Cart <sup t-attf-class="my_cart_quantity badge badge-primary" t-esc="website_sale_order and website_sale_order.cart_quantity or ''" t-att-data-order-id="website_sale_order and website_sale_order.id or ''"/>
</a>
</li>
<t t-call="website_sale.header_cart_link">
<t t-set="_icon" t-value="True"/>
<t t-set="_text" t-value="True"/>
<t t-set="_item_class" t-value="'nav-item'"/>
<t t-set="_link_class" t-value="'nav-link'"/>
</t>
</xpath>
</template>
<template id="hide_cart_if_empty" inherit_id="website_sale.header" name="Hide Cart If Empty">
<template id="header_cart_link" name="Header Cart Link">
<t t-set="website_sale_order" t-value="website.sale_get_order()" />
<t t-set="show_cart" t-value="true"/>
<li t-attf-class="#{_item_class} divider d-none"/> <!-- Make sure the cart and related menus are not folded (see autohideMenu) -->
<li t-attf-class="o_wsale_my_cart #{not show_cart and 'd-none'} #{_item_class}">
<a href="/shop/cart" t-attf-class="#{_link_class}">
<i t-if="_icon" class="fa fa-shopping-cart"/>
<span t-if="_text">My Cart</span>
<sup class="my_cart_quantity badge badge-primary" t-esc="website_sale_order and website_sale_order.cart_quantity or '0'" t-att-data-order-id="website_sale_order and website_sale_order.id or ''"/>
</a>
</li>
</template>
<template id="header_hide_empty_cart_link" inherit_id="website_sale.header_cart_link" name="Header Hide Empty Cart link" active="False">
<xpath expr="//t[@t-set='show_cart']" position="after">
<t t-set="show_cart" t-value="show_cart and website_sale_order and website_sale_order.cart_quantity" />
</xpath>