Support » Plugin: Table Rate Shipping Method for WooCommerce by Flexible Shipping » Not compatible with custom WooCommerce session handlers

  • This plugin does not support the use of custom WooCommerce session handlers.

    I have users wanting to use this plugin with my plugin CoCart which uses a custom session handler but there is an issue with this file in your plugin that is preventing compatibility.

    TypeError: Argument 2 passed to WPDesk\FS\TableRate\FreeShipping\FreeShippingNotice::__construct() must be an instance of WC_Session, instance of CoCart_Session_Handler given, called in C:\Users\Sebastien\Local Sites\cocart-dev\app\public\wp-content\plugins\flexible-shipping\classes\class-flexible-shipping-plugin.php on line 501 in file C:\Users\Sebastien\Local Sites\cocart-dev\app\public\wp-content\plugins\flexible-shipping\src\WPDesk\FS\TableRate\FreeShipping\FreeShippingNotice.php on line 45

    I don’t know why the class names are specified in the __construct() but if WC_Session is removed like so it works fine.

    public function __construct( WC_Cart $cart, $session, WP $wp ) {

    Please can you provide a patch asap.

    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor grola



    is there any reason why CoCart_Session_Handler does not extend WC_Session?

    Best regards

    Thread Starter Sébastien Dumont


    Needed more control over the abstract class to support the new features in CoCart so guest customers were fully supported.

    Plugin Contributor grola


    We will removed strong typing in next releases, but there should be instance of WC_Session or WC_Session_Handler there:

    Thread Starter Sébastien Dumont


    I thank you for your quick response and look forward to seeing the next update. I will feature your plugin as a suggestion plugin within CoCart.

    Plugin Contributor grola


    We will remove strong typing, but please note that WooCommerce expects that session handlers extends WC_Session so your solution can stop working at any time when WooCommerce or any other plugin checks for cohesion.
    Similar situation has already happened with WC_Logger_Interface and will happen in future as WooCommerce slowly integrates more and more of good practices.

    Please read this WooCommerce recommendation:

    To build a custom session handler, your class should extend WC_Session which is WooCommerce’s abstract session handler class.

    Plugin Support Marta Pawlonka


    Hello @sebd86,

    We released yesterday the new version of our plugin with removed strong typing.

    Best regards,



    Hi @martapaw

    Thank you for the update. I have compared the code between the last two versions of Flexible Shipping and it doesn’t look like you removed strong typing, in fact it looks like you added a little more which is fine.

    From what I have evaluated it looks like it was related to the notices that you adjusted which before triggered the strong typing checks to be strong for CoCart to handle.

    Now that the notices have changed the strong typing is ignored and doesn’t crash the site with CoCart.

    I have also made improvements to CoCart to be more compatible with other WooCommerce plugins in general which will release soon so thank you for your support for the current release of CoCart.

    Much appreciated.



Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Not compatible with custom WooCommerce session handlers’ is closed to new replies.