• Resolved zielsko

    (@zielsko)


    Hey!

    I have a problem with your plugin. I’ve made a custom plugin for user-favourites products that are stored in database for logged users, for not logged users they’re stored in woocommerce session. After activated your plugin WC()->session->get() and WC()->session->set() not working.

    I founded in your code that default woocommerce session handler is overridden by your class :/

    Can you help me to fix this issue?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Sébastien Dumont

    (@sebd86)

    Hey @zielsko

    Yes CoCart uses it’s own session handler as mentioned in the FAQ but these functions should still work as we extend the abstract session functions.

    Your issue is most likly that CoCart’s session handler has not loaded before you are calling the session functions.

    One way to check is to add an if condition should the session handler not be found.

    php
    if ( ! WC()->session instanceof CoCart_Session_Handler ) {
      return;
    }
    

    or

    php
    if ( ! class_exist( 'CoCart_Session_Handler' ) ) {
      return;
    }
    

    If false then you will need to load the session handler like so within your custom plugin.

    php
    include_once COCART_ABSPATH . 'includes/abstracts/abstract-cocart-session.php';
    include_once COCART_ABSPATH . 'includes/class-cocart-session-handler.php';
    

    > Please note that the location of these files will change in a major future release.

    You could also try doing a fresh session call once you have it loaded.

    php
    $handler = new CoCart_Session_Handler();
    $mycustomkeyname = $handler->get( 'my-custom-key-name' );
    

    or just stick to using default like you have done.

    Hope this has provided something helpful.

    Plugin Author Sébastien Dumont

    (@sebd86)

    Since there is no further activity on this topic I assume it’s resolved.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Woocommerce session not working with CoCart Lite’ is closed to new replies.