Use woocommerce API inside functions.php
-
Hello
I have a site using woocommerce and other pluginsOne of the plugins has an API related to Woocommerce (to use the plugin API you have to use the woocommerce API, they just added new routes)
I want to call one of these routes in my functions.php file in a woocommerce hookI tried to do this :
$autoloader = WP_CONTENT_DIR . '/plugins/woocommerce/vendor/autoload.php'; if ( is_readable( $autoloader ) ) { require_once($autoloader); } function action() { $order = wc_get_order($this_get_id); $woocommerce = new \Automattic\WooCommerce\Client( 'domains', 'credentials', 'credentials', [ 'wp_api' => true, 'version' => 'wc/v3' ] ); $test = $woocommerce->get('customers/989'); var_dump($test); die(); }; // add the action add_action( 'woocommercehook', 'action', 10, 3 );
But I have this error Uncaught Error: Class ‘Automattic\WooCommerce\Client’ not found
How to use Automattic\WooCommerce\Client inside functions.php please?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Use woocommerce API inside functions.php’ is closed to new replies.