Skip Navigation

[Resolved] if then statement

This support ticket is created 2 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by jelle-jacobd 2 years, 9 months ago.

Assisted by: Waqar.

Author
Posts
#2317625

Hi,

I need some help extending the if then statement from this ticket:
https://toolset.com/forums/topic/if-then-statement-product-attributes-on-custom-datasheet-page/page/2/

I need an extra check, so besides if not empty, I also need if not '-' I tried to add in manually but is doesn't work.

[wpv-conditional if="( '[wpv-post-taxonomy type="pa_zaagmaat" format="slug" item="$parent"]' ne '' )"]

F.e.

[wpv-conditional if="( '[wpv-post-taxonomy type="pa_zaagmaat" format="slug" item="$parent"]' ne '' ) AND ( '[wpv-post-taxonomy type="pa_zaagmaat" format="slug" item="$parent"]' ne '-' ) "]

But it doesn't seem to work?

Thanks, Jelle

#2317993

Hi Jelle,

Thank you for contacting us and I'd be happy to assist.

Based on the details shared in these two tickets, you'll need to replace the "AND" operator in the conditional statement, with the "OR" operator.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2318071

Hi Waqar,

Thanks, but this doesn't seem to work as well.

[wpv-conditional if="( '[wpv-post-taxonomy type="pa_zaagmaat" format="slug" item="$parent"]' ne '' ) OR ( '[wpv-post-taxonomy type="pa_zaagmaat" format="slug" item="$parent"]' ne '-' ) "]

Still returns a '-' sign for this attribute.
[wpv-conditional if="( '[wpv-post-taxonomy type="pa_zaagmaat" format="slug" item="$parent"]' ne '' ) OR ( '[wpv-post-taxonomy type="pa_zaagmaat" format="slug" item="$parent"]' ne '-' ) "]
<tr>
<th>Zaagmaat (in mm)</th>
<td>: [show-variation-attribute attribute="zaagmaat" variation_id="[wpv-search-term param="variation_id"]"]</td>
</tr>
[/wpv-conditional]

#2318471

Thanks for writing back.

Can you please share temporary admin login details, along with the link to the page where you need this conditional to work?

Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

#2320661

Thank you for sharing these details, but, I keep getting the message about the incorrect password.

Can you please check the username and password again?

I've set your next reply as private again and please also include a link to page(s) where these views can be seen.

#2322681

Thank you for waiting.

During troubleshooting, I noticed that the condition was failing, because "-" is returned, when the 'name' of the taxonomy is used, but in the conditional evaluation, the 'slug' is being called, which is not equal to "-":


[wpv-conditional if="( '[wpv-post-taxonomy type="pa_zaagmaat" format="slug"]' ne '' )"]
  <tr>
  <th>Zaagmaat (in mm)</th>
  <td>: [wpv-post-taxonomy type="pa_zaagmaat" format="name"]</td>
  </tr>
[/wpv-conditional]

You can update the condition to use the format="name" attribute, like this:


[wpv-conditional if="( '[wpv-post-taxonomy type="pa_zaagmaat" format="name"]' ne '' ) AND ( '[wpv-post-taxonomy type="pa_zaagmaat" format="name"]' ne '-' )"]
  <tr>
  <th>Zaagmaat (in mm)</th>
  <td>: [wpv-post-taxonomy type="pa_zaagmaat" format="name"]</td>
  </tr>
[/wpv-conditional]

#2323347

My issue is resolved now. Thank you!