Redirect to "My Cart" view instead of Checkout

  • Posts: 25
  • Thank you received: 2
1 week 2 days ago #366235

-- HikaShop version -- : 5.1.5
-- Joomla version -- : 5.2.3
-- PHP version -- : 8.1.31

Hello,

If I take the "Add to cart HTML link" provided in the product view, it gives me something like:
index.php?option=com_hikashop&ctrl=product&task=updatecart&quantity=1&cid=4&Itemid=128

Which, when inputted goes directly to the checkout view.

Instead, I would like to redirect to the Cart Display view, which is index.php?option=com_hikashop&view=cart&layout=show

How do I do this?

I tried combining everything into index.php?option=com_hikashop&view=cart&layout=show&ctrl=product&task=updatecart&quantity=1&cid=4&Itemid=128
But that just sent me to the checkout instead of the cart display.

thanks in advance.

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

  • Posts: 83486
  • Thank you received: 13507
  • MODERATOR
1 week 1 day ago #366238

Hi,

You can add a parameter "return_url" with the URL you want to use after the add to cart.
That parameter has to have the URL in base64 and urlencoded. And it needs to be the full URL.

For example, suppose that the HTML add to cart URL of your product is:

https://www.hikashop.com/index.php?option=com_hikashop&ctrl=product&task=updatecart&add=1&cid=1
(it's actually the URL to add HikaShop Essential to the cart on our website)
As on your website, this URL redirects to the checkout of our website.
Once you have something in your cart on our website, you can access the cart page with the URL:
https://www.hikashop.com/marketplace/cart/show.html
To get this URL in base64, you can use www.base64encode.org/ and you'll get:
aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL21hcmtldHBsYWNlL2NhcnQvc2hvdy5odG1s
Then, you want to urlencode it, with for example, www.urlencoder.org/
In this case, the base64 value will still be the same after the urlencode, but it might not be the case all the time.
Then, you can add the parameter to the URL:
https://www.hikashop.com/index.php?option=com_hikashop&ctrl=product&task=updatecart&add=1&cid=1&return_url=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL21hcmtldHBsYWNlL2NhcnQvc2hvdy5odG1s

The following user(s) said Thank You: brettv

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

  • Posts: 25
  • Thank you received: 2
1 week 1 day ago #366261

Just to be clear, I seem to be getting the same results with these two URLs. Is that normal?

The return_url parameter takes a BASE64 encoded URL

index.php?option=com_hikashop&ctrl=product&task=updatecart&data[1]=1&add=1&Itemid=672&return_url=cGFuaWVy

and the url parameter must be URL encoded (with slashes replaced by %2F)
index.php?option=com_hikashop&ctrl=product&task=updatecart&data[1]=1&add=1&Itemid=672&url=panier

Those two approaches are equivalent? Thanks.

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

  • Posts: 83486
  • Thank you received: 13507
  • MODERATOR
1 week 1 day ago #366263

Hi,

Yes, almost. On some Joomla websites, if you put a urlencoded URL in a URL, the routing system won't work properly and it will create erratic behaviors.
This was the case in the past with SH404SEF in some cases for example.
That's why we switched from the "url" parameter to the "return_url" parameter 10 years ago.
By using a base64 encoded URL with the return_url, you're sure you'll circumvent that kind of issues with the routing system and that's why I talked about the return_url parameter in my previous answer and didn't mention the "url" parameter.

So, if possible, I would still recommend going for the return_url parameter if you can. You'll potentially save yourself hours of complications years in the future.

The following user(s) said Thank You: brettv

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

Time to create page: 0.053 seconds
Powered by Kunena Forum