wc_get_related_products error in logs
-
I keep seeing this error show up in my logs and I don’t know what is causing this. Invalid limit type passed to wc_get_related_products. Expected integer, got string with value: “4”
I have searched in themese/astra/functions.php but can’t find “wc_get_related_products”.
I am not sure where else I can check to see what might be causing this.
I am using the Astra theme Version: 4.11.13 currently
Your help is greatly appreciated.
The page I need help with: [log in to see the link]
-
Hi @meatface888,
I understand how confusing it can be to see repeated errors like that in your logs, especially when it’s not clear where they’re coming from. Let’s take a closer look together so you can get this cleaned up.
The error you’re seeing ‘Invalid limit type passed to wc_get_related_products. Expected integer, got string with value: “4”‘ means that somewhere in your theme or a plugin, wc_get_related_products() is being called with “4” (a string) instead of 4 (an integer).
To help narrow it down, could you please confirm:
- Does the error appear only on product pages or site-wide (e.g., cart, homepage, etc.)?
- Have you added any custom snippets or template overrides related to related products, upsells, or cross-sells?
- Do you have any WooCommerce-related custom plugins (e.g., “Product Recommendations,” “Custom Related Products,” or Astra child theme edits)?
Here’s what you can try in the meantime:
- Switch temporarily to Storefront (WooCommerce’s default theme). If the error disappears, it’s likely theme-related — possibly Astra or a child theme file.
- Search the active theme and child theme folders for wc_get_related_products( — sometimes it’s inside files like single-product.php, related.php, or in astra/inc/woocommerce/.
- If comfortable testing code (optional): you can cast the limit value to an integer like this example:
$related_ids = wc_get_related_products( (int) 4, $product_id );- This is just a quick illustration — we can’t offer custom code or customization support directly, but you can try it if you’re familiar with theme edits or share it with your developer.
Once you confirm whether it’s happening only on product pages and whether you’re using a child theme or extra plugin, we can guide you on the exact file or plugin to check next.
I’m not seeing the errors on the live site. I only see these in the logs under WooCommerce > Status > Logs and search for “errors”.
I use custom code in Public_html > wp-content > plugins > Woolementor > widgets > Cart-items > cart-items.phpline number 1844
Replace this line:echo wp_kses( $thumbnail, $allowed_html );
with:
echo $thumbnail;
and also in public_html > wp-content > themes > astra > functions.php
//This is to fix currency from being converted twice on USD checkouts.
add_filter(‘woosb_item_price_before_set’, function ($_price, $cart_item) {
if (class_exists(‘WOOCS’)) {
global $WOOCS;
if ($WOOCS->is_multiple_allowed AND $_price) {
$currrent = $WOOCS->current_currency;
if ($currrent != $WOOCS->default_currency) {
$currencies = $WOOCS->get_currencies();
$rate = $currencies[$currrent][‘rate’];
$_price = $_price / $rate;
}
}
}return $_price;}, 10, 2);
Do all the places above you want me to check still apply?
I do run plugins like Elementor, CoDesigner, FOX – Currencey Switcher, Hide Shipping Metheod for Woocommerce, Kadence Woocommerce Email Designer, Ultimate Addons for Elementor Lite, WPC Product Bundles for Woocommerrce. Are these considered custom plugins?
These files I have checked and was not able to find “wc_get_related_products”. I did a search for the file names in the folder “public_html” and searched inside the files for “wc_get_related_products”.
single-product.php
/public_html/wp-content/plugins/codesigner-pro/views/templates/single-product.php
/public_html/wp-content/plugins/woocommerce/templates/content-single-product.php
/public_html/wp-content/plugins/woocommerce/templates/single-product.phpsingle-product.php
/public_html/wp-content/plugins/codesigner-pro/views/templates/single-product.php
/public_html/wp-content/plugins/woocommerce/templates/single-product.php
Also checked:
/public_html/wp-content/plugins/woocommerce/templates/content-single-product.phprelated.php
/public_html/wp-content/plugins/woocommerce/templates/single-product/related.phpastra/inc does not contain a folder “Woocommerce”
Hi @meatface888,
Thanks for the detailed follow-up, and great job digging through those files and plugins. That kind of thoroughness really helps narrow things down.
Since you’re not seeing the error on the live site and it’s only appearing in the logs, it’s likely being triggered by a background process or a plugin that’s calling
wc_get_related_products()with a string instead of an integer. Even though you didn’t find the function directly in the files you searched, it could still be invoked indirectly through a filter or action hook.The plugins you listed, especially ones like CoDesigner, WPC Product Bundles, and Woolementor, do extend WooCommerce functionality and could be considered “custom” in the sense that they may override templates or inject their own logic. It’s possible one of them is passing a string value like
"4"instead of an integer to thewc_get_related_products()function.Here’s what I’d suggest next:
- Try temporarily disabling one plugin at a time (starting with those that modify product display or bundles) and check the logs after each change.
- If you’re comfortable editing code, you could add a debug log or cast the value to an integer wherever
wc_get_related_products()is called, though I understand you haven’t found the exact location yet. You can also do this with the help of a developer. - If the error persists and you’re unable to trace it manually, enabling
WP_DEBUGandWP_DEBUG_LOGmight help surface the origin during page loads or AJAX calls.
Let us know what you uncover. Looking forward to your response.
How do I trigger this so I can see more errors? I’m not sure the plugin I deactivated is the one if the erros aren’t being triggered
Hi there!
To trigger the issue so you can see more errors, you’ll need to repeat the same steps or actions that usually cause the warning to appear (for example, visiting a specific product page, adding to cart, etc.).
Additionally, to assist you better, I’d like to understand your site more clearly. Please share the information below so we can investigate the issue further:- System Status Report which you can find via WooCommerce > Status
- Fatal error logs (if any) under WooCommerce > Status > Logs.
Please use https://pastebin.com/ or https://gist.github.com/ and share a link to that paste in reply here. Once we have more information, we’ll be able to assist you further.
I tried opening different pages, going to product listings, cart, page, checkout page, and placing an order. Each time I went to another page I refreshed the logs and there were no new logs appearing.
I did this on the staging site and thought maybe not everything is running on there since it’s a staging site so I tried on the production and same results.
Where do I activate
WP_DEBUGandWP_DEBUG_LOG?Maybe I can run this for a day and see if I can see where it is happening.
Hi @meatface888
I appreciate the detailed steps you’ve already taken to narrow this down — that level of testing really helps. Since you aren’t seeing new entries appear while browsing or testing on both staging and production, enabling debug logging is indeed the next best move to capture the exact source of the warning.
You can enable it by editing your site’s wp-config.php file, which is located in the root directory of your WordPress installation. Open that file and look for this line:
/* That's all, stop editing! Happy publishing. */Just above it, add these lines:
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false );Once saved, WordPress will start writing PHP warnings and errors to a log file located at: /wp-content/debug.log
After enabling this, keep the site running as normal for a while and revisit product pages or actions that may call related products (like viewing single products or checking cross-sells). Then open the debug.log file and check for entries containing wc_get_related_products.
When you have new log details, please upload that file to https://pastebin.com and share the link here along with your System Status Report from WooCommerce → Status → Get system report → Copy for support.
With those details, we’ll be able to pinpoint the function call that’s passing the string “4” and suggest the correct fix or plugin/theme source that needs adjusting.
Feel free to let us know how it goes.
I’ve let it run a few days now but don’t see any errors related to the wc_get_related_products error.
https://pastebin.com/?id=3461755
In WooCommerce I am still seeing the error though like the one from today.
2025-10-20T00:45:12+00:00 ERROR Invalid limit type passed to wc_get_related_products. Expected integer, got string with value: “4”
The log is filled with codesigner errors though, so I have a ticket open with them to investigate.
Hi @meatface888,
Thanks for the follow-up and for checking everything so thoroughly.
Since the warning
Invalid limit type passed to wc_get_related_productsonly appears in logs and not during normal site use, it’s likely triggered by a background process from a plugin, possibly CoDesigner, since your logs show related errors.Could you try deactivating CoDesigner temporarily and see if new “Invalid limit type” entries still appear in WooCommerce → Status → Logs after a day or so? That’ll confirm if it’s the source.
The notice itself is harmless, but the plugin developer may need to adjust their code to pass an integer instead of a string.
Thanks again for all the testing, you’re already very close to pinpointing it!
I can’t deactivate it just yet. We are investigating issues with this plugin right now. I can try that after the issues have been fixed.
Hi @meatface888,
Thank you for the update and for keeping us informed. Once you’ve had a chance to deactivate the plugin and run the test, please get back to us with the results.
It’s been a while since we heard back from you for this reason we are closing this thread.
If WooCommerce has been useful for your store and you appreciate the support you’ve received, we’d truly appreciate it if you could leave us a quick review here:
https://wordpress.org/support/plugin/woocommerce/reviews/#new-post
Feel free to open a new forum topic if you run into any other problem.
The topic ‘wc_get_related_products error in logs’ is closed to new replies.