The WooCommerce API Manager PHP Library for Plugins and Themes is a PHP Library that can be dropped into a plugin and theme for API Key authentication and software updates with the WooCommerce API Manager.
Using the PHP Library
The WooCommerce API Manager PHP Library for Plugins and Themes with the code needed to connect a plugin or theme to the PHP Library after it has been dropped into the plugin or theme. The second argument in the code block example below is for the product_id. If the product_id is left blank the customer enters the product_id, if the product_id is hard coded, then the customer will not need to enter the product_id.
Once the product is activated, a notice is displayed for the customer to activate the plugin or theme.
On the activation screen, if the product_id was hard coded then the customer only needs to enter the API Key. If this is a variable product variation, each version of the software will require a separate file with the correctly hard coded product_id matching the customer’s product purchase. This is why not hard coding the product_id is the preferred method for variable product variations as shown in the next example.
On the activation screen, if the product_id was not hard coded then the customer needs to enter both the API Key and the product_id. This is the preferred method for variable product variations.
After the plugin is activated, the number of activations remaining is displayed.
Orders that have API Key activations will display a key in the orders list.
On the order screen, the activations will be listed.
When an update is available the update details will be displayed. Plugins and themes can be updated automatically just like any other plugins and themes.
Click on the view version details link will display the details you have provided and configured just like any other plugins and themes.
After the plugin is deactivated, the activations remaining is displayed.
Using Postman for Testing
A preconfigured Postman .json file collection template is included to make it easy to test the API functions. Server URL, and keys/values, will need to be modified specific to your product and server.
Software Update File Hosting
The file used for software updates can be hosted on the local server, Amazon S3, or from any remote URL. The file download URL is wrapped in a secure URL that expires after the expire time you set.
2019.09.04 - version 2.7.1
* Tweak: Changed the Plugin header file name to match directory name.
2019.08.21 - version 2.7
* New: https://www.getpostman.com/postman collection template file added. The preconfigured .json file can be imported into Postman to make it easy to test the API functions. Server URL, and keys/values will need to be modified specific to your product and server.
2019.08.07 - version 2.7
* New: Major update for API Manager version 2.1 and greater.
2019.07.26 - version 2.6
* New: Replaced 'request' API Key for actions with 'wc_am_action' to match new query string key in API Manager 2.1 API.
2019.05.09 - version 2.5.2
* Fix: $this->plugin_or_theme moved up so $this->identifier can evaluate $this->plugin_or_theme value.
2019.05.09 - version 2.5.1
* Tweak: Update get_api_key_status() to use new API data format.
* Tweak: Get $this->identifier value based on whether plugin or theme value has been set for the object.
* Tweak: activation() method modified to prevent instance being generated more than once.
* Tweak: Other minor code changes.
* Tweak: $_REQUEST[ 'option_page' ] check to fix PHP notice as per https://github.com/toddlahman/api-manager-php-library/pull/95. Credit: https://github.com/maheshwaghmare
* New: Add filter wc_am_client_uninstall_disable as per https://github.com/toddlahman/api-manager-php-library/pull/96. Credit: https://github.com/maheshwaghmare
* New: Add filter wc_am_client_inactive_notice_override as per https://github.com/toddlahman/api-manager-php-library/pull/96. Credit: https://github.com/maheshwaghmare
2019.3.25 - version 2.5
* Fix: Leave wp_safe_remote_post() sslverify to default value of on.
2019.3.25 - version 2.4
* Tweak: get_api_key_status() can query live or saved.
* Tweak: Set wp_safe_remote_post() values timeout to 15 and sslverify to off.
2019.3.14 - version 2.3
* New: When $product_id is an empty string in data sent to the library, a Product ID form field will be displayed to allow the customer to enter the product_id manually.
2019.1.7 - version 2.2
* Fix: Moved $this->wc_am_activated_key = $this->data_key . '_activated'; above is_admin() since it would fail for frontend checks.
2019.1.7 - version 2.1
* Added get_api_key_status() method.
2018.9.8 - version 2.0
* Compatibility with WooCommerce API Manager 2.x.
2016.12.31 - version 1.1
* Fix: Moved activation notice into if is_admin() evaluation block to eliminate a PHP warning.
2016.06.17 - version 1.0
* First release of the vastly simplified, and combined, plugin and theme drop-in library.