Home › Forums › WoodMart support forum › Performance issue: wc_customer_bought_product() verified by WPML

Performance issue: wc_customer_bought_product() verified by WPML

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #730431

    DELAYON
    Participant

    Hello,

    We’ve been investigating intermittent site outages (multiple 4–20 minute periods of unresponsiveness) on our Woodmart-powered WooCommerce store. We traced one occurrence to a slow PHP-FPM request stuck in the following call chain:

    wp-includes/class-wp-hook.php:353 (do_action / apply_filters)
    → Woodmart theme: class-purchased-indicator.php → add_author_icon() (line 75)
    → is_user_purchased_product() (line 38)
    → wc_customer_bought_product() [WooCommerce core]
    → filtered via ‘woocommerce_customer_bought_product’
    → woocommerce-multilingual/inc/class-wcml-products.php: WCML_Products::is_customer_bought_product() (line 630)
    → WPML\FP\partial() / WPML\FP\compose() / WPML\FP\Fns::init() / call_user_func_array() / Collection::first()

    We opened a support case with WPML about this, since their code appeared in the trace. Their team investigated, reproduced the issue on a clean setup with Woodmart, and confirmed the following (quoting their reply in full):

    “The issue appears to come from WoodMart’s Verified Owner/Purchased Indicator functionality. WoodMart calls the WooCommerce wc_customer_bought_product() function separately for every review displayed on the product page. This function is not intended to be called for every individual review in this way, and with many reviews/customers, this can result in additional processing.

    WCML does intercept this function so that purchases of the original product or any of its translations are recognized. However, WCML does not add additional database queries for each translated product. WooCommerce caches the customer’s purchased products, so WCML’s checks against the translated product IDs use the already cached data.

    This also explains why WCML appears in the PHP slow-log stack: WCML’s filter wraps the WooCommerce function, but the repeated calls originate from WoodMart.

    We will report this to the WoodMart team from our side as well.”

    In other words: WPML has confirmed this is a Woodmart-side issue (calling wc_customer_bought_product() once per review/author instead of once per page or batched), not something caused by their own multilingual integration.

    WPML also provided us a temporary workaround, which they explicitly flagged as a theme-file modification that would be overwritten on the next Woodmart update:

    File: /wp-content/themes/woodmart/inc/integrations/woocommerce/modules/product-reviews/class-purchased-indicator.php, around line 75.

    Replace:

    php
    if ( $product_id && wc_customer_bought_product( $comment->comment_author_email, $comment->user_id, $product_id ) && wc_review_is_from_verified_owner( $comment_id ) ) {

    with:

    php
    if ( $product_id && wc_review_is_from_verified_owner( $comment_id ) ) {

    Their reasoning: wc_review_is_from_verified_owner() already checks whether the review was submitted by a verified customer who purchased the product, so the additional wc_customer_bought_product() call is redundant in this context.

    Important context on our side: the “Verified Purchase” badge on reviews is a legal/regulatory requirement for us as a German retailer, so simply disabling the Purchased Indicator feature is not an option for us — we need the underlying check to be correct and fast, not removed.

    Our questions:

    Can you confirm whether the workaround above (relying solely on wc_review_is_from_verified_owner()) is safe and correct from Woodmart’s side, or could it introduce edge cases (e.g. with WPML-translated products, guest checkouts, or email-matched vs. user-ID-matched purchases)?
    Since this workaround requires editing a core theme file and will be lost on every Woodmart update, is there a supported way to apply this safely (e.g. via a filter/hook we can use from a child theme or must-use plugin instead of patching core files directly)?
    Is there a permanent fix planned in an upcoming Woodmart release — specifically, caching/memoizing the purchase check per page load, or batching it across all reviews/authors on a product page instead of calling it once per review?
    If a fix is planned, do you have an expected timeline?

    We’re happy to provide our full PHP-FPM slow log, WPML’s complete support thread, and site access details if that helps speed up diagnosis.

    Thank you.

    #730457

    Serg Sokhatskyi
    Keymaster
    Xtemos team

    Hi there,

    Thank you for the detailed report. We have prepared an official fix for this issue in patch #730449.

    Please:

    – Create a site backup.
    – Navigate to Dashboard → WoodMart → Patcher.
    – Locate patch #730449 and click Apply.
    – Clear all website/server caches and test the product reviews again.

    The patch removes the redundant purchase check and uses WooCommerce’s native verified-owner status for the Purchased Indicator. Therefore, the badge remains enabled and continues to follow the verification status recorded by WooCommerce, while avoiding the additional check for every displayed review.

    You do not need to modify the parent theme file or implement a child-theme workaround. The fix will also be incorporated into a future full theme update, although we cannot provide an exact release date yet.

    Kind regards,
    XTemos Studio

Viewing 2 posts - 1 through 2 (of 2 total)