Skip to content

Conversation

@codegen-sh
Copy link
Contributor

@codegen-sh codegen-sh bot commented May 15, 2025

Issue

This PR fixes an error that occurs when the WooCommerce function wc_get_product_types() is not available. The error message is:

Uncaught Error: Call to undefined function wc_get_product_types() in /path/to/wp-content/plugins/clerkio/includes/clerk-legacy-helpers.php:38

This can happen in several scenarios:

  1. WooCommerce is not fully loaded when the Clerk plugin runs
  2. The user has an unusual WooCommerce version where this function is not available
  3. There's a loading order issue between plugins

Solution

Added a function_exists() check for wc_get_product_types() and provided a fallback with the most common product types (simple, variable, grouped, external) when the function is not available.

This change makes the plugin more robust by ensuring it doesn't fail when WooCommerce functions are not available, while maintaining full functionality when they are.

Testing

  • Tested with WooCommerce active and inactive
  • Verified the plugin works correctly in both scenarios

💻 View my workAbout Codegen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant