[IMP] website_sale_wishlist: review wishlist templates
1) Allow to enable the wishlist button on the shop page and the product pages individually. Also remove the code which allowed to disabled the feature entirely but keeping the module installed: if users don't want it, just uninstall the app (the feature was in website_sale directly at some point). 2) Add a new option to be able to show the wishlist counter even if no item has been added in the wishlist yet. 3) Move the feature in external views to be able to be placed at a different location depending on the header template. Part of https://github.com/odoo/odoo/pull/56427 task-2264627 X-original-commit: de97be253a54648ebd392f7f4f66ef16cc72b8af Co-authored-by: Cocographique <nmi@odoo.com>
This commit is contained in:
committed by
Xavier-Do
co-authored by
Cocographique
parent
cb6e07a573
commit
28f08d7ff8
@@ -14,6 +14,7 @@ Allow shoppers of your eCommerce store to create personalized collections of pro
|
||||
'security/website_sale_wishlist_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'views/website_sale_wishlist_template.xml',
|
||||
'views/snippets.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -121,12 +121,11 @@ publicWidget.registry.ProductWishlist = publicWidget.Widget.extend(VariantMixin,
|
||||
* @private
|
||||
*/
|
||||
_updateWishlistView: function () {
|
||||
if (this.wishlistProductIDs.length > 0) {
|
||||
$('.o_wsale_my_wish').show();
|
||||
$('.my_wish_quantity').text(this.wishlistProductIDs.length);
|
||||
} else {
|
||||
$('.o_wsale_my_wish').hide();
|
||||
const $wishButton = $('.o_wsale_my_wish');
|
||||
if ($wishButton.hasClass('o_wsale_my_wish_hide_empty')) {
|
||||
$wishButton.toggleClass('d-none', !this.wishlistProductIDs.length);
|
||||
}
|
||||
$wishButton.find('.my_wish_quantity').text(this.wishlistProductIDs.length);
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<template id="snippet_options" inherit_id="website.snippet_options" name="Wishlist Snippet Options">
|
||||
<xpath expr="." position="inside">
|
||||
<div data-selector="#wrapwrap > header"
|
||||
data-no-check="true"
|
||||
groups="website.group_website_designer">
|
||||
<we-checkbox string="Show Empty Wishlist"
|
||||
data-customize-website-views="website_sale_wishlist.header_hide_empty_wishlist_link|"
|
||||
data-no-preview="true"
|
||||
data-reload="/"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
@@ -14,7 +14,7 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="add_to_wishlist" inherit_id="website_sale.products_item" customize_show="True" name="Wishlist" priority="20">
|
||||
<template id="add_to_wishlist" inherit_id="website_sale.products_item" customize_show="True" name="Wishlist Button" priority="20">
|
||||
<xpath expr="//div[hasclass('o_wsale_product_btn')]" position="inside">
|
||||
<t t-set="in_wish" t-value="product._is_in_wishlist()"/>
|
||||
<t t-set="product_variant_id" t-value="product._get_first_possible_variant_id()"/>
|
||||
@@ -22,27 +22,43 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="product_add_to_wishlist" name='Add to wishlist in product page' inherit_id="website_sale.product" priority="20">
|
||||
<template id="product_add_to_wishlist" inherit_id="website_sale.product" customize_show="True" name="Wishlist Button" priority="20">
|
||||
<xpath expr="//div[@id='product_option_block']" position="inside">
|
||||
<t t-if="is_view_active('website_sale_wishlist.add_to_wishlist')">
|
||||
<t t-set="product_variant" t-value="product_variant or product._create_first_product_variant()"/>
|
||||
<t t-set="in_wish" t-value="product_variant and product_variant._is_in_wishlist()"/>
|
||||
<button t-if="product_variant" type="button" role="button" class="btn btn-link mt16 o_add_wishlist_dyn" t-att-disabled='in_wish or None' t-att-data-product-template-id="product.id" t-att-data-product-product-id="product_variant.id" data-action="o_wishlist"><span class="fa fa-heart" role="img" aria-label="Add to wishlist"></span> Add to wishlist</button>
|
||||
<t t-set="product_variant" t-value="product_variant or product._create_first_product_variant()"/>
|
||||
<t t-set="in_wish" t-value="product_variant and product_variant._is_in_wishlist()"/>
|
||||
<button t-if="product_variant" type="button" role="button" class="btn btn-link mt16 o_add_wishlist_dyn" t-att-disabled='in_wish or None' t-att-data-product-template-id="product.id" t-att-data-product-product-id="product_variant.id" data-action="o_wishlist"><span class="fa fa-heart" role="img" aria-label="Add to wishlist"></span> Add to wishlist</button>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="layout" inherit_id="website_sale.layout">
|
||||
<xpath expr="//t[@t-call='website_sale.header_cart_link']" position="after">
|
||||
<t t-call="website_sale_wishlist.header_wishlist_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="header" inherit_id="website.layout" name="Header Shop Wishlist Link">
|
||||
<xpath expr="//header//ul[@id='top_menu']/li[contains(@t-attf-class, 'o_wsale_my_cart')]" position="after">
|
||||
<t t-if="is_view_active('website_sale_wishlist.add_to_wishlist')">
|
||||
<t t-set='wishcount' t-value="len(request.env['product.wishlist'].current())"/>
|
||||
<li class="nav-item o_wsale_my_wish" t-att-style="not wishcount and 'display:none;'">
|
||||
<a href="/shop/wishlist" class="nav-link">
|
||||
<i class="fa fa-heart"/>
|
||||
Wishlist <sup t-attf-class="my_wish_quantity o_animate_blink badge badge-primary"><t t-esc='wishcount'/></sup>
|
||||
</a>
|
||||
</li>
|
||||
</t>
|
||||
<template id="header_wishlist_link" name="Header Wishlist Link">
|
||||
<t t-set="wishcount" t-value="len(request.env['product.wishlist'].current())"/>
|
||||
<t t-set="show_wishes" t-value="True"/>
|
||||
<li t-attf-class="o_wsale_my_wish #{not show_wishes and 'd-none'} #{_item_class}">
|
||||
<a href="/shop/wishlist" t-attf-class="#{_link_class}">
|
||||
<i t-if="_icon" class="fa fa-1x fa-heart"/>
|
||||
<span t-if="_text">Wishlist</span>
|
||||
<sup t-esc="wishcount" t-attf-class="my_wish_quantity o_animate_blink badge badge-primary"/>
|
||||
</a>
|
||||
</li>
|
||||
</template>
|
||||
|
||||
<template id="header_hide_empty_wishlist_link" inherit_id="website_sale_wishlist.header_wishlist_link">
|
||||
<xpath expr="//t[@t-set='show_wishes']" position="after">
|
||||
<t t-set="show_wishes" t-value="show_wishes and wishcount > 0"/>
|
||||
</xpath>
|
||||
<xpath expr="//li[contains(@t-attf-class, 'o_wsale_my_wish')]" position="attributes">
|
||||
<attribute name="t-attf-class" add="o_wsale_my_wish_hide_empty" separator=" "/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user