• Resolved wallyBurger

    (@wallyburger)


    Since updating to 2.4.2 the wc_customer_bought_product doesn’t seem to pick out purchased orders correctly. I can’t see why not from the SQL request in the code. If I run the SQL directly it works.

    Has this function been updated or is there a conflict I should watch out for?

    I can see the order has been completed in admin.

    Thanks.

    https://wordpress.org/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello Authors,

    I have faced the same issue for wc_customer_bought_product. After debugging your plugin code, found that there is one parameter missing in SQL.

    $result = $wpdb->get_var(
    $wpdb->prepare( “
    SELECT 1 FROM {$wpdb->posts} AS p
    INNER JOIN {$wpdb->postmeta} AS pm ON p.ID = pm.post_id
    INNER JOIN {$wpdb->prefix}woocommerce_order_items AS i ON p.ID = i.order_id
    INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS im ON i.order_item_id = im.order_item_id
    WHERE p.post_status IN ( ‘wc-completed’, ‘wc-processing’ )
    AND pm.meta_key IN ( ‘_billing_email’, ‘_customer_user’ )
    AND im.meta_key IN ( ‘_product_id’, ‘_variation_id’ )
    AND im.meta_value = %d
    “, $product_id
    ) . ” AND pm.meta_value IN ( ‘” . implode( “‘,'”, $customer_data ) . “‘ )”
    );

    SELECT 1 should be replaced with SELECT COUNT( DISTINCT i.order_item_id ).

    I hope we will get this fixed as soon as possible.

    Plugin Contributor Mike Jolley

    (@mikejolley)

    Thanks for reporting. Patched here https://github.com/woothemes/woocommerce/commit/0da69f2bef9f454945ebbaac581d1073655c8569

    tushar_solace please report on github next time so we can catch it sooner 🙂

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

The topic ‘wc_customer_bought_product error’ is closed to new replies.