- Posts: 303
- Thank you received: 18
Display Custom Fields only if Values Equal to constant
- mojooutdoors-holden
-
Topic Author
- Offline
Less
More
9 years 1 month ago #275868
by mojooutdoors-holden
-- Joomla version -- : 3.6.3
How can i only show/hide a custom field if
custom_field == VALUE ??
Should be a simple thing to do in php, but i cannot get it to work with custom fields. I have several custom fields, but i don't need them displayed for all categories. Additionally, i have a custom field for UNAVAILABLE that should display on some pages instead of out of stock (mainly for new, unreleased products).
How can i only show/hide a custom field if
custom_field == VALUE ??
Should be a simple thing to do in php, but i cannot get it to work with custom fields. I have several custom fields, but i don't need them displayed for all categories. Additionally, i have a custom field for UNAVAILABLE that should display on some pages instead of out of stock (mainly for new, unreleased products).
Please Log in or Create an account to join the conversation.
9 years 1 month ago #275870
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Display Custom Fields only if Values Equal to constant
Hello,
Please indicate the HikaShop version number you're using.
If you can also provide more details about the custom field, it would help. Because depending the context, the kind of custom field and the type of custom field ; our answer can be very different.
Regards,
Please indicate the HikaShop version number you're using.
If you can also provide more details about the custom field, it would help. Because depending the context, the kind of custom field and the type of custom field ; our answer can be very different.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- mojooutdoors-holden
-
Topic Author
- Offline
Less
More
- Posts: 303
- Thank you received: 18
9 years 1 month ago #275926
by mojooutdoors-holden
Replied by mojooutdoors-holden on topic Display Custom Fields only if Values Equal to constant
Sorry about that. I forgot to enter the version. Version currently installed is 2.6.4
The custom field will be a text field. If the product has the custom field == UNAVAILABLE, i would like to hide the add to cart block and just show the custom field value.
The custom field will be a text field. If the product has the custom field == UNAVAILABLE, i would like to hide the add to cart block and just show the custom field value.
Please Log in or Create an account to join the conversation.
9 years 1 month ago #275930
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Display Custom Fields only if Values Equal to constant
Hello,
Type of custom field : text, calendar, radio, dropdown...
Context : product page, product listing, checkout, etc.
Now regarding your request, I recommend you to change the product quantity to "0" instead of hiding or showing the "add to cart" because it would still be possible to add the product in the cart.
Afterwards, if you want to perform a view override I recommend you that documentation page :
www.hikashop.com/support/documentation/1...-display.html#layout
And I would also recommend you the setting "display view files" but it's only available since HikaShop 3.1
It's a very useful feature when it comes to customization because it display the view names directly in the page ; so you can easily know which view you want to customize.
www.hikashop.com/support/documentation/5...g.html#advanced_main
Regards,
Kind of custom field : product custom field, item custom field, order custom field.Because depending the context, the kind of custom field and the type of custom field ; our answer can be very different.
Type of custom field : text, calendar, radio, dropdown...
Context : product page, product listing, checkout, etc.
Now regarding your request, I recommend you to change the product quantity to "0" instead of hiding or showing the "add to cart" because it would still be possible to add the product in the cart.
Afterwards, if you want to perform a view override I recommend you that documentation page :
www.hikashop.com/support/documentation/1...-display.html#layout
And I would also recommend you the setting "display view files" but it's only available since HikaShop 3.1
It's a very useful feature when it comes to customization because it display the view names directly in the page ; so you can easily know which view you want to customize.
www.hikashop.com/support/documentation/5...g.html#advanced_main
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
- mojooutdoors-holden
-
Topic Author
- Offline
Less
More
- Posts: 303
- Thank you received: 18
9 years 1 month ago #276117
by mojooutdoors-holden
Replied by mojooutdoors-holden on topic Display Custom Fields only if Values Equal to constant
Hi Jerome,
I figured out how to get it done by looking at other "if" statements throughout the view files of hikashop.
I can now hide certain elements for certain products/categories as well as if certain custom fields are equal to certain values.
The original request was to hide certain elements if the custom field (text string) was equal to a certain value. For example, if availability was set to "COMING SOON" and i wanted to hide the "out of stock" string for every case where availability = "COMING SOON" then I would just use:
Hopefully that makes sense. Again, it's working now. I'm able to make complex pages with these custom fields. By far the best thing you guys have added to hikashop in my opinion!
I figured out how to get it done by looking at other "if" statements throughout the view files of hikashop.
I can now hide certain elements for certain products/categories as well as if certain custom fields are equal to certain values.
The original request was to hide certain elements if the custom field (text string) was equal to a certain value. For example, if availability was set to "COMING SOON" and i wanted to hide the "out of stock" string for every case where availability = "COMING SOON" then I would just use:
Code:
<?php if ($this->row->availability == 'COMING SOON') { ?>
<div style="display:none"> "OUT OF STOCK NOTIFICATION BLOCK"
</div>
<?php } else{ ?>
"DISPLAY OUT OF STOCK NOTIFICATION BLOCK"
<?php } ?>
Hopefully that makes sense. Again, it's working now. I'm able to make complex pages with these custom fields. By far the best thing you guys have added to hikashop in my opinion!
Please Log in or Create an account to join the conversation.
- mojooutdoors-holden
-
Topic Author
- Offline
Less
More
- Posts: 303
- Thank you received: 18
9 years 1 month ago #276122
by mojooutdoors-holden
Replied by mojooutdoors-holden on topic Display Custom Fields only if Values Equal to constant
Also, another easy fix to this problem would be to just set date available range to something in the future, then product will not show add to cart and instead show available on XXX DATE XXX
Please Log in or Create an account to join the conversation.
Time to create page: 0.221 seconds