Hello @dragoscristache,
Thank you for reaching out!
The version you’re using is outdated at this point, please try updating to version 7.9.0 per the steps in this guide.
Could you also attach a copy of your site’s System Status report? You can find it via WooCommerce > Status. Select “Get system report” and then “Copy for support” (after you scroll down a bit)”. Once done, please paste it here in your reply or via a text-sharing service like https://gist.github.com/.
Look forward to hearing back from you.
Hello @babylon1999,
I managed to find out the culprit for my issue. I was using the function below to store some additional info that we need for accounting reasons. After a bit of digging around I found that the item->save() part was causing a lot of issues under high traffic.
add_action('woocommerce_checkout_create_order', 'save_regular_price_in_order', 10, 2 );
function save_regular_price_in_order( $order, $data ) {
foreach( $order->get_items() as $item_id => $item ){
$product = $item->get_product();
$regular_price = $product->get_regular_price();
$sale_price = $product->get_sale_price();
$item->update_meta_data( '_regular_price', $regular_price );
$item->update_meta_data( '_sale_price', $sale_price );
$item->save();
}
}
I managed to fix it by saving once at order level instead of every line item – like this.
add_action('woocommerce_checkout_create_order', 'save_regular_price_in_order', 10, 2 );
function save_regular_price_in_order( $order, $data ) {
foreach( $order->get_items() as $item_id => $item ){
$product = $item->get_product();
$regular_price = $product->get_regular_price();
$sale_price = $product->get_sale_price();
$item->update_meta_data( '_regular_price', $regular_price );
$item->update_meta_data( '_sale_price', $sale_price );
// $item->save();
}
$order->save();
}
I hope this helps anyone that encounters this issue in the future. I found some extra information on Github, in issues 17660 and 25623.
I managed to fix it by saving once at order level instead of every line item – like this.
Nice work! :)
I’ll be marking the thread as solved, feel free to create a new one if you have any other questions.
Cheers!