Developer forum

Forum » Development » empty cart

Reply

When a enter the product page I whant the cart to be empty.

The problem I'm facing is if the user aborts the order the product still layes in the cart and when they enter the shop the next time and add the product again it will be two products. How can I clear the cart when they enter the shop the next time?

 


Replies

 
Reply
paul wrote:

When a enter the product page I whant the cart to be empty.

The problem I'm facing is if the user aborts the order the product still layes in the cart and when they enter the shop the next time and add the product again it will be two products. How can I clear the cart when they enter the shop the next time?

 


 

In the eCommerce setup you can state how long you want the cart to be valid for.  In admin click Control Panel > Modules > (Ecom) General

 
Reply
david@asphuset.no wrote:
paul wrote:

When a enter the product page I whant the cart to be empty.

The problem I'm facing is if the user aborts the order the product still layes in the cart and when they enter the shop the next time and add the product again it will be two products. How can I clear the cart when they enter the shop the next time?

 


 

In the eCommerce setup you can state how long you want the cart to be valid for.  In admin click Control Panel > Modules > (Ecom) General


 

I have allready tryed setting this value to 0 but the cart is not empty.

I gues the minimum is one day but I need it to be empty when they enter the shop again after a leaving the cart and without finishing the order.

 
Reply
paul wrote:
david@asphuset.no wrote:
paul wrote:

When a enter the product page I whant the cart to be empty.

The problem I'm facing is if the user aborts the order the product still layes in the cart and when they enter the shop the next time and add the product again it will be two products. How can I clear the cart when they enter the shop the next time?

 


 

In the eCommerce setup you can state how long you want the cart to be valid for.  In admin click Control Panel > Modules > (Ecom) General


 

I have allready tryed setting this value to 0 but the cart is not empty.

I gues the minimum is one day but I need it to be empty when they enter the shop again after a leaving the cart and without finishing the order.


 

If you need to empty the cart on certain pages, you can use the CartCommand 'emptycart' (by calling an url with the parameter cartcmd=emptycart). You can do this by javascript.

 
Reply

 

If you need to empty the cart on certain pages, you can use the CartCommand 'emptycart' (by calling an url with the parameter cartcmd=emptycart). You can do this by javascript.

Hello,

 

I have the same problem! I have also tried to set the cart to 0 and 1 day. How can I call Cartcmd=emptycart with javascript?

 

Thanks

 
Reply
jl@rc-media.dk wrote:

 

If you need to empty the cart on certain pages, you can use the CartCommand 'emptycart' (by calling an url with the parameter cartcmd=emptycart). You can do this by javascript.

Hello,

 

I have the same problem! I have also tried to set the cart to 0 and 1 day. How can I call Cartcmd=emptycart with javascript?

 

Thanks


 

There are a few ways of doing it, but the easiest would probably be to set the 'location.href' property. The code would look something like this:

 

<script type="text/javascript" language="javascript">
location.href = location.href + "&cartcmd=emptycart";
</script>

 

 

You would also need to check for whether you already did the redirect so you don't get infinite redirects.

 

You must be logged in to post in the forum