Support » Plugin: DHL for WooCommerce » Uncaught Error: Call to a member function get_weight() on boolean

  • Resolved gerd.neumann

    (@gerdneumann)


    Hi,

    just to let you know that I saw this error. And this was in my error.log:

    
    2018/05/14 12:18:14 [error] 18093#18093: *192800 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to a member function get_weight() on boolean in /var/www/my-site.org/wp-content/plugins/dhl-for-woocommerce/includes/abstract-pr-dhl-wc-order.php:386
    Stack trace:
    #0 /var/www/my-site.org/wp-content/plugins/dhl-for-woocommerce/includes/abstract-pr-dhl-wc-order.php(76): PR_DHL_WC_Order->calculate_order_weight('1803')
    #1 /var/www/my-site.org/wp-admin/includes/template.php(1063): PR_DHL_WC_Order->meta_box(Object(WP_Post), Array)
    #2 /var/www/my-site.org/wp-admin/edit-form-advanced.php(707): do_meta_boxes(Object(WP_Screen), 'side', Object(WP_Post))
    #3 /var/www/my-site.org/wp-admin/post.php(174): include('/var/www/my-...')
    #4 {main}
      thrown in /var/www/my-site.org/wp-content/plugins/dhl-for-woocommerce/includes/abstract-pr-dhl-wc-order.php on line 386" while reading response header from upstream, client: 79.244.63.140, server: www.my-site.org, request: "GET /wp-admin/post.php?post=1803&action=edit HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "www.my-site.org", referrer: "https://www.my-site.org/wp-admin/edit.php?s=myuser&post_status=all&post_type=shop_order&action=-1&m=0&_customer_user&paged=1&action2=-1"
    

    Looks like the plugin is calling get_weight() on a boolean. Sorry, that I cannot give further steps to reproduce, but I only have this error log.

    But maybe you can add a further check here.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Shadi Manna

    (@shadim)

    Is the plugin working normally though? Has this error caused any issues for you? Can you let me know if you figure out how to recreate this error?

    > Is the plugin working normally though?

    Yes.

    > Has this error caused any issues for you?

    No, I just saw the error in the log. I was raised by one of our shopmanagers. (I am the website / server admin).

    > Can you let me know if you figure out how to recreate this error?

    I guess I won’t be able to provide more info than what is in the fatal error stacktrace.

    Hi guys,

    The problem is caused if the order has a deleted product and in that case it can’t get the weight of the product. To fix it, just check if the product exists before getting and calculating the weight on line 387 in includes/abstract-pr-dhl-wc-order.php.

    if( $product ) {
      $product_weight = $product->get_weight();
      if( $product_weight ) {
        $total_weight += ( $item['qty'] * $product_weight );
      }
    }

    Best,
    Boris

    Plugin Author Shadi Manna

    (@shadim)

    Boris,

    Thank you for the comment, this will be fixed in the coming version of the plugin.

    Best.

    Plugin Author Shadi Manna

    (@shadim)

    This is now fixed in version 1.0.16, please test and confirm if NOT fixed.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Uncaught Error: Call to a member function get_weight() on boolean’ is closed to new replies.