• 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 Author grola

    (@grola)

    Hi,

    is there any reason why CoCart_Session_Handler does not extend WC_Session?

    Best regards
    Grzegorz

    Thread Starter Sébastien Dumont

    (@sebd86)

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

    Plugin Author grola

    (@grola)

    We will removed strong typing in next releases, but there should be instance of WC_Session or WC_Session_Handler there: https://github.com/woocommerce/woocommerce/blob/19bdc1c35b06fd1ad41f94bd91d5047474a59c3c/includes/class-woocommerce.php#L51

    Thread Starter Sébastien Dumont

    (@sebd86)

    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 Author grola

    (@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: https://github.com/woocommerce/wc-php-session-handler

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

    Plugin Support Marta Borówka

    (@martapaw)

    Hello @sebd86,

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

    Best regards,
    Marta

    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.

    regards,

    Sébastien.

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