Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

Steps to follow for reset the shopping cart in Odoo V8 Website.

By
Pascal Tremblay
on 7/3/15, 5:19 PM 1,715 views

Hello guys,

What is the trick to reset the cart? I would want a button in the cart to delete all lines in it.

Thanks to help..


11

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 7/4/15, 1:10 AM

Hi Pascal,

You can make your own custom module to manage reset the cart by following below steps...

Step 1. Inherit template of cart and make one .xml file.

<template id="clear_cart_button" inherit_id="website_sale.cart" customize_show="True" name="Clear Cart Button">
<xpath expr="//a[@href='/shop/checkout']" position="before">
    <a href="" id="clear_cart_button" class="btn btn-default mb32">&lt;span class="fa fa-trash-o"/> Clear Cart&lt;/a> 
</xpath>
</template>
<!-- This template is use to add .js file inside webiste. -->
<template id="assets_frontend" inherit_id="website.assets_frontend" name="Shop">
<xpath expr="." position="inside">
    <script type="text/javascript" src="/website_sale_clear_cart/static/src/js/website_sale_clear_cart.js"></script> 
</xpath>
</template>


Step 2. Make .js file inside /startic/src/js folder to make click event of the link.

$(document).ready(function () {
$('.oe_website_sale').each(function () {
var oe_website_sale = this;
$(oe_website_sale).on("click", ".oe_cart #clear_cart_button", function () {
openerp.jsonRpc("/shop/clear_cart", "call", {}).then(function(){
location.reload();
});
return false;
});
});
}); 


Step 3. Add controller inside .py file to manage request of clear cart.

class pos_website_sale(http.Controller):
    @http.route(['/shop/clear_cart'], type='json', auth="public", website=True)
    def clear_cart(self):
        order = request.website.sale_get_order()
        if order:
            for line in order.website_order_line:
                line.unlink()

That's it. It will add one functionality inside cart template for clear/remove all products from the selected cart.

I am sure that it is very useful for you.

Free App is out at Odoo Apps Store now. You can download  and use it.

Odoo Technical notes is published for this. You can view Technical Stpes to reset a shopping cart in Odoo 8 Website  and review it. 

Thanks for all. Very nice from you. I'm testing. For the moment, I have the button but it doesn't work.

Pascal Tremblay
on 7/4/15, 7:38 AM

Ok, it works well now! 1000 thanks for your quick answer.

Pascal Tremblay
on 7/4/15, 7:44 AM

@Emipro,
Thanks for the post! Do you have any suggestions on how this could be done by order line only? The use case is I want to add an 'x' or trash can icon to the order lines in my own module for a quick cart dropdown in the nav/header (already built), and in the shopping cart order lines.

I'm just wondering if there is an easy way to delete order lines given the method shown above or an alternative.

Luke Branch
on 7/8/15, 6:23 AM

@Luke I've did something similar. The view: https://github.com/Yenthe666/Dev/blob/master/aa_houbolak/templates.xml#L358 The JS: https://github.com/Yenthe666/Dev/blob/master/aa_houbolak/static/src/js/houbolak.js#L23-L32 This pretty much shows a delete icon and then deletes the specific line through XML-RPC. I hope this helps you :)

Yenthe
on 8/17/15, 9:36 AM
0
Niraj Pajwani
On 10/14/15, 6:51 AM

Thanks a lot.

Really its very helpful for me as well as other also.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 7/3/15, 5:19 PM
Seen: 1715 times
Last updated: 11/26/15, 9:27 AM