Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
276 views
in Technique[技术] by (71.8m points)

wordpress - Error notice in woocommerce email after update status in webhook

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

Email error

question from:https://stackoverflow.com/questions/65890140/error-notice-in-woocommerce-email-after-update-status-in-webhook

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There was nothing wrong with the plugin, the notice was showing because i was in debug mode, so i edited de wp-config to: define( 'WP_DEBUG', false ); and it solved the problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...