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