- Posts: 165
- Thank you received: 3
Url where you will be redirected when cart is empty no longer working
- jschroeder
-
Topic Author
- Offline
-- Joomla version -- : 3.7.3
-- PHP version -- : 7.0.21
Hi, the URL where you will be redirected when the cart is empty is no longer working when using the new ajax checkout and version 3.1.1. I have this setting set to redirect to a certain url buy-now.html after the cart is empty, but instead since it is using ajax it just empties the cart, but never actually redirects to the url I have set. Instead it leaves you in the cart and shows you a total of zero. Also, I deleted out all of my layout overrides just to check and it still does this so this has to be some sort of bug.
The redirect does however work if after I empty the cart and i manually refresh my browser page. It appears the ajax is just not calling the redirect after deleting the product out. How do I fix this?
Also, attached is my back end settings and what it looks like on the front end instead of redirecting you out of the cart to the buy-now.html like it should.
Thanks,
Josh
Please Log in or Create an account to join the conversation.
I'm afraid that you do have some customization in your website.
pasteboard.co/GCsUGqL.png
When the checkout cart is refreshed in ajax, HikaShop can add a JS trigger in order to indicate that the cart is empty and that the customer need to be redirected.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
Again how do I get it to redirect? There has to be some sort of bug here because it is not redirecting after the cart is emptied.
Thanks,
Josh
Please Log in or Create an account to join the conversation.
In the "cart / show" you will find that code :
It's a JS event that you can get from the checkout modules.
When the checkout cart block is updated, it check if the cart is now empty:
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
I am on version 3.1.1 and the piece of code you are mentioning does not exist in the cart/show file. I just looked it up in fact I am not seeing any of the code you listed above. This is all the javascript that is in the cart /show.php fileJerome wrote: Hello,
In the "cart / show" you will find that code :Code:window.Oby.registerAjax("cart.empty",function(params){ setTimeout(function(){ window.location.reload(); },150); });
Please Log in or Create an account to join the conversation.
I made a typo by typing too fast ; it's the "checkout / show" view..
But anyway, you need to be sure that you're using the latest packages.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
Jerome wrote: Hello,
I made a typo by typing too fast ; it's the "checkout / show" view..
But anyway, you need to be sure that you're using the latest packages.
Regards,
I am using the latest package. I removed my overrides again and I just downloaded the latest package and uploaded the latest show.php file and it still does not work. Still, when you empty the cart it just empties the cart and says total 0 and never redirects. As I said this has to be some sort of bug. How, do I fix this?
Thanks,
Josh
Please Log in or Create an account to join the conversation.
Well, now in you page source code I can find the line
So I can't provide any kind of guarantee that the system is really clean and that the cart is not modified by a third party plugin.
All I can tell you is to try to replace in the file "administrator/component/com_hikashop/helpers/checkout/cart.php" the line
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
Thanks,
Josh
Please Log in or Create an account to join the conversation.
I wanted to look at the problem again but I can't access your checkout:
monosnap.com/file/epE6Tn7UM1A4gSY14oCxVQrA0oC3Xz
To wrap up the situation, the issue is that the controller handling the update of the cart when you delete the last product is supposed to add the trigger cart.empty to the list of triggers that are sent back to the javascript of the browser so that it knows that the cart is empty and that the redirect should happen.
Since that trigger is not sent, it means that the system doesn't see the cart as empty after deleting the last product.
Jerome and I were thinking that it might be linked to the fact that the product is a variant.
Do you have the same problem with products that aren't variants ?
Also, could you try also changing the code:
Finally, we're not able to reproduce the issue on our end and no one else reported an issue with the redirect when empty with the new checkout since we've properly handled it months ago. So I would also be inclined in thinking that it comes from either custom code, a custom plugin, or you're using an old build of the 3.1.1 and you don't have all the latest patches.
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
I the mean time I am going to also do a default hikashop install on a site with no modifications and just configure the cart settings the same way as this cart and see if the issue still occurs I will report back to you what I find. If the issue still occurs I will just give you ftp access to the site and a login.
Thanks,
Josh
Please Log in or Create an account to join the conversation.
Yes that would greatly help if you could setup a test website so that we can look at the issue more in depth there.
Also, do you have the problem with products that don't have variants ?
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
Thanks,
Josh
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
However, if I take a fresh install of joomla and transfer the hikashop 3.1.1 database from the site that I am talking about above that does not work and then install a fresh copy of the newest version of 3.1.1 then it the refreshing of the checkout works as it should.
The only thing that is different is on the fresh install we are starting directly from version 3.1.1 and on the existing site this has been upgraded from previous 2.x.x versions and I cannot help but wonder if some files have gotten corrupted some how. That is really the only thing I can think of I sent you the log in credentials for the joomla site and the ftp. I am at a loss I don't know what else to do.
Also, it is not a problem with only variants it is with any product that goes into the cart.
Please Log in or Create an account to join the conversation.
I'm not able to access your link. When I go to the buy now page on your new test website, I get this:
monosnap.com/file/XEMJO21azTAvK5fJeBiLyZ4H4f9whv
So I couldn't look into it.
Could you check on that problem ?
There is no such error or column name in HikaShop so I suppose that it must come from something else.
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
Please Log in or Create an account to join the conversation.
When I tested this time from home I didn't get the issue.
Maybe there was indeed a problem with the firewall.
However, for some reason, on that test website, I'm not getting the same products as on the other one you had provided before. And the only one I see is "50 Ride-Thru Exterior Wash Tickets". If I try to add it to the cart, it doesn't do anything because of some error s in the customizations which breaks the add to cart button. I had to turn off the debug mode of the configuration to be able to get it to work.
But I was finally able to test and debug. The issue is indeed with customization, but not of the views. It comes from the customization of the translations.
You have set the "CART_EMPTY" message to an empty string. But the new checkout bases itself on the error message being empty or not to know if it needs to redirect.
Had you used instead
That's why we couldn't reproduce and you couldn't either on your tests with a clean HikaShop as you didn't had the overrides on the translations.
So I've changed the line:
if(!empty($checkoutHelper->redirectBeforeDisplay)) {
to:
if(!is_null($checkoutHelper->redirectBeforeDisplay)) {
in the file components/com_hikashop/controllers/checkout.php
That way, it now works even with an empty string for the cart empty message.
We'll add that patch on our end.
Please Log in or Create an account to join the conversation.
- jschroeder
-
Topic Author
- Offline
- Posts: 165
- Thank you received: 3
Thanks,
Josh
Please Log in or Create an account to join the conversation.
The patch will be integrated into HikaShop 3.2.0 which should be release during this month.
For the moment you can follow the Nicolas' instructions to fix that in your side.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.