Skip Navigation

[Resolved] Help showing conditional date logic if event is TODAY() – Time creates conflicts

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 28 replies, has 1 voice.

Last updated by benS-19 23 hours, 13 minutes ago.

Assisted by: Minesh.

Author
Posts
#2866070

I've never had that prompt, I just add a "Shortcode block" (as seen in previous screenshot) and add the code in there, is that what you're looking to do?

Also, is this discussion private as would not like my urls disclosed, like you've done in the previous reply, please?

If you can confirm this, I'll share more direct links, but you don't need to press "edit with Elementor" , stick with Guttenberg - doing so corrupts it and can no longer be edited... šŸ™ I do have a backup which i can share once the above is confirmed.

#2866072

Minesh
Supporter

Languages: English (English )

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

I have removed the website name from the URL I shared with my previous reply.

I need direct link to where I can add consitionals or you can for example add example conditional and share the direct link with me and also share details on frontend using what link I can cross check the conditional works or not.

*** Please make a FULL BACKUP of your database and website.***
- Please make backup of your site so any worst situation you will have a backup to restore.

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

#2866076

Minesh
Supporter

Languages: English (English )

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

Can you please set one post whose draw date is today and one post whose draw date is already passed so I can check all the conditoins.

#2866077

Hi Minesh.

No problem, done. The requested dates now reflect on the front-end above each product thumbnail.

#2866078

Minesh
Supporter

Languages: English (English )

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

Please check now: hidden link

First of all, I've eneable the legacy view so that we can build content template using shortcodes:
- https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/

Then I've build the following content template:
=> hidden link

And added the following code to it and saved the content template.

[wpv-conditional if="('[types field='draw-date' output='raw'][/types]' gte 'TODAY()' ) AND ( '[types field='draw-date' output='raw'][/types]' lt FUTURE_DAY(1) )"]
Tbe draw date is TODAY
[/wpv-conditional]

[wpv-conditional if="('NOW()' gte '[types field='draw-date' output='raw'][/types]' )"]
the draw has finished or closed
[/wpv-conditional]

Then, on "Loop: Giveaway Items" template, I've added the following shortcode that is used to display the cotent template we created above:

[wpv-post-body view_template="ct-to-render-draw-conditionals"]

Can you please confirm it works as expected now.

#2866079

Thank you very much for your patience and assistance with this issue, i'll take a look at the legacy mode link you sent through to better understand this.

It's almost 100% - would you be able to assist it now showing the date on the items you've made conditionals for, please?

e.g. Just show "The draw date is TODAY" (hide the date) and "The draw has finished or closed" (hide the date) - so essentially these messages replace the date, not sit alongside it.

Thank you.

#2866080

Minesh
Supporter

Languages: English (English )

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

Can you please add one more post for future date draw so I can test all conditoins.
- Today draw date
- Draw is closed/finished
- show draw date

#2866083

No problem, done.

#2866085

Minesh
Supporter

Languages: English (English )

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

Ok - I've added the following code to the following content template:
=> hidden link

<div class="loop-top-label"> 
	[wpv-conditional if="('[types field='draw-date' output='raw'][/types]' gte 'TODAY()' ) AND ( '[types field='draw-date' output='raw'][/types]' lt FUTURE_DAY(1) )"]
The draw date is TODAY
[/wpv-conditional]

[wpv-conditional if="('NOW()' gte '[types field='draw-date' output='raw'][/types]' )"]
The draw has finished or closed
[/wpv-conditional]
  
[wpv-conditional if="('[types field='draw-date' output='raw'][/types]' gt FUTURE_DAY(1) )"]
<p>Draw date:[types field='draw-date'][/types] </p>
[/wpv-conditional]
</div>

Then, on "Loop: Giveaway Items" template, I've added the following shortcode that is used to display the cotent template we created above:

[wpv-post-body view_template="ct-to-render-draw-conditionals"]

Now, "Loop: Giveaway Items" template has only the above shortcode.

I hope the solution I shared above will help you to fix your issue.

#2866086

Thanks Minesh! Fantastic support. šŸ™‚

- It's ALMOSt there, I've just gone to check and noticed that when a competition finishes on the same date, but earlier in the day, it shows both "Closed" + "Draw today" statements rather than "Draw Closed" - do you have a moment to correct this, please?

Thank you.

#2866087

Minesh
Supporter

Languages: English (English )

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

I just updated the code to content template as given under:

<div class="loop-top-label"> 
	[wpv-conditional if="('[types field='draw-date' output='raw'][/types]' gte 'TODAY()' ) AND ( '[types field='draw-date' output='raw'][/types]' lt FUTURE_DAY(1) )"]
The draw date is TODAY
[/wpv-conditional]

[wpv-conditional if="('[types field='draw-date' output='raw'][/types]' lt 'TODAY()'  )"]
The draw has finished or closed
[/wpv-conditional]
  
[wpv-conditional if="('[types field='draw-date' output='raw'][/types]' gt FUTURE_DAY(1) )"]
<p>Draw date:[types field='draw-date'][/types] </p>
[/wpv-conditional]
</div>
#2866088

Minesh
Supporter

Languages: English (English )

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

You can now add your own conditionals and adjust as required I've just shown you the way. You can add/edit the conditionals as per your requirement.

Here is the doc:
- https://toolset.com/documentation/legacy-features/views-plugin/#conditional-output-in-views

#2866091

Hi Minesh,

It's still showing as "Draw Today", it should say "Closed" on the product /wp-admin/post.php?post=10966&action=edit - as the draw was earlier in the day. "Closed takes precedence over the "Today", if it was in the past, but on the same day, I would need a bit of help with that if you don't mind?

Other aspects I can figure out re: standard conditionals, etc.

#2866093

Minesh
Supporter

Languages: English (English )

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

I've adjusted the conditional code added to content template as given under:

<div class="loop-top-label"> 
	[wpv-conditional if="(('[types field='draw-date' output='raw'][/types]' gte 'TODAY()' ) AND ( '[types field='draw-date' output='raw'][/types]' lt FUTURE_DAY(1) )) AND ( NOW() lt [types field='draw-date' output='raw'][/types])"]
The draw date is TODAY
[/wpv-conditional]

[wpv-conditional if="('[types field='draw-date' output='raw'][/types]' lt 'NOW()') "]
The draw has finished or closed
[/wpv-conditional]
  
[wpv-conditional if="('[types field='draw-date' output='raw'][/types]' gt FUTURE_DAY(1) )"]
<p>Draw date:[types field='draw-date'][/types] </p>
[/wpv-conditional]
</div>

I hope this time the above solution help you to resolve your issue.

#2866094

Amazing, thank you kindly. šŸ™‚