Skip Navigation

[Resolved] Make a BUY button appear conditionally

This support ticket is created 5 years, 8 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 5 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#1217721

Toolset & Elementor pro

I'd like a 'Buy Ticket' button to appear ONLY if the Toolset Custom Field 'Box Office URL' actually has a URL in it. If it is empty I do not want the Button to appear. Can this be done?

I am using Elementor Pro so I can make the URL of the button dynamic of course but not the button itself.

hidden link

Thanks

#1218243

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Hi John

Toolset provides for conditional display, but it doesn't work at the level of page builder modules, such as a button module from Elementor.

Conditional shortcodes can be used to wrap a section of markup (to determine whether the markup is added to the page or not), which is described in this documentation section: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

This page specifically refers to testing if a field is empty: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

So your button would need to be added to a text module (if I recally correctly, the Elementor HTML module doesn't parse shortcodes), and you would wrap the markup for the button in the wpv-conditional shortcode.

Note that Toolset can't control the Elementor UI, meaning you would need to add the shortcodes manually.

You may find it easier to edit a template or page without Elementor where you can use the Conditional Output button to insert the conditional shortcode with the correct attributes, and then copy and paste this into where it is needed in the text module.

If you want the button to look the same as if you had inserted a button module you can inspect the markup for the button when inserted via a button module and then paste that into the text module.

This is what is currently output on your test URL:

<div class="lae-button-wrap" style="clear: both; text-align:center;"><a class="lae-button  lae-with-icon lae-default lae-small lae-animate-on-scroll lae-visible-on-scroll animated fadeIn" data-animation="fadeIn" href="#" target=""_blank"" style="opacity: 1;"><span class="fa fa-gbp"></span>Buy Now</a></div>