Detect when checkout is empty and redirect

  • Posts: 217
  • Thank you received: 1
11 years 8 months ago #94469

Hi all,

When they delete a product from the checkout if it is the last product I want them to go to a specific page.

How can I detect when they delete a product and if it is the last redirect rather than display the current empty checkout.

'The cart is empty' message gets displayed so which code triggers that and I might work in my redirect there?

Thanks,

Mat

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

  • Posts: 217
  • Thank you received: 1
11 years 8 months ago #94470

found it: checkout / cart.php

Ok what seems to be happening is the checkout then goes to a product/listings page when it is empty ... where do I control that?

Last edit: 11 years 8 months ago by Mat.

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

  • Posts: 217
  • Thank you received: 1
11 years 8 months ago #94473

And I found this: www.hikashop.com/en/forum/4-how-to/17893...turn-page.html#17894

I will edit the core hikashop file :(

Actually what I might do is set the redirect_url_when_cart_is_empty each time in my own code ... thoughts? Anyway I will see if I can do that :)

Last edit: 11 years 8 months ago by Mat.

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

  • Posts: 217
  • Thank you received: 1
11 years 8 months ago #94476

Oh lol everyone updates that variable using the idea that i had ... might have to edit the core hikashop ....

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

  • Posts: 13201
  • Thank you received: 2322
11 years 8 months ago #94523

Hi,

Just use the option "URL where to redirect when the cart is empty" in Config > Checkout don't work ?
Because it redirect the customer when the cart is empty, so last product removed.

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

  • Posts: 217
  • Thank you received: 1
11 years 8 months ago #94652

I want it to go back to the page that went to the check out when the last item is removed. This varies a lot.

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

  • Posts: 13201
  • Thank you received: 2322
11 years 8 months ago #94675

Hi,

You can maybe add the following line:

<?php $config = hikashop_config(); $config->set('redirect_url_when_cart_is_empty', urlencode(base64_encode(hikashop_currentURL('url',false)))); ?>

In the view "product / cart". This should set the return url dynamically. I don't tried it..

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

  • Posts: 217
  • Thank you received: 1
11 years 8 months ago #95401

Hi Xavier - that would work per user and not actually update the config table right? Thanks, Mat

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

  • Posts: 217
  • Thank you received: 1
11 years 8 months ago #95402

and what does this function do : hikashop_currentURL('url',false)?

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

  • Posts: 217
  • Thank you received: 1
11 years 8 months ago #95405

Anyway it was simpler to modify the core files.

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

  • Posts: 13201
  • Thank you received: 2322
11 years 8 months ago #95559

Hi,

The code given is per user, and don't change anything in config.
The hikashop_currentURL() function take the current page url.

So, because the code is in the produt page, the redirect url when empty will be this page.
The customer will not move out this page when emptying the cart.

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

Time to create page: 0.082 seconds
Powered by Kunena Forum