Skip to main content

Empty Cart Button

More
15 years 5 months ago #14276 by momentis
Empty Cart Button was created by momentis
Is there a way to add a button into the cart view that will allow a user to clear all the contents of the cart with one click?

Please Log in or Create an account to join the conversation.

More
15 years 5 months ago #14277 by nicolas
Replied by nicolas on topic Re: Empty Cart Button
Sure:
<a href="<?php echo hikashop::completeLink('product&task=cleancart'); ?>">Empty Cart</a>

Please Log in or Create an account to join the conversation.

More
15 years 5 months ago #14278 by momentis
Replied by momentis on topic Re: Empty Cart Button
Thanks!!

Please Log in or Create an account to join the conversation.

More
15 years 5 months ago #14322 by momentis
Replied by momentis on topic Re: Empty Cart Button
Nicolas,

I inserted this in the front-end Checkout->Cart file. It adds the link and is certainly clearing the cart. However, when the page refreshes the cart items still show on that screen, but browsing to another page (where the cart module is displayed) shows an empty cart. Is there a way to have the cart itself refresh and clear?

Please Log in or Create an account to join the conversation.

More
15 years 5 months ago #14324 by nicolas
Replied by nicolas on topic Re: Empty Cart Button
In that case, you need to add a return parameter to the URL:
<a href="<?php echo hikashop::completeLink('product&task=cleancart&return_url='. urlencode(base64_encode(hikashop::currentURL('url')))); ?>">Empty Cart</a>

Please Log in or Create an account to join the conversation.

More
15 years 5 months ago #14325 by momentis
Replied by momentis on topic Re: Empty Cart Button
Man, you are truly amazing!! Thanks!!!

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #54343 by lanzanet
Replied by lanzanet on topic Re: Empty Cart Button
Hi. Where exatly may I put this code? I tried to put it in Views->Checkout->Cart ot the Frontend, but nothing happens. Could you help me please?

Thanks.

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #54370 by nicolas
Replied by nicolas on topic Re: Empty Cart Button
That view file is for the cart on the checkout. If you want the cart module, it should be the file "cart" of the view "product".
Also, make sure that you're doing it for your front end template and not another template.

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #54376 by lanzanet
Replied by lanzanet on topic Re: Empty Cart Button
Thanks Nicolas. Yes, It was for the checkout module. Now I have my 'Empty Cart' link, but Is there a way for that link to appears like a button (like the 'Checkout' button)?

Thanks.

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #54440 by nicolas
Replied by nicolas on topic Re: Empty Cart Button
Everything is possible. You could use that code instead for that:

<input name="Empty Cart" value="Empty Cart" onclick="window.location='<?php echo hikashop::completeLink('product&task=cleancart&return_url='. urlencode(base64_encode(hikashop::currentURL('url')))); ?>';return false;"/>

Please Log in or Create an account to join the conversation.

More
14 years 3 months ago #54469 by lanzanet
Replied by lanzanet on topic Re: Empty Cart Button
WOWWWW!! Amazing!

Really everything is possible. It works perfectly, but I needed to add:

type="submit" class="button" before the name var, so the code looks:

<input type="submit" class="button" name="Empty Cart" value="Empty Cart" onclick="window.location='<?php echo hikashop::completeLink('product&task=cleancart&return_url='. urlencode(base64_encode(hikashop::currentURL('url')))); ?>';return false;"/>

and it works exactly as I wanted.

I think it's the fastest and the best support for the price I've ever had for a software bought. I don't know how you manage to answer so many posts so fast.

Thanks again Nicolas.

Please Log in or Create an account to join the conversation.

More
12 years 7 months ago - 12 years 7 months ago #141464 by Flooder
Replied by Flooder on topic Re: Empty Cart Button
When I use this code in templates/../html/checkout/cart.php and I click the new link, I know that the cart is empty.
Code:
<a href="<?php echo hikashop::completeLink('product&task=cleancart&return_url='. urlencode(base64_encode(hikashop::currentURL('url')))); ?>">Empty Cart</a>

