Skip Navigation

[Resolved] double conditional in a view

This thread is resolved. Here is a description of the problem and solution.

Problem:

The conditional should be the following, but it doesn't work for me. Where am I failing?

Solution:

You can follow our document to setup the wpv-conditional shortcode, for example:

https://toolset.com/es/forums/topic/double-conditional-in-a-view/#post-1910165

Relevant Documentation:

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional

This support ticket is created 3 years, 10 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 11 replies, has 2 voices.

Last updated by avansisI-2 3 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#1902997

Hello! I have a question about whether you can put a double conditional.

In this case I need here:

<td> [type field = "expiration-date"] [/ types] <br> [wpv-conditional if = "($ (wpcf-expiration-date) lt 'TODAY ()')"] <b> EXPIRED </b> [/ wpv-conditional] </td> 

The expired is only shown if one of the forms in the rest of the columns is not complete like [cred_form form="adjunto-bonos"]
the complete code of the view is as follows. Could you help me?

<td>[types field='nombre_campana' separator=', ' item='@campana-bonos-bono.parent'][/types]</td>
<td>[types field="referencia-del-bono"][/types]</td>
<td>[types field="fecha-de-creacion-del-bono"][/types]</td>
<td>[types usermeta="telefono_movil" user_is_author="true"][/types]<br>[wpv-post-author format="meta" meta="user_email"]  </td>
<td>
[wpv-conditional if="( $(wpcf-comprobante) eq '' )"]
[cred_form form="adjunto-bonos"]
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-comprobante) ne '' )"]
[types field='comprobante'][/types]
[/wpv-conditional]</td>
<td>[wpv-view name="child-view"]</td>
 <td> [types field="fecha-de-caducidad"][/types]<br>[wpv-conditional if = "($(wpcf-fecha-de-caducidad) lt 'TODAY()')"] <b>CADUCADO</b> [/wpv-conditional]</td>
#1903531

Hello,

Please elaborate the questions with more details:

The expired is only shown if one of the forms in the rest of the columns is not complete like [cred_form form="adjunto-bonos"]

Are you going display something different after user submit the Toolset post form?
If it is, you can try the option:
After visitors submit this form: Display a message instead of the form...

#1904377
image-bonos.png

Hi Luo,

Expired date is in other column. Therefore it is not a consequence of sending the form 'adjunto-bonos'. But I want that if I submit this form, the word 'caducado' doesnt dispkay, even if 2 days have passed since the creation of the 'bono', which is currently when the word CADUCADO is included.

You can see view here.

/listado-bonos-administrador/

#1904715

Please provide your website credentials in below private message box, also point out the problem page URLs and form URLs, I need to test it in a live website, thanks

#1906069

Thanks for the details, I assume we are talking about this post form "Adjunto bonos":
hidden link

It is a post form for editing "Bonos" post.

For the question:
But I want that if I submit this form, the word 'caducado' doesnt dispkay

You can add another custom field(for example "my-field") into post form "Adjunto bonos", after user submit that form, change the custom field "my-field" value to something else.

Then use wpv-conditional shortcode to check "my-field" field value, display the text "caducado"

More help:
https://toolset.com/course-lesson/creating-custom-fields/
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional

#1908447

Hi Luo,

I'm trying to make it simpler, and just do it with a form.

If there is 'comprobante' remove the word 'caducado'

Could you help me?

#1908835

You can edit the post view "Listado bonos administrador":
hidden link
In section "Loop item in Listado bonos administrador", replace this code from:
[wpv-conditional if = "($(wpcf-fecha-de-caducidad) lt 'TODAY()') "] <b>CADUCADO</b> [/wpv-conditional]

With:
[wpv-conditional if = "($(wpcf-fecha-de-caducidad) lt 'TODAY()') OR ($(wpcf-comprobante) nq '') "] <b>CADUCADO</b> [/wpv-conditional]

#1908881

Hi Luo,
If I put that code 'Expired' it doesnt display in any case.

#1908887

That is because that you have already setup one condition:($(wpcf-fecha-de-caducidad) lt 'TODAY()')

Do you need it or not? If you don't need it, you can remove it, for example:
[wpv-conditional if = " ($(wpcf-comprobante) nq '') "] <b>CADUCADO</b> [/wpv-conditional]

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional

#1909041

Hi Luo,

The conditional should be the following, but it doesn't work for me. Where am I failing?

<td> [types field="fecha-de-caducidad"][/types]<br>[wpv-conditional if = "($(wpcf-fecha-de-caducidad) lt 'TODAY()')" AND "( $(wpcf-comprobante) eq '' )" ] <b>CADUCADO</b> [/wpv-conditional] </td>

#1910165

There is an extra double quotes in the codes you mentioned above.

I have changed the codes in your website as below:

[wpv-conditional if = "($(wpcf-fecha-de-caducidad) lt 'TODAY()')  AND ( $(wpcf-comprobante) eq '' ) "] <b>CADUCADO</b> [/wpv-conditional]

Please test it, check if it is fixed, thanks

#1910309

My issue is resolved now. Thank you!