Skip Navigation

[Gelöst] How to include [wpv-woo-buy-options] shortcode in conditional output

This support ticket is created vor 6 Jahre, 5 Monate. 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 Antworten, has 2 Stimmen.

Last updated by Christian Cox vor 6 Jahre, 5 Monate.

Assisted by: Christian Cox.

Author
Artikel
#584112
Settings.png
Conditions.png

I'm trying to use [wpv-woo-buy-options] as part of the output for a conditional argument in a visual editor. the argument works as expected, but [wpv-woo-buy-options] is not rendered as shortcode, and the raw shortcode appears on the front end.

I'm a little confused by documentation I've come across, as much seems to suggest adding a function to the toolset front end settings page. I can see where this should go, and can see other woocommerce functions and fields there, but adding wpv_woo_buy_options_func or wpv_woo_buy_options etc does not seem to make it work. I'll add open ended id functions to the

Site is unavailable to the public right now, but I've added screenshots to explain.

So, I'd like this code to work, but it doesn't out put the buy button on the front end.

[wpv-conditional if="( $(wpcf-availability) eq '2' )"]
Please <a href="mailto:sales@yourdomain.com">email us</a> for pre-order information [/wpv-conditional][wpv-conditional if="( $(wpcf-availability) eq '2' )" evaluate="false"][wpv-woo-buy-options add_to_cart_text='Add product to basket' show_quantity_in_button="no"]
[/wpv-conditional]

As a workaround I've used css visibiity and included a div id in the conditional output. It works but is restrictive.

[wpv-conditional if="( $(wpcf-availability) eq '2' )"]
<div id="buybuttoninvis">Please <a href="mailto:sales@yourdomain.com">email us</a> for pre-order information [/wpv-conditional][wpv-conditional if="( $(wpcf-availability) eq '2' )" evaluate="false"]
<div>[/wpv-conditional][wpv-woo-buy-options add_to_cart_text='Add product to basket' show_quantity_in_button="no"]</div>

Any clearer instructions on how to add [wpv-woo-buy-options] to the conditional output list, the documentaion seems unclear to me at least? Or maybe it is not possible?

Thanks,

Ben

#584598

I'm a little confused by documentation I've come across, as much seems to suggest adding a function to the toolset front end settings page.
There are two times you would be required to register something on the settings page.
- If your shortcode is used as an argument in another shortcode. I don't think it's necessary in this case. You would only need to do this if had something like

[wpv-post-title id="[wpv-woo-buy-options]"]

- If you have a custom PHP function and you want to use it as an argument for a conditional. Something like

[wpv-conditional if=" my-custom-php() eq '1'"]Something[/wpv-conditional]

Neither of these is necessary here, so something else must be going on. I don't see anything obviously wrong with your code, and in fact it works well for me on a local test environment when I copy + paste. Please try the following troubleshooting steps to help narrow down the issue.
1. Remove the "show _quantity_in_button" attribute. It's not documented, so it's not doing anything for you:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-woo-buy-options

2. Temporarily disable all plugins except WooCommerce, Types, Views and WooCommerce Views. Activate a default theme like Twenty Seventeen, then retry. If the problem is resolved, reactivate your theme and plugins one by one until the conflict is revealed.

3. If the problem was not resolved, make sure all your Toolset and WooCommerce plugins are up-to-date.

4. Create a basic Layout that only includes a Visual Editor cell with the shortcode wrapped in a basic conditional like shown below. Temporarily apply the basic Layout to the product so you can see if there is perhaps a conflict in the Layout somewhere, or some other broken code.

[wpv-conditional if="( '1' eq '1' )"][wpv-woo-buy-options add_to_cart_text='Add product to basket'][/wpv-conditional]
#585771

Ok, will try in fresh layout etc when I have a moment.

Just an FYI, the "show _quantity_in_button" attribute is documented:

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-woo-buy-or-select

It is needed here, and used elsewhere in other views and works as expected. but I'll also try without to see if that is a part of the problem. I'll maybe give it a go on one of the reference/training sites.

#586454

Okay sure, I'll stand by for your update.

Just an FYI, the "show _quantity_in_button" attribute is documented:
You're referring to documentation for another shortcode's attributes. I meant the attribute is not documented as a supported attribute for this shortcode. Just wanted to let you know that it should not be inferred an attribute is supported in any shortcodes other than the one(s) where it is documented.

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