@ -0,0 +1,51 @@ |
|||
.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg |
|||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html |
|||
:alt: License: LGPL-3 |
|||
|
|||
Website Multi Variant Add to Cart |
|||
================================= |
|||
This module allows you to select variants of the selected |
|||
product from the same window of the selected product itself. |
|||
|
|||
Installation |
|||
------------- |
|||
- www.odoo.com/documentation/18.0/setup/install.html |
|||
- Install our custom addon |
|||
|
|||
Company |
|||
------- |
|||
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
|||
|
|||
License |
|||
------- |
|||
GNU Lesser General Public License , Version 3 (LGPL v3). |
|||
(http://www.gnu.org/licenses/lgpl-3.0-standalone.html) |
|||
|
|||
Credits |
|||
------- |
|||
Developers : (V18) Ranjith R @ Cybrosys, |
|||
(V17) Ayana KP @ Cybrosys, |
|||
(V16) Abhin K @ Cybrosys, |
|||
Contact: odoo@cybrosys.com |
|||
|
|||
Contacts |
|||
-------- |
|||
* Mail Contact : odoo@cybrosys.com |
|||
* Website : https://cybrosys.comAbhin |
|||
|
|||
Bug Tracker |
|||
----------- |
|||
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
|||
|
|||
Maintainer |
|||
========== |
|||
.. image:: https://cybrosys.com/images/logo.png |
|||
:target: https://cybrosys.com |
|||
|
|||
This module is maintained by Cybrosys Technologies. |
|||
|
|||
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
|||
|
|||
Further information |
|||
=================== |
|||
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import controllers |
@ -0,0 +1,46 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
{ |
|||
'name': 'Website Multi Variant Add to Cart', |
|||
'version': '18.0.1.0.0', |
|||
'category': 'Website', |
|||
'summary': """Enhance product details page with prominent attribute options, |
|||
quantity box, and quick add to cart feature.""", |
|||
'description': """Multi Variant Add to Cart " |
|||
Present the comprehensive range of product attribute |
|||
options prominently on the product's details page, |
|||
accompanied by a convenient quantity box and a |
|||
streamlined 'quick add to cart' functionality.""", |
|||
'author': 'Cybrosys Techno Solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'website': 'https://www.cybrosys.com', |
|||
'depends': ['website_sale'], |
|||
'data': [ |
|||
'views/website_multi_variant_templates.xml' |
|||
], |
|||
'images': ['static/description/banner.jpg'], |
|||
'license': 'LGPL-3', |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False, |
|||
} |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import website_multi_variant |
@ -0,0 +1,75 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import http |
|||
from odoo.http import request |
|||
from odoo.addons.website_sale.controllers.main import WebsiteSale |
|||
|
|||
|
|||
class WebsiteVariantSale(WebsiteSale): |
|||
""" WebsiteSale class is inherited to add the |
|||
functionality to add the variants if selected """ |
|||
def _prepare_product_values(self, product, category, search, **kwargs): |
|||
"""Since the buy button is optional this function is supered |
|||
to give buy_now value from the settings to the template""" |
|||
values = super()._prepare_product_values(product, category, search, |
|||
**kwargs) |
|||
res = request.env['res.config.settings'].sudo().search([], limit=1, |
|||
order='id desc') |
|||
values['buy_now'] = res.enabled_buy_now_button |
|||
return values |
|||
|
|||
@http.route('/shop/cart/multi', type='http', auth="user", website=True) |
|||
def cart_update_multi(self, **post): |
|||
"""This controller is triggered when |
|||
the form is submitted and will update |
|||
the cart and redirect to payment if |
|||
selected to will redirect to cart""" |
|||
if post.get('product_tmpl_id'): |
|||
request.website.pricelist_id |
|||
sale_order = request.website.sale_get_order(force_create=1) |
|||
product_template = request.env['product.template'].sudo().browse( |
|||
int(post.get('product_tmpl_id'))) |
|||
if product_template: |
|||
for variant in product_template.product_variant_ids: |
|||
if post.get(f'quantity-{variant.id}'): |
|||
quantity = float(post.get(f'quantity-{variant.id}')) |
|||
if quantity >= 1: |
|||
if sale_order.order_line: |
|||
for rec in sale_order.order_line: |
|||
variant_ids_in_sale = \ |
|||
[record.product_id.id for record in |
|||
sale_order.order_line] |
|||
if variant.id not in variant_ids_in_sale: |
|||
sale_order._cart_update( |
|||
product_id=int(variant.id), |
|||
add_qty=float(quantity)) |
|||
elif rec.product_id.id == variant.id: |
|||
rec.product_uom_qty += float(quantity) |
|||
else: |
|||
sale_order._cart_update( |
|||
product_id=int(variant.id), |
|||
add_qty=float(quantity)) |
|||
|
|||
res = request.redirect('/shop/payment') if post.get( |
|||
'buy_now') else request.redirect( |
|||
'/shop/cart') |
|||
return res |
@ -0,0 +1,6 @@ |
|||
## Module <website_multi_variant> |
|||
|
|||
#### 19.02.2025 |
|||
#### Version 18.0.1.0.0 |
|||
#### ADD |
|||
- Initial commit for Website Multi Variant Add to Cart |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 767 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 760 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 697 KiB |
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 294 KiB |
After Width: | Height: | Size: 196 KiB |
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 296 KiB |
After Width: | Height: | Size: 187 KiB |
After Width: | Height: | Size: 319 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 747 KiB |
After Width: | Height: | Size: 42 KiB |
@ -0,0 +1,114 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<odoo> |
|||
<!--Product Template is inherited to add |
|||
the table that let users choose its variants--> |
|||
<template id="multi_variant_product" inherit_id="website_sale.product"> |
|||
<xpath expr="//div[@id='product_details']/div[@id='o_product_terms_and_share']" |
|||
position="before"> |
|||
<div class="multi_variant_list" |
|||
t-if="len(product.product_variant_ids) > 1" |
|||
style="margin-left:-28px;"> |
|||
<form method="post" action="/shop/cart/multi"> |
|||
<input type="hidden" name="csrf_token" |
|||
t-att-value="request.csrf_token()"/> |
|||
<t t-set="products" t-value="product"/> |
|||
<table class="table table-striped table-condensed" |
|||
id="product_variants"> |
|||
<thead> |
|||
<tr> |
|||
<th width="130">Attributes</th> |
|||
<th width="130">Price</th> |
|||
<th width="130">Quantity</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr t-foreach="product.product_variant_ids" |
|||
t-as="variant_ids"> |
|||
<td> |
|||
<div style="display: flex; justify-content: space-between;"> |
|||
<div> |
|||
<img class="variant_image" |
|||
style="width: 66%; border-radius: 10%;" |
|||
t-att-src="'/web/image/product.product/%s/image_128' % variant_ids.id"/> |
|||
</div> |
|||
<div style="display:block; width:111%;"> |
|||
<div t-foreach="variant_ids.product_template_attribute_value_ids" |
|||
t-as="attribute"> |
|||
<div> |
|||
<span t-field="attribute.attribute_id"/> |
|||
: |
|||
<span t-esc="attribute.name"/> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</td> |
|||
<td id="td-price" name="product_price"> |
|||
<span t-field="variant_ids.lst_price" |
|||
style="white-space: nowrap;" |
|||
t-options="{ 'widget': 'monetary', 'display_currency': website.currency_id }"/> |
|||
</td> |
|||
<td> |
|||
<div class="css_quantity input-group" |
|||
contenteditable="false"> |
|||
<a t-attf-href="#" |
|||
class="btn btn-secondary js_add_cart_json" |
|||
aria-label="Remove one" |
|||
title="Remove one"> |
|||
<i class="fa fa-minus"/> |
|||
</a> |
|||
<input type="text" |
|||
class="form-control quantity" |
|||
data-min="0" |
|||
t-att-name="'quantity-%s' % (variant_ids.id)" |
|||
value="0" |
|||
style="width:31px;text-align:center;"/> |
|||
<a t-attf-href="#" |
|||
class="btn btn-secondary float_left js_add_cart_json" |
|||
aria-label="Add one" |
|||
title="Add one"> |
|||
<i class="fa fa-plus"/> |
|||
</a> |
|||
</div> |
|||
</td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
<input name="product_tmpl_id" t-att-value="products.id" |
|||
type="hidden"/> |
|||
<div style="display: flex;align-items: center; margin-bottom: 2%"> |
|||
<a role='button' |
|||
type="submit" id="m_add_to_cart" |
|||
class="btn btn-primary btn-lg mt8 js_check_product a-submit" |
|||
style="padding-bottom: 0.10000000000000142rem;width: 28%; font-size: 91%;height: 38px; padding-top: 9px;" |
|||
> |
|||
<i class="fa fa-shopping-cart"/> |
|||
<span style="font-weight:bold">Add to Cart</span> |
|||
</a> |
|||
<div style="position: relative; display: inline-block; margin-left: 2%;"> |
|||
<input t-if="buy_now" role="button" |
|||
type="submit" name="buy_now" value="Buy Now" |
|||
class="btn btn-outline-primary btn-lg mt16 d-block d-sm-inline-block buy_now_variant" |
|||
style="margin-top: 1.3%; transform: translateY(-3px); padding: 6px 32px; padding-right: 30px; font-size: 16px" |
|||
/> |
|||
<i t-if="buy_now" class="fa fa-bolt me-2" |
|||
style="position: absolute;top: 20%;right: 90px; transform: translateY(-30%);"/> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
</xpath> |
|||
</template> |
|||
<!--Hides the add to cart and color selection |
|||
option from the screen if it has variants--> |
|||
<template id="quantity_hide" inherit_id="website_sale.product_quantity"> |
|||
<xpath expr="//div[@id='add_to_cart_wrap']" position="attributes"> |
|||
<attribute name="t-if">len(product.product_variant_ids) <= 1 |
|||
</attribute> |
|||
</xpath> |
|||
<xpath expr="//div[hasclass('js_main_product')]" position="attributes"> |
|||
<attribute name="t-if">len(product.product_variant_ids) <= 1 |
|||
</attribute> |
|||
</xpath> |
|||
</template> |
|||
</odoo> |