• Resolved MaxAuray

    (@maxauray)


    Hi,

    Found a bug. Call to

    $strThumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $product->get_image( 'full', array( 'class' => 'block package checkout' ) ), $item, $item_id );

    leads to a CRITICAL Uncaught Error: Call to a member function get_type() on null in /var/www/vhosts/www.pre.ex-nihilo-paris.com/wp-content/plugins/giftable-for-woocommerce/includes/DGFW.php:530 in Version 1.0.4

    Complete error:

    2019-08-16T13:16:21+00:00 CRITICAL Uncaught Error: Call to a member function get_type() on null in /var/www/vhosts/www.pre/wp-content/plugins/giftable-for-woocommerce/includes/DGFW.php:530
    Stack trace:
    #0 /var/www/vhosts/www.pre/wp-content/plugins/giftable-for-woocommerce/public/Public.php(488): DGFW->is_gift(NULL)
    #1 /var/www/vhosts/www.pre/wp-includes/class-wp-hook.php(286): DGFW_Public->gift_cart_thumbnail('<img width="560...', Object(WC_Order_Item_Product), 252)
    #2 /var/www/vhosts/www.pre/wp-includes/plugin.php(203): WP_Hook->apply_filters('<img width="560...', Array)
    #3 /var/www/vhosts/www.pre/wp-content/themes/my-custom-theme/woocommerce/order/order-details-item.php(36): apply_filters('woocommerce_car...', '<img width="560...', Object(WC_Order_Item_Product), 252)
    #4 /var/www/vhosts/www.pre/wp-content/plugins/woocommerce/includes/wc-core-functions.php(211): include('/var/www/vhosts...')
    #5 /var/www/vhosts/www.pre in /var/www/vhosts/www.pre/wp-content/plugins/giftable-for-woocommerce/includes/DGFW.php on line 530

    Thanks.

    • This topic was modified 5 years, 3 months ago by MaxAuray.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author DecomTeam

    (@decomteam)

    hi @maxauray thanks for report, you are using default WooCommerce theme files or you are trying to modify them ? where are you calling this $strThumbnail ?

    Check that you have latest woocommerce theme files applied to you custom-theme/woocommerce/folder , I see that cart file is calling image like this:
    $_product->get_image()

    $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
    

    What to do to reproduce it (steps or video would be great) ?

    • This reply was modified 5 years, 3 months ago by DecomTeam.
    Thread Starter MaxAuray

    (@maxauray)

    Hi @decomteam.

    I am working on a custom theme, nothing to do with WooCommerce theme files, except it rigorously respect WordPress coding rules.

    As part of it, the get_image method of WP_Product is called with parameters for my own needs. See https://docs.woocommerce.com/wc-apidocs/source-class-WC_Product.html#1825-1849

    In my code:
    $product->get_image( 'full', array( 'class' => 'block package checkout' ) )

    But that’s not the point. The point applies to the woocommerce_cart_item_thumbnail filter that cascades to a call to DGFW_Public->gift_cart_thumbnail as defined in .\public\Public.php.

    There, in Public.php:488, a call to method DGFW_Public->is_gift($cart_item['data']) occurs without verifying if the ‘data’ entry of $cart_item contains an object. Then DGFW->is_gift($product) with $product = $cart_item[‘data’] calls the get_type() method on $product whatever $product is. In my case, it may be NULL. Fatal Error.

    Please change the Public.php:488 from:

    if ($cart_item && $cart_item['variation_id'] && $this->is_gift($cart_item['data']) ) {

    to

    if ($cart_item && $cart_item['variation_id'] && is_object($cart_item['data']) && $this->is_gift($cart_item['data']) ) {

    • This reply was modified 5 years, 3 months ago by MaxAuray.
    • This reply was modified 5 years, 3 months ago by MaxAuray.
    Plugin Author DecomTeam

    (@decomteam)

    @maxauray thank you for reporting back, should be included in next update (no eta).

    Plugin Author DecomTeam

    (@decomteam)

    – included in 1.0.5

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Call to a member function get_type() on null’ is closed to new replies.