I'm writing a plugin for WooCommerce, everything is working fine but I'm getting a notice error in the emails when the update is being changed in the webhook, if I update the status in process payment function this does not happen.
Even with this notice error the plugin updates the status correctly.
This is how I change the order status in the webhook, is there something I'm doing wrong?
public function webhook() {
$result = sanitize_text_field($_GET['success']);
$transaction_id = sanitize_text_field($_GET['transaction_id']);
$public_transaction_commerce_id = sanitize_text_field($_GET['public_transaction_commerce_id']);
if($result == 'true')
{
$order = wc_get_order($public_transaction_commerce_id);
$order->update_status( 'completed', 'Pago Confirmado TXID: '.$transaction_id );
WC()->cart->empty_cart();
return wp_redirect($this->get_return_url( $order));
}
else
{
wc_add_notice('El pago no pudo ser procesado, verifique su pedido e intente nuevamente.', 'error' );
return wp_redirect(wc_get_cart_url());
}
}
Notice: payment_method ha sido llamada de forma incorrecta. Order
properties should not be accessed directly. Backtrace:
require('wp-blog-header.php'), wp, WP->main, WP->parse_request,
do_action_ref_array('parse_request'), WP_Hook->do_action,
WP_Hook->apply_filters, WC_API->handle_api_requests,
do_action('woocommerce_api_glufcopayments'), WP_Hook->do_action,
WP_Hook->apply_filters, WC_GlufcoPayments_Gateway->webhook,
WC_Order->update_status, WC_Order->save, WC_Order->status_transition,
do_action('woocommerce_order_status_completed'), WP_Hook->do_action,
WP_Hook->apply_filters, WC_Emails::send_transactional_email,
do_action_ref_array('woocommerce_order_status_completed_notification'),
WP_Hook->do_action, WP_Hook->apply_filters,
WC_Email_Customer_Completed_Order->trigger, WC_Email->get_content,
WC_Email_Customer_Completed_Order->get_content_html,
wc_get_template_html, wc_get_template,
include('/plugins/woocommerce/templates/emails/customer-completed-order.php'),
do_action('woocommerce_email_order_detai in
/opt/bitnami/apps/wordpress/htdocs/wp-includes/functions.php on line
5229
question from:
https://stackoverflow.com/questions/65890140/error-notice-in-woocommerce-email-after-update-status-in-webhook 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…