[Skip to main content](#vessel-content)

#   Detect when checkout is empty and redirect

##

- **[Mat](/forum/user/4216-mat "View Mat's Profile")**
- [![Mat's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4216-mat "View Mat's Profile") Topic Author
- [ Offline](/forum/user/4216-mat)

Less More

- Posts: 217
- Thank you received: 1
-
-

13 years 8 months ago [\#94469](#94469) by [Mat](/forum/user/4216-mat "View Mat's Profile")  *[Detect when checkout is empty and redirect](/forum/2-general-talk-about-hikashop/79287-detect-when-checkout-is-empty-and-redirect#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")* was created by *[Mat](/forum/user/4216-mat "View Mat's Profile")*

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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mjg3LWRldGVjdC13aGVuLWNoZWNrb3V0LWlzLWVtcHR5LWFuZC1yZWRpcmVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mat](/forum/user/4216-mat "View Mat's Profile")**
- [![Mat's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4216-mat "View Mat's Profile") Topic Author
- [ Offline](/forum/user/4216-mat)

Less More

- Posts: 217
- Thank you received: 1
-
-

13 years 8 months ago -  13 years 8 months ago [\#94470](#94470) by [Mat](/forum/user/4216-mat "View Mat's Profile")  Replied by *[Mat](/forum/user/4216-mat "View Mat's Profile")* on topic *[Detect when checkout is empty and redirect](/forum/2-general-talk-about-hikashop/79287-detect-when-checkout-is-empty-and-redirect#94470 "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")*

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: 13 years 8 months ago by [Mat](/forum/user/4216-mat "View Mat's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mjg3LWRldGVjdC13aGVuLWNoZWNrb3V0LWlzLWVtcHR5LWFuZC1yZWRpcmVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mat](/forum/user/4216-mat "View Mat's Profile")**
- [![Mat's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4216-mat "View Mat's Profile") Topic Author
- [ Offline](/forum/user/4216-mat)

Less More

- Posts: 217
- Thank you received: 1
-
-

13 years 8 months ago -  13 years 8 months ago [\#94473](#94473) by [Mat](/forum/user/4216-mat "View Mat's Profile")  Replied by *[Mat](/forum/user/4216-mat "View Mat's Profile")* on topic *[Detect when checkout is empty and redirect](/forum/2-general-talk-about-hikashop/79287-detect-when-checkout-is-empty-and-redirect#94473 "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")*

And I found this: [ www.hikashop.com/en/forum/4-how-to/17893...turn-page.html#17894](http://www.hikashop.com/en/forum/4-how-to/17893-empty-cart-return-page.html#17894)

I will edit the core hikashop file ![:(](/media/kunena/emoticons/22.png ":(")

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 ![:)](/media/kunena/emoticons/3.png ":)")

Last edit: 13 years 8 months ago by [Mat](/forum/user/4216-mat "View Mat's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mjg3LWRldGVjdC13aGVuLWNoZWNrb3V0LWlzLWVtcHR5LWFuZC1yZWRpcmVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mat](/forum/user/4216-mat "View Mat's Profile")**
- [![Mat's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4216-mat "View Mat's Profile") Topic Author
- [ Offline](/forum/user/4216-mat)

Less More

- Posts: 217
- Thank you received: 1
-
-

13 years 8 months ago [\#94476](#94476) by [Mat](/forum/user/4216-mat "View Mat's Profile")  Replied by *[Mat](/forum/user/4216-mat "View Mat's Profile")* on topic *[Detect when checkout is empty and redirect](/forum/2-general-talk-about-hikashop/79287-detect-when-checkout-is-empty-and-redirect#94476 "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")*

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mjg3LWRldGVjdC13aGVuLWNoZWNrb3V0LWlzLWVtcHR5LWFuZC1yZWRpcmVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

13 years 7 months ago [\#94523](#94523) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Detect when checkout is empty and redirect](/forum/2-general-talk-about-hikashop/79287-detect-when-checkout-is-empty-and-redirect#94523 "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")*

Hi,

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mjg3LWRldGVjdC13aGVuLWNoZWNrb3V0LWlzLWVtcHR5LWFuZC1yZWRpcmVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mat](/forum/user/4216-mat "View Mat's Profile")**
- [![Mat's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4216-mat "View Mat's Profile") Topic Author
- [ Offline](/forum/user/4216-mat)

Less More

- Posts: 217
- Thank you received: 1
-
-

13 years 7 months ago [\#94652](#94652) by [Mat](/forum/user/4216-mat "View Mat's Profile")  Replied by *[Mat](/forum/user/4216-mat "View Mat's Profile")* on topic *[Detect when checkout is empty and redirect](/forum/2-general-talk-about-hikashop/79287-detect-when-checkout-is-empty-and-redirect#94652 "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")*

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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mjg3LWRldGVjdC13aGVuLWNoZWNrb3V0LWlzLWVtcHR5LWFuZC1yZWRpcmVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

13 years 7 months ago [\#94675](#94675) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Detect when checkout is empty and redirect](/forum/2-general-talk-about-hikashop/79287-detect-when-checkout-is-empty-and-redirect#94675 "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")*

Hi,

You can maybe add the following line: Code:

&lt;?php $config = hikashop_config(); $config-&gt;set('redirect_url_when_cart_is_empty', urlencode(base64_encode(hikashop_currentURL('url',false)))); ?&gt;

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mjg3LWRldGVjdC13aGVuLWNoZWNrb3V0LWlzLWVtcHR5LWFuZC1yZWRpcmVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mat](/forum/user/4216-mat "View Mat's Profile")**
- [![Mat's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4216-mat "View Mat's Profile") Topic Author
- [ Offline](/forum/user/4216-mat)

Less More

- Posts: 217
- Thank you received: 1
-
-

13 years 7 months ago [\#95401](#95401) by [Mat](/forum/user/4216-mat "View Mat's Profile")  Replied by *[Mat](/forum/user/4216-mat "View Mat's Profile")* on topic *[Detect when checkout is empty and redirect](/forum/2-general-talk-about-hikashop/79287-detect-when-checkout-is-empty-and-redirect#95401 "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")*

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mjg3LWRldGVjdC13aGVuLWNoZWNrb3V0LWlzLWVtcHR5LWFuZC1yZWRpcmVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mat](/forum/user/4216-mat "View Mat's Profile")**
- [![Mat's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4216-mat "View Mat's Profile") Topic Author
- [ Offline](/forum/user/4216-mat)

Less More

- Posts: 217
- Thank you received: 1
-
-

13 years 7 months ago [\#95402](#95402) by [Mat](/forum/user/4216-mat "View Mat's Profile")  Replied by *[Mat](/forum/user/4216-mat "View Mat's Profile")* on topic *[Detect when checkout is empty and redirect](/forum/2-general-talk-about-hikashop/79287-detect-when-checkout-is-empty-and-redirect#95402 "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")*

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mjg3LWRldGVjdC13aGVuLWNoZWNrb3V0LWlzLWVtcHR5LWFuZC1yZWRpcmVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mat](/forum/user/4216-mat "View Mat's Profile")**
- [![Mat's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4216-mat "View Mat's Profile") Topic Author
- [ Offline](/forum/user/4216-mat)

Less More

- Posts: 217
- Thank you received: 1
-
-

13 years 7 months ago [\#95405](#95405) by [Mat](/forum/user/4216-mat "View Mat's Profile")  Replied by *[Mat](/forum/user/4216-mat "View Mat's Profile")* on topic *[Detect when checkout is empty and redirect](/forum/2-general-talk-about-hikashop/79287-detect-when-checkout-is-empty-and-redirect#95405 "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")*

Anyway it was simpler to modify the core files.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mjg3LWRldGVjdC13aGVuLWNoZWNrb3V0LWlzLWVtcHR5LWFuZC1yZWRpcmVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

13 years 7 months ago [\#95559](#95559) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Detect when checkout is empty and redirect](/forum/2-general-talk-about-hikashop/79287-detect-when-checkout-is-empty-and-redirect#95559 "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")*

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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzc5Mjg3LWRldGVjdC13aGVuLWNoZWNrb3V0LWlzLWVtcHR5LWFuZC1yZWRpcmVjdD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.082 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
