Hello,
Thank you for reaching out to us.
We have reviewed the issue you’re experiencing when changing the order status to “Completed” with WP Loyalty active. You are correct — WP Loyalty triggers actions (like awarding points and sending email notifications for points earned) when the status changes to “Completed.”
However, after examining the error you’re encountering, it seems the conflict is related to the label creation plugin’s handling of the order object. Both WP Loyalty and the label plugin use the same hook during this status change.
$this->loader->add_filter( 'woocommerce_email_format_string', $plugin_admin, 'plc_tracking_links_placeholder', 99, 2 );
In this case, the label creation plugin attempts to process the order object, but it does so without validating whether the object exists or is of the correct type.
Specifically, the error occurs in this part of their code:
$order = $email->object;
In the callback function plc_tracking_links_placeholder, the code attempts to fetch the order object directly:
public function plc_tracking_links_placeholder( $string, $email ) {
$placeholder = '{tracking_numbers}';
$order = $email->object;
$value = $this->plc_get_tracking_numbers( $order );
return str_replace( $placeholder, $value, $string );
}
In this instance, $order might be null (as it’s not always the order object that gets passed), which leads to the error. In some cases, it could be a user object or another type(based on the plugin requirement), which leads to the order being null. The plugin should ideally include validation to check if the order object exists before processing it.
Additionally, in the plc_get_tracking_numbers function, the order object is used without validation:
public function plc_get_tracking_numbers( $order ) {
global $wpdb;
$query = '
SELECT * FROM ' . PLC_SHIPMENTS . '
WHERE order_id="' . $order->get_id() . '"
';
$results = $wpdb->get_results( $query, OBJECT );
.......
}
If the $order is null, calling $order->get_id() will result in an error. It’s crucial to validate the order object to prevent these issues from occurring.
We recommend reaching out to the label creation plugin’s support team and pointing out this issue. They may need to implement validation for the order object before using it in their callbacks.
Please let us know if you need further assistance or clarification. We’re here to help!
Best regards,
Akshaya
Flycart Support Team