This question has been flagged
5 Replies
12679 Views

Dear all,

I am trying to use the Odoo 12 E-commerce function as an online catalog so I would like to disable "Add to Cart" button while I cannot disable it in product page.

I tried to delete the line:
<a role="button" id="add_to_cart" class="btn btn-primary btn-lg mt8 js_check_product a-submit" href="#">Add to Cart</a>
 in XML Product, but it does not allow me to save, which showing this error: 

A server error occured. Please check you correctly signed in and that the file you are saving is correctly formatted.
[object Object] 

There are some modules for older versions but I cannot use them in version 12.

Thanks in advance.

Avatar
Discard
Best Answer

Hello,

You can disable the "Add to Cart" button in E-commerce product page in Odoo 12V easily.

To configure it from frontend follow the following steps:

  1. Go to the Odoo Website Product Page then click on HTML/CSS Editor under the Customize Tab.
  2. You need to remove or comment the following HTML/CSS Code

<a id="add_to_cart" class="btn btn-primary btn-lg mt8 js_check_product a-submit" href="#">Add to Cart</a>

For more information refer to the screenshot,

You can also disable it from Odoo Backend; you need to follow the below-mentioned steps:

  1. Open the Odoo and click on the Settings menu. Here, click on Activate the Developer Mode. Even, one can also activate the developer mode by typing ‘debug=1’ after ‘web?’ in the URL.
  2. Go to the 'Views' menu under 'Technical settings'
  3. Now, search for the 'Product'. It is a QWeb template for the product page in website_sale module. For more information refer screenshot-2,
  4. Open the product template and comment or remove the same line mentioned above (<a id="add_to_cart" class="btn btn-primary btn-lg mt8 js_check_product a-submit" href="#">Add to Cart</a>)

Please Note: The Add to Cart will be disabled only till you do not update the Website Module.

If you want to make the changes permanently then you have to do the same changes in website_sale Module.

If you have any issues/queries then, please https://webkul.uvdesk.com/en/customer/create-ticket/

For any doubt contact us at support@webkul.com 

https://prnt.sc/qgfufx

https://prnt.sc/qgfz7u 

Avatar
Discard
Best Answer

@Ed can you please share the exact language you used please? im a beginner and im trying to do the same for my website. I would also like to eliminate showing the price, could you help me?

Avatar
Discard
Best Answer


add below code to your module :


    
   


user_id.partner_id.name == 'Public user'" id="add_to_cart" class="btn btn-primary btn-lg mt16 js_check_product a-submit d-block d-sm-inline-block" href="#">Add to Cart


Avatar
Discard
Best Answer

Hi Ed:

You can add a hidden attribute to the <a> tag like so to hide the button:

<a role="button" id="add_to_cart" class="btn btn-primary btn-lg mt8 js_check_product a-submit" hidden href="#">Add to Cart</a>

However, the way you are trying to do it is not the recommended way. You can lose your changes during an update if you do it this way. Odoo has a set of customization guidelines that need to be followed for enhancing the core functionality of the system. For example, in this case, you need to use View Inheritance to add the hidden attribute to the <a> tag. The following link explains the concepts involved:

View inheritance

Avatar
Discard
Author Best Answer

Hi Paresh,

Thank you very much for your help. I added  style="visibility:hidden;" in the <a> tag and the Add to Cart button is now hidden. I will look into the View inheritance later.

Best regards,
Ed

Avatar
Discard