• Resolved Leo.Lin

    (@bi1012037)


    After the upgrade, I can no longer use the Rest API to query all products in an order.

    from woocommerce import API
    wcapi = API(
        url="my_domain",
        consumer_key="ck_my_key",
        consumer_secret="cs_mysecret",
        version="wc/v3",
        timeout=20
    )
    order_id = "12345"
    oder_items = wcapi.get("orders/%s" % order_id).json()
    print(oder_items)

    {‘code’: ‘internal_server_error’, ‘message’: ‘
    A serious error occurred on this website.
    Learn more about troubleshooting in WordPress
    ‘, ‘data ‘: {‘status’: 500}, ‘additional_errors’: []}

Viewing 8 replies - 1 through 8 (of 8 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi there

    {‘code’: ‘internal_server_error’, ‘message’: ‘
    A serious error occurred on this website.
    Learn more about troubleshooting in WordPress
    ‘, ‘data ‘: {‘status’: 500}, ‘additional_errors’: []}

    The error message you’re receiving suggests that there’s an internal server error on your website.

    The first thing I would recommend is to check your server error logs. These logs can provide more detailed information about what might be causing the internal server error. You can usually find these logs in your hosting control panel or by contacting your hosting provider.

    There’s more information on error logs in this support documentation.

    Hope this helps.

    Thread Starter Leo.Lin

    (@bi1012037)

    Hello, I have rolled back to v8.3.1, there may be some problems with 8.4.0 currently!

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @bi1012037

    I’m glad to know that downgrading to 8.3.1 resolved your issue! But, to get to the bottom of this error, would you mind upgrading again, turning on the legacy API, and checking if the error reappears?

    Direct link: https://vgy.me/u/UQRsp2

    Rest assured, I’ve tried replicating the error using WooCommerce 8.4.0, WordPress 6.4.2, and the Storefront theme on my testing site. However, it appears everything is working perfectly without any errors.

    Thanks!

    Thread Starter Leo.Lin

    (@bi1012037)

    Hi,
    I have upgraded again and checked to allow the use of the old Rest API, but still have the same error. The server error message is as follows:
    2023/12/14 10:17:08 [error] 14000#0: *179017 FastCGI sent in stderr: “PHP message: PHP Fatal error: Uncaught Error: Call to a member function get() on null in /usr/share /nginx/html/wordpress/wp-content/plugins/woocommerce/includes/wc-cart-functions.php:394

    • This reply was modified 11 months, 2 weeks ago by Leo.Lin.
    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @bi1012037

    Thanks for your effort in trying again and letting us know the outcome.

    The error message you’re seeing suggests an issue with your PHP configuration or a specific plugin.

    I recommend checking your PHP version. WooCommerce requires PHP 7.4 or higher, so please ensure you’re running a compatible version. The version that best works on my testing site is 8.1.26.

    If your PHP version is up-to-date, the issue might be caused by a conflict with another plugin. To identify if this is the case, I suggest deactivating all your other plugins and then reactivating them one by one, checking each time to see when the error reappears. This should help you identify the problematic plugin.

    If running a conflict test on your live site isn’t possible, don’t worry! You can easily create a staging site to conduct the test without impacting your sales. To help you out, we’ve put together a detailed guide on how to create a staging site here: https://woo.com/posts/what-is-staging-site-wordpress-how-to-set-one-up/

    I recommend creating an issue on Github if you still face problems after trying these steps. Our developer will then be able to check it out and give you some insight.

    Thanks again for your cooperation and patience.

    Thread Starter Leo.Lin

    (@bi1012037)

    I have found other plug-ins that affect this API, but v8.3.1 is normal. I will check how to modify it now!
    Affected code: $chosen_shipping = wc_get_chosen_shipping_method_ids();

    add_filter('woocommerce_payment_gateways', 'newebpay_alter_payment_gateways', 100);    
    function newebpay_alter_payment_gateways($list) {
            if(isset($_GET['pay_for_order']) && isset($_GET['key'])) {
                $order_id = wc_get_order_id_by_order_key($_GET['key']);
                $order = wc_get_order($order_id);
                if($order->has_shipping_method('newebpay_cvscom')) {
                    $list = array('WC_newebpay');
                }
            }elseif(!is_admin() && function_exists('wc_get_chosen_shipping_method_ids')) { I have found other plug-ins that affect this API, but v8.3.1 is normal. I will check how to modify it now!
                $chosen_shipping = wc_get_chosen_shipping_method_ids();
                if ($chosen_shipping !== null) {
    
                    $virtual_count = 0;
                    $cart_items = WC()->cart->get_cart();
                    foreach ( $cart_items as $key => $cart_item ) {
                        $virtual_count += ($cart_item['data']->is_virtual()) ? 1 : 0;
                    }
                    if(@ in_array('newebpay_cvscom', $chosen_shipping) && $virtual_count < count($cart_items)) {
                        $list = array('WC_newebpay');
                    }
                }
            }
    
            return $list;
        }
    • This reply was modified 11 months, 2 weeks ago by Leo.Lin.
    Thread Starter Leo.Lin

    (@bi1012037)

    @shameemreza

    I’m not sure if this is a good way to modify it. For now, I’ll modify it like this.Currently, it’s working fine!
    add code
    if (is_object(WC()->cart)){

    }

    
    function newebpay_alter_payment_gateways($list) {
            if(isset($_GET['pay_for_order']) && isset($_GET['key'])) {
                $order_id = wc_get_order_id_by_order_key($_GET['key']);
                $order = wc_get_order($order_id);
                if($order->has_shipping_method('newebpay_cvscom')) {
                    $list = array('WC_newebpay');
                }
            }elseif(!is_admin() && function_exists('wc_get_chosen_shipping_method_ids')) { 
                if (is_object(WC()->cart)) { //fix here
                    $chosen_shipping = wc_get_chosen_shipping_method_ids();
              
                    $virtual_count = 0;
                    $cart_items = WC()->cart->get_cart();
                    foreach ( $cart_items as $key => $cart_item ) {
                        $virtual_count += ($cart_item['data']->is_virtual()) ? 1 : 0;
                    }
                    if(@ in_array('newebpay_cvscom', $chosen_shipping) && $virtual_count < count($cart_items)) {
                        $list = array('WC_newebpay');
                    }
                }
            }
    
            return $list;
        }
        add_filter('woocommerce_payment_gateways', 'newebpay_alter_payment_gateways', 100);
    • This reply was modified 11 months, 2 weeks ago by Leo.Lin.

    Hey there @bi1012037,

    Thank you so much for adding your input! Some of our customers might indeed find this guide helpful!

    modify it like this.Currently, it’s working fine!

    Just to clarify, this works fine with WooCommerce version 8.4.0 now. Correct?

    We appreciate you being an active part of the community ??

    Have a wonderful day!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Rest API error after upgrading woocommerce 8.4.0’ is closed to new replies.