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

#   automatically add product when landing on article?

##

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

Less More

- Posts: 156
- Thank you received: 0
-
-

15 years 5 months ago [\#18362](#18362) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  *[automatically add product when landing on article?](/forum/4-how-to/18362-automatically-add-product-when-landing-on-article#18362 "How can i Automatically add a product to the cart from a link without leaving the page it landed on?  What i am trying to do is Create a link that will take you to an article, but as soon as you get to that article there is a product added to the cart. I want them to be able to stay on that page.")* was created by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")*

How can i Automatically add a product to the cart from a link without leaving the page it landed on?

What i am trying to do is Create a link that will take you to an article, but as soon as you get to that article there is a product added to the cart. I want them to be able to stay on that page.

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

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14324
-
-

15 years 5 months ago [\#18382](#18382) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: automatically add product when landing on article?](/forum/4-how-to/18362-automatically-add-product-when-landing-on-article#18382 "How can i Automatically add a product to the cart from a link without leaving the page it landed on?  What i am trying to do is Create a link that will take you to an article, but as soon as you get to that article there is a product added to the cart. I want them to be able to stay on that page.")*

Hi,

You should look at that thread: [ www.hikashop.com/en/support/forum/4-how-...shopping-pop-up.html](http://www.hikashop.com/en/support/forum/4-how-to/16632-continue-shopping-pop-up.html)
It explains how the add to cart url can be tweaked to include a link where HikaShop will redirect once the product in the URL is added to the cart.

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

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

Less More

- Posts: 156
- Thank you received: 0
-
-

15 years 4 months ago -  15 years 4 months ago [\#21198](#21198) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: automatically add product when landing on article?](/forum/4-how-to/18362-automatically-add-product-when-landing-on-article#21198 "How can i Automatically add a product to the cart from a link without leaving the page it landed on?  What i am trying to do is Create a link that will take you to an article, but as soon as you get to that article there is a product added to the cart. I want them to be able to stay on that page.")*

Code:

$phone = $plan = false; foreach($this-&gt;rows as $i =&gt; $row){ if($row-&gt;type_of_product=='plan') $plan=true; if($row-&gt;type_of_product=='phone') $phone=true; } $app =&amp; JFactory::getApplication(); if($phone &amp;&amp; !$plan){ $app-&gt;redirect('http://www.iqcellular.com/index.php?option=com_content&amp;view=article&amp;id=18'); }elseif(!$phone &amp;&amp; $plan){ } if($plan){ $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=8&amp;quantity=1&amp;add=1&amp;return='.urlencode(base64_encode(hikashop::currentUrl())))); }

so i added the above code to the what i had working before the idea is that if plan is true to add product of the id 8 to the cart but it's now going through. what i am getting is this.  [ ![&#91;img](http://www.hikashop.com/media/kunena/attachments/legacy/images/Untitled_1-20110713.jpg) ](http://www.hikashop.com/media/kunena/attachments/legacy/images/Untitled_1-20110713.jpg "&#91;img")

- [ ![Untitled&#95;1-20110713.jpg](/forum/attachment/1444) ](/forum/attachment/1444 "...1-20110713.jpg") [ ](/forum/attachment/1444?download=1 "...1-20110713.jpg")

Last edit: 15 years 4 months ago by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile").

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

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14324
-
-

15 years 4 months ago [\#21210](#21210) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: automatically add product when landing on article?](/forum/4-how-to/18362-automatically-add-product-when-landing-on-article#21210 "How can i Automatically add a product to the cart from a link without leaving the page it landed on?  What i am trying to do is Create a link that will take you to an article, but as soon as you get to that article there is a product added to the cart. I want them to be able to stay on that page.")*

the line:
$app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=8&amp;quantity=1&amp;add=1&amp;return='.urlencode(base64_encode(hikashop::currentUrl()))));

should be:
$app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=8&amp;quantity=1&amp;add=1&amp;return='.urlencode(base64_encode(hikashop::currentUrl())),false,true));

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

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

Less More

- Posts: 156
- Thank you received: 0
-
-

15 years 4 months ago -  15 years 2 months ago [\#21268](#21268) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: automatically add product when landing on article?](/forum/4-how-to/18362-automatically-add-product-when-landing-on-article#21268 "How can i Automatically add a product to the cart from a link without leaving the page it landed on?  What i am trying to do is Create a link that will take you to an article, but as soon as you get to that article there is a product added to the cart. I want them to be able to stay on that page.")*

i got it working like this. there was more to it then what i thought. would it be better to use the base64 way or would it be just the same like this.
Code:

$phone = $actfee = $noplan = $plan = false; foreach($this-&gt;rows as $i =&gt; $row){ if($row-&gt;type_of_product=='plan') $plan=true; if($row-&gt;type_of_product=='phone') $phone=true; if($row-&gt;product_code=='One_time_Activation_Fee') $actfee=true; if($row-&gt;product_code=='no_plan') $noplan=true; } $app =&amp; JFactory::getApplication(); if($phone &amp;&amp; !$plan){ $app-&gt;redirect('http://www.*********.com/index.php?option=com_content&amp;view=article&amp;id=18'); }elseif(!$phone &amp;&amp; $plan){} else{ } if(!$noplan){ if($plan &amp;&amp; !$actfee){ $app-&gt;redirect('http://www.********.com/index.php?option=com_hikashop&amp;ctrl=product&amp;task=updatecart&amp;quantity=1&amp;checkout=1&amp;product_id=8'); } elseif(!$plan &amp;&amp; $actfee){ $app-&gt;redirect('http://www.**********.com/index.php?option=com_hikashop&amp;ctrl=product&amp;task=updatecart&amp;quantity=0&amp;checkout=1&amp;product_id=8'); } }

Last edit: 15 years 2 months ago by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile").

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

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14324
-
-

15 years 4 months ago [\#21289](#21289) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: automatically add product when landing on article?](/forum/4-how-to/18362-automatically-add-product-when-landing-on-article#21289 "How can i Automatically add a product to the cart from a link without leaving the page it landed on?  What i am trying to do is Create a link that will take you to an article, but as soon as you get to that article there is a product added to the cart. I want them to be able to stay on that page.")*

It's the same in your case (when the code is run on the first step of the checkout).

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

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

Less More

- Posts: 156
- Thank you received: 0
-
-

15 years 4 months ago [\#21584](#21584) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: automatically add product when landing on article?](/forum/4-how-to/18362-automatically-add-product-when-landing-on-article#21584 "How can i Automatically add a product to the cart from a link without leaving the page it landed on?  What i am trying to do is Create a link that will take you to an article, but as soon as you get to that article there is a product added to the cart. I want them to be able to stay on that page.")*

i need a product to be added to the cart then the link will take you to a menu item link.
i base64 encode the link first then urlencode it and the link is still taking me to the cart after adding to the cart.
the complete link is
"index.php?option=com_hikashop&amp;amp;ctrl=product&amp;amp;task=updatecart&amp;amp;quantity=1&amp;amp;checkout=1&amp;amp;product_id=7&amp;amp;url=aHR0cDovL3d3dy5pcWNlbGx1bGFyLmNvbS9pbmRleC5waHAvcGhvbmVzL2NhdGVnb3J5L2xpc3Rp%0d%0abmc%3d%0d%0a"

the link that was encode is [ www.iqcellular.com/index.php/phones/category/listing](http://www.iqcellular.com/index.php/phones/category/listing)

Thanks.

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

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14324
-
-

15 years 4 months ago [\#21598](#21598) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: automatically add product when landing on article?](/forum/4-how-to/18362-automatically-add-product-when-landing-on-article#21598 "How can i Automatically add a product to the cart from a link without leaving the page it landed on?  What i am trying to do is Create a link that will take you to an article, but as soon as you get to that article there is a product added to the cart. I want them to be able to stay on that page.")*

You need to remove the &amp;amp;checkout=1 from that URL, otherwise, it will force the system to redirect to the checkout and will ignore the return_url. Also, it should be &amp;amp;return_url= and not &amp;amp;url=

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE4MzYyLWF1dG9tYXRpY2FsbHktYWRkLXByb2R1Y3Qtd2hlbi1sYW5kaW5nLW9uLWFydGljbGU/dG1wbD1tYXJrZG93bg==) 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.083 seconds

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