Skip Navigation

[Resolved] Conditional Add To Cart button for Woocommerce

This support ticket is created 6 years, 11 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by DanielS9588 6 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#519424

I am trying to:
Create conditional Add To Cart button for a WooCommerce template i created.

I visited this URL:
hidden link

I expected to see:
When there isn't a Price for a product the ADD TO CART should not appear.

Instead, I got:
The ADD TO CART appears by default.

Thank you and I look forward to your response.

#519429

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Daniel,

Thank you for contacting our support forum.

I believe this issue is being caused by your API key. To verify this please try this api key below and let me know if the issue persists.
AIzaSyB0KhffiMteHVLTmx5bdgG4_m2gI5YAFgw

If not then what I would recommend that you do is to regenerate your API key with an unrestricted domain and try that key.

Thanks,
Shane

#519440

Shane,

Thanks for VERY quick response.

Where do I input this API Key?

I'm not seeing a place withing Woocommerce or WP-Tools.

#519526

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Daniel,

Please disregard my initial response as it seems that i had mixed up my ticket responses 🙁

I must apologize for that.

You issue seems to need some conditional code to make it work.
Would you mind providing me with admin access to the site so that I can check on the page for you ?

The private fields will be enabled for your next response.

Thanks,
Shane

#524241

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Daniel,

Thank you for the login.

The correct solution to this is using our conditional shortcode.

An example can be seen below.

[wpv-conditional if="( '[wpv-post-field name='_regular_price']' ne '' )"]
Display something if the price is not equal to empty
    [/wpv-conditional]

[wpv-conditional if="( '[wpv-post-field name='_regular_price']' eq '' )"]
Display something if the price is empty
    [/wpv-conditional]

So what you can do is to add your add to cart information in the first conditional and it will only display when you have a price filled in.

Please let me know if this helps.
Thanks,
Shane

#525283

Shane,

AWESOME!
Working perfectly and Im using it for a few other things as well.

Thank you for your time and direction.

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