Background of the issue:
Hi! I had a problem on site https://wpml.org/forums/topic/instructions-to-payment-method-sent-in-incorrect-language/, this ticket was marked as resolved, but I have found the bug. I'm using wpml + woocommerce and custom integration with crm. It sends order on order creation
add_action( 'woocommerce_checkout_update_order_meta', function ( $order_id ) {
do_action( 'onebox_send_order', $order_id );
}, 9999 );
add_action( 'onebox_send_order', [ $this, 'send_order' ] );
public function send_order(
int $order_id, array $args = [
'customfields' => []
]
): void {
//handle data
$response = $this->send_request( 'order/set/', [ $order_data ], $order );
When the $order->save() is done, the language data dissapears. If I comment this row it works. As I understand, WPML somehow interfere when the order is saved by woocommerce. What is the correct way to fix the problem, so wpml language won't be erased. By missing language I mean that wpml_language meta is missing or has default language instead of secondary language. I'm using HPOS so it will be a problem to replace $order->save() with just update_post_meta
Thanks for the update! There is still an internal ticket open from your previous case, and we're currently investigating the issue to identify what might be causing it.
Yes, that’s fine. I was referring to an internal ticket in our bug tracker system, not the forum case itself. There was additional information from your previous case.
However, based on the information we have right now, we can only make an educated guess. It’s possible that $order->save() is being hooked or modified in our code due to a race condition—but this is just speculation at this point.
To properly debug this, we need a clear way to reproduce the issue. Could you please provide a Duplicator package of your site along with detailed instructions on how to trigger the order to your CRM to reproduce the issue?
Specifically, are there any particular steps involved in creating an order that lead to this behavior?