/**
* Calculate and update the total revenue of a product
* @param $productid
*/
private function updateTotalRevenueOfProduct($productid) {
global $wpdb;
$query ="SELECT
SUM(ltoim.meta_value) as revenue
FROM
{$wpdb->prefix}woocommerce_order_itemmeta wcoim
LEFT JOIN
{$wpdb->prefix}woocommerce_order_items oi ON wcoim.order_item_id = oi.order_item_id
LEFT JOIN
{$wpdb->prefix}posts wpposts ON order_id = wpposts.ID
LEFT JOIN
{$wpdb->prefix}woocommerce_order_itemmeta ltoim ON ltoim.order_item_id = oi.order_item_id AND ltoim.meta_key = '_line_total'
WHERE
wcoim.meta_key = '_product_id' AND wcoim.meta_value = %d AND wpposts.post_status = 'wc-completed';";
$translations = pll_get_post_translations($productid);
foreach($translations as $item){
$result = $wpdb->get_row($wpdb->prepare( $query, $item ), ARRAY_A);
if (!is_null($result) && isset($result['revenue'])) {
update_post_meta( $item, 'wcdp_total_revenue', array('revenue' => (float) $result['revenue'], 'time' => time()));
} else {
update_post_meta( $item, 'wcdp_total_revenue', array('revenue' => 0, 'time' => time()));
}
}
}
You have any idea why now I get the value on other language and not the default language?
First I had on Hebrew language the value, now it changed to English.
Thank you for your help.