• Resolved nuagelab

    (@nuagelab)


    The latest version of the plugin (Upsell version 2.2.6 combined to Upsell Pro version 2.1.8) with WooCommerce version 8.0.3 and WordPress 6.3.1, running on PHP 7.4.33 results in the following error when an order is created from the admin:

    [29-Aug-2023 20:59:00 UTC] PHP Fatal error: ?Uncaught Error: Call to a member function set() on null in /home/xxxxxx/public_html/wp-content/plugins/upsell-order-bump-offer-for-woocommerce/public/class-upsell-order-bump-offer-for-woocommerce-public.php:1999
    Stack trace:
    #0 /home/xxxxxx/public_html/wp-includes/class-wp-hook.php(312): Upsell_Order_Bump_Offer_For_Woocommerce_Public->wps_custom_get_current_order_id(60039)
    #1 /home/xxxxxx/public_html/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters('', Array)
    #2 /home/xxxxxx/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #3 /home/xxxxxx/public_html/wp-content/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php(194): do_action('woocommerce_new...', 60039, Object(Automattic\WooCommerce\Admin\Overrides\Order))
    #4 /home/xxxxxx/public_html/wp-content/plugins/woocommerce/includes/class-wc-data-store.php(196): WC_Order_Data_Store_CPT->update(Object(Automattic\WooCommerce\Admin\Overrides\Order))
    #5 /home/xxxxxx/public_html/wp-content/plugins/woocommer in /home/xxxxxx/public_html/wp-content/plugins/upsell-order-bump-offer-for-woocommerce/public/class-upsell-order-bump-offer-for-woocommerce-public.php on line 1999

    The order is properly created, and refreshing the page shows it.

    It only seems to affect orders created from the admin.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author WP Swings

    (@wpswings)

    Hey @nuagelab

    We have tested at our end present and previous versions also. But we have not found any issue as of now.

    It maybe the issue is site specific so please connect with our support team, they will help and guide you further on this

    Regards,

    We are having the same issue.

    At /class-upsell-order-bump-offer-for-woocommerce-public.php?on line?1999

    Thread Starter nuagelab

    (@nuagelab)

    The line in question is:

    WC()->session->set( 'custom_order_id', $order_id );

    So I’m guessing that WC()->session is null when an order is created from the admin because there is no active WooCommerce session in that specific case, and contains a valid session when the order is created from the frontend.

    I don’t know your code, but I’m pretty sure this would fix it:

    if (WC()->session !== null) {
        WC()->session->set( 'custom_order_id', $order_id );
    }

    There’s probably no upsell to make when an order is created from the admin, and this session field is probably only useful when the order is from a real customer using the frontend to which we can try to upsell something to. But it’s just an educated guess, as I wrote, I don’t know your code.

    • This reply was modified 1 year, 5 months ago by nuagelab.
    • This reply was modified 1 year, 5 months ago by nuagelab.
    Thread Starter nuagelab

    (@nuagelab)

    @wpswings You might have been unable to reproduce the problem because you tested something else on the frontend earlier and thus had an active WooCommerce session.

    I would suggest retrying the same thing (adding an order through the admin) from an incognito window that never accessed the frontend in order to be able to reproduce it.

    • This reply was modified 1 year, 5 months ago by nuagelab.
    Plugin Author WP Swings

    (@wpswings)

    Hey,

    Thanks for the report and also for suggesting the solution for that. This issue persists when we add the order from the admin side where the woocommerce session doesn’t exist and this error arises. we will update this with some extra validation in the upcoming update and for now, you can use the following code as suggested.

    Replace this at file public/class-upsell-order-bump-offer-for-woocommerce-public.php

    WC()->session->set( ‘custom_order_id’, $order_id );

    to this

    if (WC()->session !== null) { WC()->session->set( ‘custom_order_id’, $order_id ); }

    If still any queries please ping us,

    Regards,

    Thread Starter nuagelab

    (@nuagelab)

    @wpswings Thanks for following up! It’s a minor annoyance, the admin created order ends up being created properly. But non-technical users tend to panic when they get a Server Error. We instructed ours just to reload the page and that all would be fine (and it is). But I’m guessing many of your users aren’t aware of that.

    You can close this issue as you wish, we’ll be looking forward to the next version.

    Plugin Author WP Swings

    (@wpswings)

    Hey,

    Sure we will update it,

    Thank you

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Error when creating an order in the admin’ is closed to new replies.