- Posts: 48
- Thank you received: 5
Redirect to "My Cart" view instead of Checkout
1 year 6 months ago #366235
by brettv
Redirect to "My Cart" view instead of Checkout was created by brettv
-- 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.
-- 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.
1 year 6 months ago #366238
by nicolas
Replied by nicolas on topic Redirect to "My Cart" view instead of Checkout
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:
(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:
To get this URL in base64, you can use
www.base64encode.org/
and you'll get:
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:
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:
Code:
https://www.hikashop.com/index.php?option=com_hikashop&ctrl=product&task=updatecart&add=1&cid=1
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:
Code:
https://www.hikashop.com/marketplace/cart/show.html
Code:
aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL21hcmtldHBsYWNlL2NhcnQvc2hvdy5odG1s
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:
Code:
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.
1 year 6 months ago #366261
by brettv
Replied by brettv on topic Redirect to "My Cart" view instead of Checkout
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
and the url parameter must be URL encoded (with slashes replaced by %2F)
Those two approaches are equivalent? Thanks.
The return_url parameter takes a BASE64 encoded URL
Code:
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)
Code:
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.
1 year 6 months ago #366263
by nicolas
Replied by nicolas on topic Redirect to "My Cart" view instead of Checkout
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.
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.182 seconds