Skip to content

Commit

Permalink
Merge pull request #15 from coopiteasy/14.0-mig-website_sale_add_to_c…
Browse files Browse the repository at this point in the history
…art_popup

[14.0][MIG] website_sale_add_to_cart_popup
  • Loading branch information
carmenbianca authored Mar 24, 2022
2 parents 43caf26 + d48ff00 commit bbc01fe
Show file tree
Hide file tree
Showing 12 changed files with 605 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/website_sale_add_to_cart_popup/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
71 changes: 71 additions & 0 deletions website_sale_add_to_cart_popup/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
==============================
Website Sale Add To Cart Popup
==============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-coopiteasy%2Fcie--e--commerce-lightgray.png?logo=github
:target: https://github.com/coopiteasy/cie-e-commerce/tree/12.0/website_sale_add_to_cart_popup
:alt: coopiteasy/cie-e-commerce

|badge1| |badge2| |badge3|

With this module installed, the "Add to cart" popup is always shown when
clicking on add to cart button. Even if the product has no optional
product.

By default in Odoo, this popup is only shown when the product has
optional product configured correctly. Here the goal is to always show
this popup to let user pursue shopping after adding an item to cart.

**Table of contents**

.. contents::
:local:

Usage
=====

1. Install module
2. Go on the e-commerce and click on the "Add to cart" button. A popup
will appear with the ability to chose to "go to cart" or "continue
shopping".

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/coopiteasy/cie-e-commerce/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/coopiteasy/cie-e-commerce/issues/new?body=module:%20website_sale_add_to_cart_popup%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Coop IT Easy SCRLfs

Contributors
~~~~~~~~~~~~

* Rémy Taymans <remy@coopiteasy.bey>

Maintainers
~~~~~~~~~~~

This module is part of the `coopiteasy/cie-e-commerce <https://github.com/coopiteasy/cie-e-commerce/tree/12.0/website_sale_add_to_cart_popup>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions website_sale_add_to_cart_popup/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import controllers
15 changes: 15 additions & 0 deletions website_sale_add_to_cart_popup/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Coop IT Easy SCRLfs <https://coopiteasy.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Website Sale Add To Cart Popup",
"summary": "Always show the add to cart popup in the e-commerce.",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Coop IT Easy SCRLfs",
"website": "https://coopiteasy.be",
"depends": [
"sale_product_configurator",
"website_sale", # Recommends
],
}
1 change: 1 addition & 0 deletions website_sale_add_to_cart_popup/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_configurator
56 changes: 56 additions & 0 deletions website_sale_add_to_cart_popup/controllers/product_configurator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2021 Coop IT Easy SCRLfs <https://coopiteasy.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.http import request

from odoo.addons.sale_product_configurator.controllers.main import (
ProductConfiguratorController,
)


class ProductConfiguratorController(ProductConfiguratorController):
def _show_optional_products(
self, product_id, variant_values, pricelist, handle_stock, **kw
):
"""
Overwrite default behaviour to always show a content for the
add to cart modal.
Copied verbatim from sale_product_configurator, and slightly adjusted.
"""
product = request.env["product.product"].browse(int(product_id))
combination = request.env["product.template.attribute.value"].browse(
variant_values
)
# Commented out from upstream. Preserved for posterity's sake.
#
# has_optional_products = product.optional_product_ids.filtered(
# lambda p: p._is_add_to_cart_possible(combination)
# )
#
# if not has_optional_products:
# return False

add_qty = int(kw.get("add_qty", 1))

no_variant_attribute_values = combination.filtered(
lambda attribute_value: attribute_value.attribute_id.create_variant
== "no_variant"
)
if no_variant_attribute_values:
product = product.with_context(
no_variant_attribute_values=no_variant_attribute_values
)

return request.env["ir.ui.view"]._render_template(
"sale_product_configurator.optional_products_modal",
{
"product": product,
"combination": combination,
"add_qty": add_qty,
"parent_name": product.name,
"variant_values": variant_values,
"pricelist": pricelist,
"handle_stock": handle_stock,
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
1 change: 1 addition & 0 deletions website_sale_add_to_cart_popup/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Rémy Taymans <remy@coopiteasy.bey>
7 changes: 7 additions & 0 deletions website_sale_add_to_cart_popup/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
With this module installed, the "Add to cart" popup is always shown when
clicking on add to cart button. Even if the product has no optional
product.

By default in Odoo, this popup is only shown when the product has
optional product configured correctly. Here the goal is to always show
this popup to let user pursue shopping after adding an item to cart.
4 changes: 4 additions & 0 deletions website_sale_add_to_cart_popup/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1. Install module
2. Go on the e-commerce and click on the "Add to cart" button. A popup
will appear with the ability to chose to "go to cart" or "continue
shopping".
Loading

0 comments on commit bbc01fe

Please sign in to comment.