But I still see item in cart until I refresh another time...
Last edit: 12 years 7 months ago by Flooder.

Please Log in or Create an account to join the conversation.

More
12 years 7 months ago #141569 by Eliot
Replied by Eliot on topic Re: Empty Cart Button
Hi there,

You should try with hikashop_completeLink instead of hikashop::completeLink.
If if doesn't work, please give us a link to the page where we could test it.
The following user(s) said Thank You: Flooder

Please Log in or Create an account to join the conversation.

More
12 years 7 months ago #141695 by Flooder
Replied by Flooder on topic Re: Empty Cart Button
your account is created and you received a private message. Thks

Please Log in or Create an account to join the conversation.

More
12 years 7 months ago #141719 by Flooder
Replied by Flooder on topic Re: Empty Cart Button
This problem is solved for me with :
Code:
$lienredir = urlencode(base64_encode('index.php?option=com_hikashop&ctrl=checkout')); $url = 'index.php?option=com_hikashop&ctrl=product&task=cleancart&return_url='. $lienredir; ?> <a class="btn button" href="<?php echo $url; ?>">Vider le panier</a>

I think SEF was my problem. I disabled it, found the real links, and reactivated it.

Please Log in or Create an account to join the conversation.

More
12 years 7 months ago #141821 by Eliot
Replied by Eliot on topic Re: Empty Cart Button
I'm glad you fixed it, thanks for sharing your solution!

Please Log in or Create an account to join the conversation.

More
12 years 3 months ago #161191 by happiexy
Replied by happiexy on topic Re: Empty Cart Button
incase the above fails, as it did with mine, just delete from the database via a query. works best

:)


fFull-stack

Please Log in or Create an account to join the conversation.

More
3 years 4 months ago #351948 by loovanloon
Replied by loovanloon on topic Empty Cart Button
How would this code look if I want to return to a specifiek page after emptying the cart?
Code:
<a href="<?php echo hikashop::completeLink('product&task=cleancart'); ?>">

I would want to return to page: www.ev8.shop/#sp-main-body

Please Log in or Create an account to join the conversation.

More
3 years 4 months ago #351952 by nicolas
Replied by nicolas on topic Empty Cart Button
Hi,

You can change the line:
Code:
$lienredir = urlencode(base64_encode('index.php?option=com_hikashop&ctrl=checkout'));
to:
Code:
$lienredir = urlencode(base64_encode('https://www.ev8.shop/#sp-main-body'));
in the code posted above.

Please Log in or Create an account to join the conversation.

More
3 years 4 months ago - 3 years 4 months ago #351973 by loovanloon
Replied by loovanloon on topic Empty Cart Button

nicolas wrote: Hi,
[hr]
You can change the line:
$lienredir = urlencode(base64_encode('index.php?option=com_hikashop&ctrl=checkout'));
to:
$lienredir = urlencode(base64_encode(' www.ev8.shop/#sp-main-body '));

in the code posted above.

[hr]

Thank you. Can you help me just one step further? As I do not know how to do this. What I want is a custom button to empty the card, and then return to a specifiec page. I managed to empty the cart with this code:
Code:
<a class="btnbtn-rich" href="<?php echo hikashop::completeLink('product&amp;task=cleancart'); ?>">Start over</a>

But now I want an extra button somewhere else that brings the user back to ' www.ev8.shop/#sp-main-body ' after pressing the custom 'empty cart button".

I just do not understand how to integrate your suggested code into the code. Can you add the return url for me into:
Code:
<a class="btnbtn-rich" href="<?php echo hikashop::completeLink('product&amp;task=cleancart'); ?>">Start over</a>

Or suggest a tutorial where I can learn about it? I have googled but can't find any suitable.
Last edit: 3 years 4 months ago by loovanloon. Reason: clarifications and typo's

Please Log in or Create an account to join the conversation.

Time to create page: 0.333 seconds
Powered by Kunena Forum