Skip Navigation

[Resolved] Using Conditional Logic with WooCommerce Product Category Thumbnail Field

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
- 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 2 replies, has 2 voices.

Last updated by Minesh 10 months, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2677192

I'm trying to run conditional logic in a taxonomy term view that displays WooCommerce Product Categories. My intended conditional logic is trying to display elements based on if the Product Category Thumbnail field ([wpv-woo-productcategory-images size='large']) is populated or not, and I can't seem to get favorable results.

This is what I've tried so far:

[wpv-conditional if="( '[wpv-woo-productcategory-images size='large']' ne '' )"]<img src="[...]" />[/wpv-conditional]
[wpv-conditional if="( NOT(empty($(_thumbnail_id))) )"]<img src="[...]" />[/wpv-conditional]

I even added the wpv-woo-productcategory-images string to the third-party shortcode arguments configuration, as well as selected the enable the "manage by types" option for the thumbnail_id field, but all attempts have resulted in nothing being displayed.

I searched for similar topics in your forums and was led to this page, https://toolset.com/documentation/legacy-features/views-plugin/checking-fields-and-other-elements-for-emptynon-empty-values, but nothing here seems to be helpful for my application.

This is the page in question: hidden link

Any help in this matter would be greatly appreciated, thanks!

Just a heads up, if you view the page link, I implemented a CSS solution that'll work for the time being, but I'd much rather prefer to use the conditional logic if I could.

#2677221

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Can you please share admin access details and let me check whats going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) 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.

#2677523

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

The issue was the conditionals were working fine but the div for which you assigned the class name "missing-store-img" the CSS attribute assigned to this class display:none; was the issue.

I've added the conditional as given under:

 [wpv-conditional if="( '[wpv-woo-productcategory-images size='thumbnail']' ne '' )"]
            <img src="[wpv-woo-productcategory-images size='large']" alt="[wpv-taxonomy-title] logo" />
        [/wpv-conditional]
        
        [wpv-conditional if="( '[wpv-woo-productcategory-images size='thumbnail']' eq '' )"]
            <div class="">
                <img src="/wp-content/uploads/2023/11/cropped-favicon.png" alt="[wpv-bloginfo] icon" />
            </div>
        [/wpv-conditional]

Can you please confirm it works as expected now.

#2677753

The display: none CSS was there as a potential fix if I couldn't get the conditional logic to work and wasn't in place when I was initially working on the conditional logic arguments. That said, your implementation appears to be working.

Not sure why it wasn't working before, perhaps it required the size attribute to equal to thumbnail? I dunno. Either way, thanks for your help anyway.