Fatal error: Declaration of {ShippingClassName}::calculate() must be compatible with that of ShippingModule::calculate()

Summary

A fatal error occurs in the storefront that prevents the entire website from being usable resulting in a blank white page (white screen) on all pages.

Symptoms

After upgrading or installing a shipping module, a fatal error occurs causing the website to become a blank white page on all pages. The fatal error can usually be found in the server’s error logs. The error will be one of the error messages described below.

Error Message(s)

Fatal error: Declaration of AusPost::calculate() must be compatible with that of ShippingModule::calculate()
Fatal error: Declaration of CanadaPost::calculate() must be compatible with that of ShippingModule::calculate()
Fatal error: Declaration of FedExRates::calculate() must be compatible with that of ShippingModule::calculate()
Fatal error: Declaration of ShipWire::calculate() must be compatible with that of ShippingModule::calculate()
Fatal error: Declaration of UPSServiceRates::calculate() must be compatible with that of ShippingModule::calculate()
Fatal error: Declaration of USPSRates::calculate() must be compatible with that of ShippingModule::calculate()

Impacts

Shopp Version: 1.2.3

Known Causes

A Shopp version 1.2.3 installation has add-ons that have been updated to be compatible with Shopp version 1.2.4.

When Shopp 1.2.4 was released, all of the shipping addons were updated in order to be compatible with a change in core to make Shopp work properly under PHP 5.4. The change in the core Shopp plugin necessitated a change in all of the shipping modules. As a result, the latest, most up-to-date shipping addons will not work with Shopp 1.2.3.

Here is a list of the latest compatible shipping addons for Shopp 1.2.3:

Shipping Addon Version
AusPost 1.2.2
CanadaPost 1.2
FedEx Rates 1.2.1
ShipWire 1.2.2
UPS Service Rates 1.2.1
USPS Rates 1.2.3

Solution

The best solution is to either update Shopp to the most recent release or at least to Shopp version 1.2.4.

Manually Fixing Shopp 1.2.3

If updating Shopp, for whatever reason is not possible you will need to edit several files in order to make sure Shopp and all the available shipping modules are compatible.

Step 1: Update the ShippingModule Interface

Edit the shopp/core/model/Shipping.php file and change line 242 to include an & before the $options parameter:

public function calculate(&$options,$Order);

Step 2: Update Core Shipping Calculators

Edit each of the shipping calculators found under shopp/shipping/core/ and change their calculate() method declaration to include the & before the $options parameter:

function calculate (&$options,$Order) {

Step 3: Update Installed Shipping Add-ons

Edit each of the installed shipping add-ons found under shopp/shipping/ and change their calculate() method declaration to include the & before the $options parameter:

function calculate (&$options,$Order) {

See Also

Fatal error: Declaration of {ShippingClassName}::calculate() must be compatible with that of ShippingModule::calculate()
  • 1.00 / 5 5
  1. Avatar of Ross Varner

    I updated the Shopp plugin to 1.2.5 and the fatal error is still occuring. Any additional thoughts?

    April 4th   #

  2. Avatar of owlandfox

    I had this error on an installation where no shipping modules are installed.

    September 24th   #

  3. Avatar of owlandfox

    FIXED.
    I had this error on a Shopp that was current version 1.2.9, with no shipping modules installed.

    Step 1 above was already fixed as it describes, but step 2 wasn’t, so I made the change specified. e.g. line 28


    function calculate (&$options,$Order) {

    I think the description provided has a typo and doesn’t provide the file name, which should be shopp/shipping/core/FlatRates.php

    September 24th   #

  4. Avatar of Joshua

    Note that I had to change private $sizes to protected $sizes in the shipping modules to work with 1.3 beta

    December 3rd   #

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.

Skip to toolbar