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

#   How to trigger add $10 from radio selection?part2

##

- **[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 [\#21057](#21057) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  *[How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21057 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")* was created by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")*

So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the code below to get what i am looking for.

$already = false;
foreach($this-&gt;rows as $i =&gt; $row){
if($row-&gt;product_code =='Transfer_Number_Fee') $already = true;
}
if($this-&gt;order-&gt;numberchoice){
if(!$already){
$app =&amp; JFactory::getApplication();
$app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=1&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}else{
if($already){
$app =&amp; JFactory::getApplication();
$app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=0&amp;add=1&amp;return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86561
- Thank you received: 14307
-
-

15 years 4 months ago [\#21064](#21064) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21064 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

You say that the custom field numberchoice can have the values of keepnumber or newnumber, so your if should reflect that.
Instead of:
if($this-&gt;order-&gt;numberchoice){

you should have:
if($this-&gt;order-&gt;numberchoice=='newnumber'){

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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 [\#21196](#21196) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21196 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

$already = false;
foreach($this-&gt;rows as $i =&gt; $row){
if($row-&gt;product_code =='Transfer_Number_Fee') $already = true;
}
if($this-&gt;order-&gt;numberchoice=='keepnumber'){
if(!$already){
$app =&amp; JFactory::getApplication();
$app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=1&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}else{
if($this-&gt;order-&gt;numberchoice=='newnumber'){
$app =&amp; JFactory::getApplication();
$app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=0&amp;add=1&amp;return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}
This is what i have now. it's not doing anything.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86561
- Thank you received: 14307
-
-

15 years 4 months ago [\#21208](#21208) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21208 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

That's not what I said. You should do like that:

$already = false;
foreach($this-&gt;rows as $i =&gt; $row){
if($row-&gt;product_code =='Transfer_Number_Fee') $already = true;
}
if($this-&gt;order-&gt;numberchoice=='newnumber'){
if(!$already){
$app =&amp; JFactory::getApplication();
$app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=1&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}else{
if($already){
$app =&amp; JFactory::getApplication();
$app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=0&amp;add=1&amp;return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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 [\#21271](#21271) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21271 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

Code:

$already = false; foreach($this-&gt;rows as $i =&gt; $row){ if($row-&gt;product_code =='Transfer_Number_Fee') $already = true; } if($this-&gt;order-&gt;numberchoice=='newnumber'){ if(!$already){ $app =&amp; JFactory::getApplication(); $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=1&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl())))); } }else{ if($already){ $app =&amp; JFactory::getApplication(); $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=0&amp;add=1&amp;return='.urlencode(base64_encode(hikashop::currentUrl())))); } }

i don't think this is going to give me the result i want. the code says if they select they want a new number and there isn't a transfer fee there it will add one. I want the transfer fee to come up when they select that they want to keep their number, so it would be 'keepnumber' instead of 'newnumber'. also based on the code you sent me wouldn't it get stuck in a loop? adding and removing the product? if the selection was left on 'newnumber'.

so over all what we want is that if the selection is 'keepnumber' to add the transfer fee to the cart, and if they select 'newnumber' it gets removed. That is why i thought this might work.
Code:

$already = false; foreach($this-&gt;rows as $i =&gt; $row){ if($row-&gt;product_code =='Transfer_Number_Fee') $already = true; } if($this-&gt;order-&gt;numberchoice=='keepnumber'){ if(!$already){ $app =&amp; JFactory::getApplication(); $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=1&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl())))); } }else{ if($this-&gt;order-&gt;numberchoice=='newnumber'){ $app =&amp; JFactory::getApplication(); $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=0&amp;add=1&amp;return='.urlencode(base64_encode(hikashop::currentUrl())))); }

it's not doing anything at the moment. just thought it might need some tweaking to make it work. also since this on the custom field part should i add the code there or in the cart view? also since it's in the custom fields part should we add the a check for the user selection like we had in the code for the custom fields?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86561
- Thank you received: 14307
-
-

15 years 4 months ago [\#21292](#21292) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21292 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

It might be because of your checkout workflow. If the cart and the field view are not on the same step, your code will either miss the $this-&gt;order (from the field view) or the $this-&gt;rows (from the cart view). Please make sure that you have both cart and field view on the same step and try again.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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 [\#21295](#21295) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21295 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

well i don't want to mess up the flow of the checkout. this is what it is now cart,login_address_terms,fields,shipping_payment,confirm_address_cart_status,end

your saying to change it to
cart_fields,login_address_terms,shipping_payment,confirm_address_cart_status,end

i don't want the fields to be under the cart. i would like them to be as they are now. what can i do to the code above to make it work like that.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86561
- Thank you received: 14307
-
-

15 years 4 months ago [\#21302](#21302) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21302 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

What you could do is to put that code in the cart view and add before it the code below:
$app =&amp; JFactory::getApplication();
$order = $app-&gt;getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null);
$fieldsClass = hikashop_get('class.field');
$this-&gt;order = $fieldsClass-&gt;getFields('frontcomp',$order,'order');
That will initialize the custom fields data on the cart view.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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 [\#21305](#21305) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21305 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

i think that might work since i got the cart view before the end for review. i will be using authorize.net as SIM when will the payment be processed in the checkout i assume at the step end? so that this gets added to the charge at the review step.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86561
- Thank you received: 14307
-
-

15 years 4 months ago [\#21314](#21314) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21314 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

Yes, that would be done on the review step before the confirmation of the order.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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 [\#21358](#21358) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21358 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

landing on the cart i get this.
Fatal error: Call to undefined function hikashop_get() in /home/iqcellul/public_html/templates/ja_anion/html/com_hikashop/checkout/cart.php on line 234

This is the whole code right now

$app =&amp; JFactory::getApplication();
$order = $app-&gt;getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null);
$fieldsClass = hikashop_get('class.field');
$this-&gt;order = $fieldsClass-&gt;getFields('frontcomp',$order,'order');

$already = false;
foreach($this-&gt;rows as $i =&gt; $row){
if($row-&gt;product_code =='Transfer_Number_Fee') $already = true;
}
if($this-&gt;order-&gt;numberchoice=='keepnumber'){
if(!$already){
$app =&amp; JFactory::getApplication();
$app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=1&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}else{
if($this-&gt;order-&gt;numberchoice=='newnumber'){
$app =&amp; JFactory::getApplication();
$app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=0&amp;add=1&amp;return='.urlencode(base64_encode(hikashop::currentUrl()))));
}
}

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86561
- Thank you received: 14307
-
-

15 years 4 months ago [\#21369](#21369) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21369 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

That's because you don't use the latest version. change the code hikashop_get with hikashop::get and it should work.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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 [\#21404](#21404) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21404 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

is that change across for all the code? will hikashop::completeLink be hikashop_completeLink in the new version?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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 [\#21408](#21408) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21408 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

this is what i have now to try to accomplish a product being added to the cart if a radio selection is selected from the order fields.

$app =&amp; JFactory::getApplication();
$order = $app-&gt;getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null);
$fieldsClass = hikashop::get('class.field');
$this-&gt;order = $fieldsClass-&gt;getFields('frontcomp',$order,'order');

$already = false;
foreach($this-&gt;rows as $i =&gt; $row){
if($row-&gt;product_code =='Transfer_Number_Fee') $already = true;
}
if($this-&gt;order-&gt;numberchoice=='keepnumber'){
if(!$already){
$app =&amp; JFactory::getApplication();
$app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=1&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl())),false,true));
}
}else{
if($this-&gt;order-&gt;numberchoice=='newnumber'){
$app =&amp; JFactory::getApplication();
$app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=0&amp;add=1&amp;return='.urlencode(base64_encode(hikashop::currentUrl())),false,true));
}
}

i tried it with and without the false,true

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86561
- Thank you received: 14307
-
-

15 years 4 months ago [\#21419](#21419) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21419 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

Yes, that change will be for all the hikashop:: code. However, we kept the backward compatibility so that you can continue to use hikashop:: in your customized views. We had to do that change in order to avoid the deprecated warnings from PHP 5.3 when the strict mode is activated.

That code seems correct. You should put some traces to make sure that the $already has the correct value before the if and that the $this-&gt;order variable contains the numberchoice custom field value.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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 3 months ago [\#21511](#21511) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21511 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

So it's down to the $app =&amp; JFactory::getApplication();
$order = $app-&gt;getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null);
$fieldsClass = hikashop::get('class.field');
$this-&gt;order = $fieldsClass-&gt;getFields('frontcomp',$order,'order');

cause i used firephp to echo the value of $this-&gt;order-&gt;numberchoice and in the cart view i get null , but in the fields view i get the correct value. so it's something to do with the code above and bring in the data from the order table.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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 3 months ago [\#21518](#21518) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21518 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

here i got it working like this Code:

$order = $app-&gt;getUserState(HIKASHOP_COMPONENT.'.checkout_fields',null); $fieldsClass = hikashop::get('class.field'); $this-&gt;order = $fieldsClass-&gt;getFields('frontcomp',$order,'order'); $already = false; $clean = false; foreach($this-&gt;rows as $i =&gt; $row){ if($row-&gt;product_code =='Transfer_Number_Fee') $already = true; } if(!$already &amp;&amp; $plan){ if($order-&gt;numberchoice=='keepnumber'){ $app =&amp; JFactory::getApplication(); $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=1&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl())),false,true)); } } elseif($order-&gt;numberchoice=='newnumber'){ if($already){ $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=0&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl())),false,true)); } } elseif($order-&gt;numberchoice=='keepnumber'){ if($already &amp;&amp; !$plan){ if(!$clean){ $clean = true; $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=0&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl())),false,true)); } } }else{}

now the problem is that when i click the last next it gives me a 505 error.
i removed Code:

$order = $app-&gt;getUserState( HIKASHOP_COMPONENT.'.checkout_fields',null); $fieldsClass = hikashop::get('class.field'); $this-&gt;order = $fieldsClass-&gt;getFields('frontcomp',$order,'order')

and i got it working so how do i undo the loading off all the extra fields before going to the next step.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86561
- Thank you received: 14307
-
-

15 years 3 months ago [\#21521](#21521) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21521 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

Try to remove just the two lines:
$fieldsClass = hikashop::get('class.field');
$this-&gt;order = $fieldsClass-&gt;getFields('frontcomp',$order,'order');

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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 3 months ago [\#21523](#21523) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  Replied by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21523 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

That worked. The issue now is on the payment view when you click next, which is suppose to go the the review page where it will where the cart view is again with the updated totals. it takes me back to step one of the cart. Code:

$order = $app-&gt;getUserState(HIKASHOP_COMPONENT.'.checkout_fields',null); $already = false; $clean = false; foreach($this-&gt;rows as $i =&gt; $row){ if($row-&gt;product_code =='Transfer_Number_Fee') $already = true; } if(!$already &amp;&amp; $plan){ if($order-&gt;numberchoice=='keepnumber'){ $app =&amp; JFactory::getApplication(); $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=1&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl())),false,true)); } } elseif($order-&gt;numberchoice=='newnumber'){ if($already){ $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=0&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl())),false,true)); } } elseif($order-&gt;numberchoice=='keepnumber'){ if($already &amp;&amp; !$plan){ if(!$clean){ $clean = true; $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=9&amp;quantity=0&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl())),false,true)); } } }else{}

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzIxMDU3LWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbi1wYXJ0Mj90bXBsPW1hcmtkb3du) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86561
- Thank you received: 14307
-
-

15 years 3 months ago [\#21533](#21533) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: How to trigger add $10 from radio selection?part2](/forum/4-how-to/21057-how-to-trigger-add-10-from-radio-selection-part2#21533 "So i now have a custom field name numberchoice which is a radio selection with the values of keepnumber or newnumber. i want something like this to happpen based on the selection. what can i do to the...")*

In your code, try to change &amp;return= by &amp;return_url=

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

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