Support » Plugin: WooCommerce » REST API Client Class Not Found

  • Resolved hozayrayz

    (@hozayrayz)


    I keep getting this issue when I try to connect to my woocommerce API.

    Fatal error: Uncaught Error: Class ‘Automattic\WooCommerce\Client’ not found in /home/woorayzist/public_html/wp-content/themes/Divi-child/functions.php:258 Stack trace: #0 /home/woorayzist/public_html/wp-includes/class-wp-hook.php(287): woo_new_product_tab(Array) #1 /home/woorayzist/public_html/wp-includes/plugin.php(206): WP_Hook->apply_filters(Array, Array) #2 /home/woorayzist/public_html/wp-content/themes/Divi/includes/builder/module/helpers/WooCommerceModules.php(904): apply_filters(‘woocommerce_pro…’, Array) #3 /home/woorayzist/public_html/wp-includes/class-wp-hook.php(287): ET_Builder_Module_Helper_Woocommerce_Modules::get_woo_default_tabs_options(‘include_tabs’) #4 /home/woorayzist/public_html/wp-includes/plugin.php(206): WP_Hook->apply_filters(‘include_tabs’, Array) #5 /home/woorayzist/public_html/wp-content/themes/Divi/includes/builder/class-et-builder-element.php(2280): apply_filters(‘et_builder_get_…’, ‘include_tabs’) #6 /home/woorayzist/public_html/wp-content/themes/Divi/includes/builder/class-et-builder-e in /home/woorayzist/public_html/wp-content/themes/Divi-child/functions.php on line 258

    Whereas my composer folder is located in wp-content. I also call in the files as:

    require_once WP_CONTENT_DIR . '/composer/vendor/autoload.php';
    use Automattic\WooCommerce\Client;
    use Automattic\WooCommerce\HttpClient\HttpClientException;

    My permalinks are set as: /store/%product_cat%/ for products.

    My code to connect is:

    $woocommerce = new Client(
            'https://woo.rayzist.com/store',
            'ck_###',
            'cs_###',
            [
                'wp_api' => true,
                'version' => 'wc/v3',
                'query_string_auth' => true # Force Basic Authentication as query string true and using under HTTPS
            ]
        ); 
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Thread Starter hozayrayz

    (@hozayrayz)

    Heyo! So I found out the solution to it.
    It turns out that I didn’t install the package correctly using composer. So I had to install it and now it works!

    I was getting the issue that xx bytes is trying to be allocated. Although I had the value of -1 in all of my memory limit on cPanel and WHM, it still didn’t work. So, I had to write
    php -d memory_limit=-1 composer.phar automattic/woocommerce
    Which had it work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘REST API Client Class Not Found’ is closed to new replies.