Support » Plugin: CoCart - Headless ecommerce » Cocart session handler broke woocommerce sessions

  • Resolved sid3ps

    (@sid3ps)


    Hi,

    I have Cocart v3.4.1 with Woocommerce 5.6, WCFM Ultimate, WCFMMP Membership plugins.

    When I am trying to register a vendor then I am getting “Email verification code invalid” error (even if I am entering correct code received in email). But, when I have added an item in my cart then I don’t get this error and vendor registration completed successfully.

    After debugging I found that the error is generated due to following file (Line #163), apparently the variable “$verification_code” always remains empty and hence fails this. FILE: wp-content/plugins/wc-multivendor-membership/controllers/wcfmvm-controller-memberships-registration.php

    The code getting failed is at line #158 ——> ” if( WC()->session && WC()->session->get( ‘wcfm_membership_email_verification_code’ ) ) ”

    I also checked a thread (at: https://wordpress.org/support/topic/not-compatible-with-custom-woocommerce-session-handlers/) which seems to explain incompatibility of your plugin with WC sessions.

    To verify this when I deactivated the CoCart plugin then the vendor registration process worked successfully.

    You are requested to provide a patch in order to address this issue as it has broken the main feature of vendor registration of my site.

    Thanks.

    The page I need help with: [log in to see the link]

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

    (@sebd86)

    Have you tried upgrading anything on a staging site to see if the problem is solved?

    Can you also provide a link to each of the WCFM plugins product page.

    Would appreciate it if you report the bug also to WCFM so that they are also in the loop and help solve this issue together.

    Thank you.

    Thread Starter sid3ps

    (@sid3ps)

    Hi,

    Thanks for getting back so quickly, I appreciate your help!

    Here are my answers to your 3 points.

    1) I have not tried upgrading anything yet. Do you want me to upgrade Cocart plugin? (My current version is v3.4.1 and latest available is v3.7.4)

    2) Here are the links to the WCFM pages:

    a) WCFM – WooCommerce Multivendor Marketplace => https://wclovers.com/knowledgebase_category/wcfm-marketplace/
    b) WCFM – WooCommerce Frontend Manager => https://wordpress.org/plugins/wc-frontend-manager/
    c) WCFM – WooCommerce Multivendor Membership => https://wclovers.com/knowledgebase/wcfm-membership/
    d) WCFM – WooCommerce Multivendor Marketplace – REST API => https://wordpress.org/plugins/wcfm-marketplace-rest-api/
    e) WCFM – WooCommerce Frontend Manager – Groups & Staffs => https://wclovers.com/knowledgebase/wcfm-groups-staffs/

    3) I have already raised the issue with WCFM => https://wclovers.com/ticket/email-verification-code-invalid-error/

    Thanks Again.

    Thread Starter sid3ps

    (@sid3ps)

    Hi,

    I followed this thread https://wordpress.org/support/topic/woocommerce-session-not-working-with-cocart-lite/ and tried to set specified code under “wp_loaded” action hook as below, but nothing worked. Any updates please?

    add_action( ‘wp_loaded’, ‘initiate_session_early’ );
    function initiate_session_early () {
    if ( ! WC()->session instanceof CoCart_Session_Handler ) {
    include_once WP_PLUGIN_DIR . ‘/cart-rest-api-for-woocommerce/includes/abstracts/abstract-cocart-session.php’;
    include_once WP_PLUGIN_DIR . ‘/abstract-cocart-session.php/includes/class-cocart-session-handler.php’;
    WC()->session = new CoCart_Session_Handler();
    }
    }

    Plugin Author Sébastien Dumont

    (@sebd86)

    1. Updates provided are for your benefit to insure compatibility with WooCommerce and WordPress so long as you are updating them as well.

    2. Thank you for sharing the links. I will create a fresh setup so I can work on this. Currently working on finishing a big update for CoCart so it will be scheduled after.

    3. That’s good to know. As it’s behind a login I won’t be able to read the ticket so please do share what they respond when they do.

    As for your code snippet. It’s wrong. You can’t initiate the session handler that early because WooCommerce hasn’t even loaded yet.

    I don’t know if this will help but I don’t think the issue has anything to do with loading the session handler in time.

    add_action( 'woocommerce_loaded', function() {
    	if ( ! WC()->session instanceof CoCart_Session_Handler ) {
    		include_once WP_PLUGIN_DIR . ‘/cart-rest-api-for-woocommerce/includes/abstracts/abstract-cocart-session.php';
    		include_once WP_PLUGIN_DIR . ‘/cart-rest-api-for-woocommerce/includes/class-cocart-session-handler.php';
    		WC()->session = new CoCart_Session_Handler();
    	}
    }
    Plugin Author Sébastien Dumont

    (@sebd86)

    Just setup a new local install but can’t fully activate and setup WCFM – WooCommerce Frontend Manager. There appear to be many issues with this plugin. See screenshot.

    Can you tell me what version of PHP you are running on? I’m on 8.0

    Thread Starter sid3ps

    (@sid3ps)

    Hi Sébastien,

    Thanks for taking so much pain in giving insights.
    The screenshot is not mush readable so, please tell me which plugin/tool you used to extract these error I will try in my installation because, I can’t see any such issues here. I am using Query Monitor Plugin (https://wordpress.org/plugins/query-monitor/) to view errors and warnings.

    I am running it on PHP v7.4.25 and when I tried on v8.0 then it did not run properly. (WP v5.6.5)

    When I temporarily deactivate CoCart plugin then woocommerce session cookie gets created the vendor registration works fine. However, with CoCart active only the Cocart session cookie created till I add an item in cart through Add To Cart button on /shop page.

    Thanks.

    Plugin Author Sébastien Dumont

    (@sebd86)

    I use LocalWP as my tool and also using Query Montior.

    I changed to PHP v7.4 and the errors disappeared.

    I have looked at the plugin code base and it looks like they are adding data to the session before CoCart filters the session handler to use it’s own and because our session handler uses it’s own database table, the session data that was added before is not there so it’s not able to verify it when needed.

    If the membership plugin simply changes it’s hooks to use woocommerce_loaded instead for the functions that are adding the session data then it should work fine with CoCart.

    woocommerce_loaded is the best action hook to be using to make sure the plugin is fully compatible with WooCommerce and is loaded first with all it’s core properties including the session handler.

    This will then allow all 3 plugins to load in the right order.

    You can see here that CoCart does nothing until WooCommerce has loaded first using the woocommerce_loaded hook.

    I hope this helps the developers of the membership plugin.

    Plugin Author Sébastien Dumont

    (@sebd86)

    Any updates on on this @wclovers @sid3ps

    Plugin Author Sébastien Dumont

    (@sebd86)

    Closing issue since there hasn’t been any further updates.

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.