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

#   Conditional Display of Custom Fields in Checkout

##

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

Less More

- Posts: 15
- Thank you received: 0
-
-

14 years 8 months ago [\#40593](#40593) by [ddmulro](/forum/user/1426-ddmulro "View ddmulro's Profile")  *[Conditional Display of Custom Fields in Checkout](/forum/2-general-talk-about-hikashop/40593-conditional-display-of-custom-fields-in-checkout#40593 "I run a site that does registrations and equipment orders for a sports club. As part of the checkout process additional information is requested for program registrations (emergency contact, etc)...")* was created by *[ddmulro](/forum/user/1426-ddmulro "View ddmulro's Profile")*

I run a site that does registrations and equipment orders for a sports club. As part of the checkout process additional information is requested for program registrations (emergency contact, etc) which is not desirable when ordering only equipment. I would like to be able to manipulate the display/input of custom fields in the checkout based on the contents of the cart. My expected approach is to modify the checkout/custom_fields.php view to select which fields are displayed based on the ordered products.

Is there a straightforward method for checking the contents of the cart within the checkout/custom_fields.php view so that the information can be used in conditional statements?

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

Less More

- Posts: 86293
- Thank you received: 14272
-
-

14 years 8 months ago [\#40771](#40771) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Conditional Display of Custom Fields in Checkout](/forum/2-general-talk-about-hikashop/40593-conditional-display-of-custom-fields-in-checkout#40771 "I run a site that does registrations and equipment orders for a sports club. As part of the checkout process additional information is requested for program registrations (emergency contact, etc)...")*

That's the correct approach.
The cart products should be available in the variable $this-&gt;rows

So you could have some foreach on it, like that:
$myproduct_in_the_cart=false;
foreach($this-&gt;rows as $row){
if($row-&gt;product_code =="myproduct"){
$myproduct_in_the_cart=true;
}
}

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

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

Less More

- Posts: 15
- Thank you received: 0
-
-

14 years 8 months ago [\#40805](#40805) by [ddmulro](/forum/user/1426-ddmulro "View ddmulro's Profile")  Replied by *[ddmulro](/forum/user/1426-ddmulro "View ddmulro's Profile")* on topic *[Re: Conditional Display of Custom Fields in Checkout](/forum/2-general-talk-about-hikashop/40593-conditional-display-of-custom-fields-in-checkout#40805 "I run a site that does registrations and equipment orders for a sports club. As part of the checkout process additional information is requested for program registrations (emergency contact, etc)...")*

Thanks very much for the reply.

I have tried the code in custom_fields.php, terms.php and cart.php. In the custom_fields.php and terms.php I get the following error:

"Warning: Invalid argument supplied for foreach() in /home/gohsa/public_html/dev/templates/go-hsa/html/com_hikashop/checkout/terms.php on line 23"

In cart.php the code works as desired. Any suggestions as to what else needs to be changed to provide access to the cart information in custom_fields.php and terms.php?

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

Less More

- Posts: 86293
- Thank you received: 14272
-
-

14 years 8 months ago [\#41009](#41009) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Conditional Display of Custom Fields in Checkout](/forum/2-general-talk-about-hikashop/40593-conditional-display-of-custom-fields-in-checkout#41009 "I run a site that does registrations and equipment orders for a sports club. As part of the checkout process additional information is requested for program registrations (emergency contact, etc)...")*

ah yes, that's because you're not displaying the views together like it is by default so the cart is not loaded by the system. You will have first to load the cart manually like that:
$cartClass = hikashop_get('class.cart');
$cart = $cartClass-&gt;loadFullCart(true);
$this-&gt;rows =&amp; $cart-&gt;products;

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

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

Less More

- Posts: 15
- Thank you received: 0
-
-

14 years 8 months ago [\#41336](#41336) by [ddmulro](/forum/user/1426-ddmulro "View ddmulro's Profile")  Replied by *[ddmulro](/forum/user/1426-ddmulro "View ddmulro's Profile")* on topic *[Re: Conditional Display of Custom Fields in Checkout](/forum/2-general-talk-about-hikashop/40593-conditional-display-of-custom-fields-in-checkout#41336 "I run a site that does registrations and equipment orders for a sports club. As part of the checkout process additional information is requested for program registrations (emergency contact, etc)...")*

That works. Thank you very much. ![:)](/media/kunena/emoticons/8.png ":)")

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

- **[Devine](/forum/user/2915-devine "View Devine's Profile")**
- [![Devine's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2915-devine "View Devine's Profile")
- [ Offline](/forum/user/2915-devine)

Less More

- Posts: 62
- Thank you received: 0
-
-

14 years 4 months ago [\#54856](#54856) by [Devine](/forum/user/2915-devine "View Devine's Profile")  Replied by *[Devine](/forum/user/2915-devine "View Devine's Profile")* on topic *[Re: Conditional Display of Custom Fields in Checkout](/forum/2-general-talk-about-hikashop/40593-conditional-display-of-custom-fields-in-checkout#54856 "I run a site that does registrations and equipment orders for a sports club. As part of the checkout process additional information is requested for program registrations (emergency contact, etc)...")*

I would like to do something similar except I would like to not just hide the fields but hide the entire step. My checkout has Fields as a single step. When I hide the fields I just end up with an empty step.

I'm guessing I need to edit the step.php file. How should I go about this and are there any other issues in just hiding a step?
For example if a field is required, do I need to handle this also?

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

Less More

- Posts: 86293
- Thank you received: 14272
-
-

14 years 4 months ago [\#54945](#54945) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Conditional Display of Custom Fields in Checkout](/forum/2-general-talk-about-hikashop/40593-conditional-display-of-custom-fields-in-checkout#54945 "I run a site that does registrations and equipment orders for a sports club. As part of the checkout process additional information is requested for program registrations (emergency contact, etc)...")*

Hi,

If you want to remove the whole fields step conditionally, the best will be to create a joomla system plugin which would include the hikashop helper, do your checks, load the config of HikaShop and set the "checkout" of the config based on the result of your checks.
If you remove the whole fields step directly like that, the system won't do any checks on the fields data during the checkout so even if they are required it won't bug you.
If you try to do it via the views like explained on that thread and that you have required fields, the checkout controller won't let you proceed to the next step and you will have to hack the controller. So I would recommend the joomla system plugin overriding the config setting.

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

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

[](#top)
