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

#   How to trigger add $10 from radio selection?

##

- **[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 [\#17833](#17833) by [Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")  *[How to trigger add $10 from radio selection?](/forum/4-how-to/17833-how-to-trigger-add-10-from-radio-selection#17833 "How to trigger add $10 from radio selection?  I have a custom field &quot;radio&quot; in my check out page. i want to be able to add $10 to this if it's not null or false. would the simplest way be to just add some PHP code to a file somewhere to add $10 to the shopping cart?  i have most figured out but what code would i need to just add $10 extra if radio box was true on checkout page?")* was created by *[Rickhavoc](/forum/user/2766-rickhavoc "View Rickhavoc's Profile")*

How to trigger add $10 from radio selection?

I have a custom field "radio" in my check out page. i want to be able to add $10 to this if it's not null or false. would the simplest way be to just add some PHP code to a file somewhere to add $10 to the shopping cart?

i have most figured out but what code would i need to just add $10 extra if radio box was true on checkout page?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE3ODMzLWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbj90bXBsPW1hcmtkb3du) 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 5 months ago [\#17843](#17843) 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?](/forum/4-how-to/17833-how-to-trigger-add-10-from-radio-selection#17843 "How to trigger add $10 from radio selection?  I have a custom field &quot;radio&quot; in my check out page. i want to be able to add $10 to this if it's not null or false. would the simplest way be to just add some PHP code to a file somewhere to add $10 to the shopping cart?  i have most figured out but what code would i need to just add $10 extra if radio box was true on checkout page?")*

You would have to edit the file cart of the view checkout via the menu Display-&gt;Views.
There, you could add something like that: Code:

$already = false; foreach($this-&gt;rows as $i =&gt; $row){ if($row-&gt;product_code =='10_dollars_product') $already = true; } if($this-&gt;order-&gt;custom_field_column_name){ if(!$already){ $app =&amp; JFactory::getApplication(); $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=106&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=106&amp;quantity=0&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl())))); } }

supposing that the 10 dollars product has the id 106 and the product code 10_dollars_product and that your custom order field has the column name custom_field_column_name

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE3ODMzLWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbj90bXBsPW1hcmtkb3du) 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 5 months ago -  15 years 5 months ago [\#17856](#17856) 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?](/forum/4-how-to/17833-how-to-trigger-add-10-from-radio-selection#17856 "How to trigger add $10 from radio selection?  I have a custom field &quot;radio&quot; in my check out page. i want to be able to add $10 to this if it's not null or false. would the simplest way be to just add some PHP code to a file somewhere to add $10 to the shopping cart?  i have most figured out but what code would i need to just add $10 extra if radio box was true on checkout page?")*

Why then use of the if else? can you explain the code more if you can? i just want to understand for future resources.. thanks..

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE3ODMzLWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbj90bXBsPW1hcmtkb3du) 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 5 months ago [\#17869](#17869) 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?](/forum/4-how-to/17833-how-to-trigger-add-10-from-radio-selection#17869 "How to trigger add $10 from radio selection?  I have a custom field &quot;radio&quot; in my check out page. i want to be able to add $10 to this if it's not null or false. would the simplest way be to just add some PHP code to a file somewhere to add $10 to the shopping cart?  i have most figured out but what code would i need to just add $10 extra if radio box was true on checkout page?")*

As you can see, in the if, the redirect url has a quantity of 1, which means that it adds the product 106 to the cart.
In the else, it has a quantity of 0, which means that it removes the product 106 from the cart.
So if the user changes his mind and toggle several times your custom field of the table order, the $10 product will be added or removed based on the user's change.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE3ODMzLWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbj90bXBsPW1hcmtkb3du) 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 5 months ago [\#18893](#18893) 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?](/forum/4-how-to/17833-how-to-trigger-add-10-from-radio-selection#18893 "How to trigger add $10 from radio selection?  I have a custom field &quot;radio&quot; in my check out page. i want to be able to add $10 to this if it's not null or false. would the simplest way be to just add some PHP code to a file somewhere to add $10 to the shopping cart?  i have most figured out but what code would i need to just add $10 extra if radio box was true on checkout page?")*

i now have the radio selection in my field step of checkout do i add this code there instead?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE3ODMzLWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbj90bXBsPW1hcmtkb3du) 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 5 months ago [\#18895](#18895) 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?](/forum/4-how-to/17833-how-to-trigger-add-10-from-radio-selection#18895 "How to trigger add $10 from radio selection?  I have a custom field &quot;radio&quot; in my check out page. i want to be able to add $10 to this if it's not null or false. would the simplest way be to just add some PHP code to a file somewhere to add $10 to the shopping cart?  i have most figured out but what code would i need to just add $10 extra if radio box was true on checkout page?")*

Why instead ?
You need to add it yes but you need to keep the code of the custom fields... Otherwise, you won't see your custom fields...

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE3ODMzLWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbj90bXBsPW1hcmtkb3du) 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 5 months ago [\#19003](#19003) 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?](/forum/4-how-to/17833-how-to-trigger-add-10-from-radio-selection#19003 "How to trigger add $10 from radio selection?  I have a custom field &quot;radio&quot; in my check out page. i want to be able to add $10 to this if it's not null or false. would the simplest way be to just add some PHP code to a file somewhere to add $10 to the shopping cart?  i have most figured out but what code would i need to just add $10 extra if radio box was true on checkout page?")*

the Radio selection field is now in the fields step of check out, i will be putting the custom fields differently using the code you gave me on the other post about echoing each field separately.

so this code
Code:

$already = false; foreach($this-&gt;rows as $i =&gt; $row){ if($row-&gt;product_code =='10_dollars_product') $already = true; } if($this-&gt;order-&gt;custom_field_column_name){ if(!$already){ $app =&amp; JFactory::getApplication(); $app-&gt;redirect(hikashop::completeLink('product&amp;task=updatecart&amp;product_id=106&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=106&amp;quantity=0&amp;add=0&amp;return='.urlencode(base64_encode(hikashop::currentUrl())))); } }

do i add it to the view field of checkout? or which one?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE3ODMzLWhvdy10by10cmlnZ2VyLWFkZC0xMC1mcm9tLXJhZGlvLXNlbGVjdGlvbj90bXBsPW1hcmtkb3du) 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 5 months ago [\#19024](#19024) 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?](/forum/4-how-to/17833-how-to-trigger-add-10-from-radio-selection#19024 "How to trigger add $10 from radio selection?  I have a custom field &quot;radio&quot; in my check out page. i want to be able to add $10 to this if it's not null or false. would the simplest way be to just add some PHP code to a file somewhere to add $10 to the shopping cart?  i have most figured out but what code would i need to just add $10 extra if radio box was true on checkout page?")*

That code uses mainly the data of the products in the cart, so I would put it in the cart file of the view checkout.

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

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