• Resolved Christian

    (@nwachuku)


    I just want to use this opportunity to thank you for this amazing plugin!!!!

    But I get this error when I try to add a Facebook synced product to the cart. Everything was working fine until I updated to the latest version 1.10.0 of Facebook for WooCommerce

    It seems there is a conflict with the Facebook for WooCommerce plugin Version 1.10.0

    I have also submitted a ticket to the developer of Facebook for WooCommerce developers to see if it’s coming from their end.

    Fatal error:
    Uncaught ArgumentCountError: Too few arguments to function WC_Facebookcommerce_EventsTracker::set_last_product_added_to_cart_upon_redirect(),
    1 passed in [ABSOLUTE_PATH]/wp-includes/class-wp-hook.php on line 288 and exactly 2 expected in
    [WEBSITE_ABSOLUTE_PATH]/wp-content/plugins/facebook-for-woocommerce/facebook-commerce-events-tracker.php:346
    Stack trace: #0 [ABSOLUTE_PATH]/wp-includes/class-wp-hook.php(288): WC_Facebookcommerce_EventsTracker->set_last_product_added_to_cart_upon_redirect(”)
    #1 [ABSOLUTE_PATH]/wp-includes/plugin.php(206): WP_Hook->apply_filters(”, Array)
    #2 [ABSOLUTE_PATH]/wp-content/plugins/woo-poly-integration/src/Hyyan/WPI/Cart.php(406): apply_filters(‘woocommerce_add…’, ”)
    #3 [ABSOLUTE_PATH]/wp-includes/class-wp-hook.php in [ABSOLUTE_PATH]/wp-content/plugins/facebook-for-woocommerce/facebook-commerce-events-tracker.php on line 346

    WORDPRESS VERSION: 5.3.2
    WooCommerce version: 3.9.3
    PHP version: 7.3.15
    Hyyan WooCommerce Polylang Integration: Version 1.4.3

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey team behind Hyyan WooCommerce Polylang Integration,

    Tamara here from the SkyVerge team. We have recently taken over the development of Facebook for WooCommerce.

    I downloaded your plugin and tracked down what’s this causing this fatal error and it looks like a change is required within your plugin. The fix would require your team to update your plugin to ensure two arguments are passed to the woocommerce_add_to_cart_redirect filter. This would mean that line 406 of file src/Hyyan/WPI/Cart.php within your code should read something like:

    
    if ($url = apply_filters('woocommerce_add_to_cart_redirect', $url, null)) {
    

    For a bit of background, WooCommerce defines the woocommerce_add_to_cart_redirect filter with two arguments like so:

    
    apply_filters( 'woocommerce_add_to_cart_redirect', $url, $adding_to_cart )
    

    where $url is the add-to-cart URL and $adding_to_cart is the product that is being added to the cart (or null when no product is being added to the cart). The WooCommerce code has been using 2 arguments for this filter since WooCommerce 3.6.0.

    Your code applies this filter with only one argument like so:

    
    apply_filters('woocommerce_add_to_cart_redirect', $url )
    

    When the Facebook for WooCommerces plugin hooks into the woocommerce_add_to_cart_redirect filter it requires both of these arguments which results in WordPress outputting the error the user experienced:

    
    Fatal error: Uncaught ArgumentCountError: Too few arguments to function WC_Facebookcommerce_EventsTracker::set_last_product_added_to_cart_upon_redirect(), 1 passed
    

    The Facebook for WooCommerce plugin is used by over 600,000 sites so I expect that we will receive more reports with this conflict. Would you please let me know if you are able to make this change in your plugin and when your users can expect the update to be available?

    Thanks,
    Tamara ??
    SkyVerge

    Plugin Contributor jomo

    (@jonathanmoorebcsorg)

    @skyverge thanks for your comments, for this type of technical discussion please post on:
    https://github.com/hyyan/woo-poly-integration/issues
    (or pull request even better)

    Plugin Contributor jomo

    (@jonathanmoorebcsorg)

    as per discussion on:
    https://github.com/hyyan/woo-poly-integration/issues/495
    we will remove the offending code.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Error When I add the product to the cart.’ is closed to new replies.