3

I got this error:

Fatal error: Call to a member function getPrice() on null in /home/.../public_html/vendor/magento/module-checkout/Block/Shipping/Price.php on line 71

So, after reading this solution here I altered this file:

/app/design/frontend/Package/Theme/Magento_Checkout/Block/Shipping/Price.php

However, I still keep getting the same error:

Fatal error: Call to a member function getPrice() on null in /home/.../public_html/vendor/magento/module-checkout/Block/Shipping/Price.php on line 71

Which makes me think that Magento2 is ignoring my Block in Magento_Checkout, and defaulting back to Magento2's own core code.

How can I solve this issue (without editing the core code).

Is there something I need to do to register this Block?


Before I get asked:

I have deployed:

php bin/magento setup:static-content:deploy

I have re-indexed:

php bin/magento indexer:reindex

I have cleared the cache:

php bin/magento cache:clean
php bin/magento cache:flush

And Magento 2 is in the painfully slow developer mode.

I have made alterations to the view files in /app/design/frontend/Package/Theme/Magento_Checkout/view/frontend/templates/... and these have all worked fine. They are not being ignored, only /app/design/frontend/Package/Theme/Magento_Checkout/Block is being ignored.


I think my problem here might be related, I have made changes to XML Layout for Magento_CatalogSearch but these changes are being ignored, and the default XML Layout is being used instead.

6
  • why the downvote?
    – Jimmery
    Commented Apr 26, 2016 at 13:34
  • 1
    I'm not sure why you were downvoted? I'm upvoting as it seems like a well-considered question and you've posted many avenues you investigated.
    – philwinkle
    Commented Apr 26, 2016 at 13:41
  • 1
    Sorry i did it downvote. basically it is a mistake. i want to upvote but click on a wrong place
    – Asish Hira
    Commented Apr 26, 2016 at 14:38
  • thanks for fixing that, was getting worried that me or my question was generating some hate for some unknown reason :)
    – Jimmery
    Commented Apr 26, 2016 at 14:47
  • I have the same problem, any news? :/
    – Iazel
    Commented Jun 10, 2016 at 10:05

1 Answer 1

1

I don't know if this is the best solution, but to get ridden of the fatal error in a clean way you can override the template with:

<?php
    // app/design/My/Theme/Magento_Checkout/templates/shipping/price.phtml

    if( $block->getShippingRate() )
        echo $block->getShippingPrice();
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.