Skip Navigation

[Résolu] Conditional output

This support ticket is created Il y a 1 an et 9 mois. 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 7 réponses, has 4 voix.

Last updated by Pat Il y a 1 an et 9 mois.

Assisted by: Minesh.

Auteur
Publications
#2381007

Pat

Hello,

I have a Views that's display some product info thanks to this :
[types field='type-d-evenement' item='[wpv-ordered-product-ids]'][/types]
I would like to make a condition based on the result of this line (for example, the result could be "Conférences")
Is there a way to do this?
I can use the custom field (type-d-evenement) in the condition, but does not know how to add the link with the WC shortcode [wpv-ordered-product-ids]

Regards
Pat

#2381155

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

What if you try to use the conditional statement, for example:

[wpv-conditional if="( '[types field='type-d-evenement' item='[wpv-ordered-product-ids]'][/types]' eq 'Conférences' )" ]
 
// display your content when condition is true
 
[/wpv-conditional]
#2381581

Pat

Hi Minesh,

Thanks for helping.
Unfortunately, this is not working (too much nested levels?)
Regards
Pat

#2382581

Shane
Supporter

Languages: Anglais (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pat,

Unfortunately Minesh is off sick today but should be back on Monday to continue assisting you with this one.

Thanks,
Shane

#2383927

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+00:00)

Sorry Pat, Minesh is still off.

Can you check what is output if you have the debug option for the condition turned on?

(If you are using a conditional block you can enable it in the settings; if you are using the wpv-conditional shortcode you can add the debug="true" attribute.)

#2384023

Pat

Hi Nigel,

Thanks for taking care.

Here is what I'm getting :
####################
wpv-conditional attributes
####################
Array
(
[if] => ( '' = 'Conférences' )
[debug] => true
)

####################
Debug information
####################
--------------------
Original expression: ( '' = 'Conférences' )
--------------------
After replacing 1 general variables and comparing strings: ( '' = 'Conférences' )
Comparing to Conférences

This is the same for all orders that are in the loop, which means the result of the [types field='type-d-evenement' item='[wpv-ordered-product-ids]'][/types] is always '' when it is integrated inside the condition but if I place the shortcode in the loop without condition, I'm getting the right result 'Conférences' for some of the orders !
Regards
Pat

#2384581

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

I would like to know where exactly you added the conditional shortcode, within view's loop or outside the views loop.

If you have added it within the view's loop, what if you try to use:

[wpv-conditional if="( '[types field='type-d-evenement'][/types]' eq 'Conférences' )" ]
  
// display your content when condition is true
  
[/wpv-conditional]

The thing is that shortcode [wpv-ordered-product-ids] will output the comma separated product IDs:
=> https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-555686

This shortcode outputs ordered product IDs in a comma-separated format. This shortcode should only be used inside a View, layout or a Content Template that displays WooCommerce orders. It can be used on a single WooCommerce order page or a WooCommerce orders listing page

When you use like the following format, the [wpv-ordered-product-ids] should return only one value without comma separated IDs as the item attribute will accept only one value.

[types field='type-d-evenement' item='[wpv-ordered-product-ids]'][/types]

if you want to compare the product id within the view's loop and view is set to query the product then the above statement should work but if you want to query by order product ids then you will have to create another view where we should the pass the [wpv-ordered-product-ids] shortcode as view's shortcode attribute and filter the view with those passed products only.

If you do not have any idea then you can share problem URL and access details and tell me what you want to display conditionally with what section and I'm happy to help.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2387875

Pat

Hi Minesh

Thanks for helping.
Regards
Pat

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.