Skip to main content

automatically add product when landing on article?

More
15 years 3 months ago #18362 by Rickhavoc
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 or Create an account to join the conversation.

More
15 years 3 months ago #18382 by nicolas
Hi,

You should look at that thread: www.hikashop.com/en/support/forum/4-how-...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 or Create an account to join the conversation.

More
15 years 2 months ago - 15 years 2 months ago #21198 by Rickhavoc
Code:
$phone = $plan = false; foreach($this->rows as $i => $row){ if($row->type_of_product=='plan') $plan=true; if($row->type_of_product=='phone') $phone=true; } $app =& JFactory::getApplication(); if($phone && !$plan){ $app->redirect('http://www.iqcellular.com/index.php?option=com_content&view=article&id=18'); }elseif(!$phone && $plan){ } if($plan){ $app->redirect(hikashop::completeLink('product&task=updatecart&product_id=8&quantity=1&add=1&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.
Last edit: 15 years 2 months ago by Rickhavoc.

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

More
15 years 2 months ago #21210 by nicolas
the line:
$app->redirect(hikashop::completeLink('product&task=updatecart&product_id=8&quantity=1&add=1&return='.urlencode(base64_encode(hikashop::currentUrl()))));

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

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

More
15 years 2 months ago - 15 years 6 days ago #21268 by Rickhavoc
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->rows as $i => $row){ if($row->type_of_product=='plan') $plan=true; if($row->type_of_product=='phone') $phone=true; if($row->product_code=='One_time_Activation_Fee') $actfee=true; if($row->product_code=='no_plan') $noplan=true; } $app =& JFactory::getApplication(); if($phone && !$plan){ $app->redirect('http://www.*********.com/index.php?option=com_content&view=article&id=18'); }elseif(!$phone && $plan){} else{ } if(!$noplan){ if($plan && !$actfee){ $app->redirect('http://www.********.com/index.php?option=com_hikashop&ctrl=product&task=updatecart&quantity=1&checkout=1&product_id=8'); } elseif(!$plan && $actfee){ $app->redirect('http://www.**********.com/index.php?option=com_hikashop&ctrl=product&task=updatecart&quantity=0&checkout=1&product_id=8'); } }
Last edit: 15 years 6 days ago by Rickhavoc.

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

More
15 years 2 months ago #21289 by nicolas
It's the same in your case (when the code is run on the first step of the checkout).

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

More
15 years 2 months ago #21584 by Rickhavoc
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&ctrl=product&task=updatecart&quantity=1&checkout=1&product_id=7&url=aHR0cDovL3d3dy5pcWNlbGx1bGFyLmNvbS9pbmRleC5waHAvcGhvbmVzL2NhdGVnb3J5L2xpc3Rp%0d%0abmc%3d%0d%0a"

the link that was encode is www.iqcellular.com/index.php/phones/category/listing

Thanks.

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

More
15 years 2 months ago #21598 by nicolas
You need to remove the &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 &return_url= and not &url=

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

Time to create page: 0.189 seconds
Powered by Kunena Forum