Display Custom Fields only if Values Equal to constant

  • Posts: 303
  • Thank you received: 18
  • Hikashop Business
6 years 8 months ago #275868

-- 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).

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

  • Posts: 26007
  • Thank you received: 4004
  • MODERATOR
6 years 8 months ago #275870

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,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 303
  • Thank you received: 18
  • Hikashop Business
6 years 8 months ago #275926

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.

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

  • Posts: 26007
  • Thank you received: 4004
  • MODERATOR
6 years 8 months ago #275930

Hello,

Because depending the context, the kind of custom field and the type of custom field ; our answer can be very different.

Kind of custom field : product custom field, item custom field, order custom field.
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.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 303
  • Thank you received: 18
  • Hikashop Business
6 years 8 months ago #276117

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:

    <?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.

  • Posts: 303
  • Thank you received: 18
  • Hikashop Business
6 years 8 months ago #276122

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.074 seconds
Powered by Kunena Forum