How to Use Plugin Builder?
Plugin Builder
About API2Cart Plugins
The API2Cart plugins are intended to make it easier to add stores based on open-source shopping carts like Magento, WooCommerce, PrestaShop. They automatically install a connection bridge to the root folder of the store thus excluding the inconveniences that the process usually entails.
In particular, using the plugin resolves a couple of issues for both software vendors and their clients:
- Vendors do not need to ask store owners for their FTP credentials.
- Store owners avoid the inconvenience of begrudgingly sharing their access information.
- The security of the FTP credentials remains absolute as they do not leave the private admin surrounding the store.
- Either the vendor or the store owner does not have to grope for the right folder to insert the bridge.
How the API2Cart plugins work
- A store owner installs the plugin.
- They press Connect and the system automatically generates a store key.
- The store owner passes the key to the software vendor.
- The vendor system identifies the user account and sends an account.cart.add API call to API2Cart.
- The store is connected.
You can build your own plugins and automate the process of connecting stores using the Plugin Builder
Plugin installation guides
Installing API2Cart plugins on your customers’ stores is easy as 1-2-3.
These video guides show few simple steps store owners do to get the
plugin installed.
PrestaShop Plugin Installation
OpenCart Plugin Installation
WooCommerce Plugin Installation
Magento 1 Plugin Installation
WooCommerce plugin for Webhooks for Basket Updates
This plugin was developed for API2Cart users to improve integration with WooCommerce.
WooCommerce shopping cart doesn’t provide the ability to get webhook notifications for basket updates, and API2Cart developed this functionality itself.
With this plugin, you can get webhook notifications for shopping cart updates, for example when the new item is added or deleted.
N.B. This plugin works only if WooCommerce plugin is installed and active.
About Plugin Builder
The Plugin Builder allows you to build the Bridge Connector plugin, which is used to connect the store to API2Cart, for different shopping platforms. The following platforms are currently supported:
- Magento 2
- Opencart 2.x - 4.x
- PrestaShop
- Shopware 6
- WooCommerce
If the “Plugin builder” feature is available in the account plan, the plugin can be customized to your needs, for example, you can specify the plugin's name, company, description, and logo. Also, you can enable or disable encryption on the bridge, configure the callback URL, etc. When this feature is unavailable in the plan, the values for the plugin are set by default.
Also, the possibility of asymmetric data encryption has been added to the Plugin Builder. Data is encrypted using the OAEP (Optimal Asymmetric Encryption Padding) protocol, which provides a reliable level of security and resistance to attacks. More details.
Callback URL and Public Key allow you to generate a plugin. After installing it and clicking the “Connect” button, a webhook will be sent to the URL that was specified in the Callback URL field with encrypted store credentials that can be used when adding it to APICart. Namely: store_url, store_key, store_root, bridge_url. Data is encrypted with an RSA key. You can insert your own public key or generate a pair of 2048-bit keys.
The data sent to the callback is encrypted according to the following principle:
- Encoding the data array into a JSON string
- Division of the received string into parts of one length (depending on the length of the generated key)
- Encoding the parts with the public key
- Combining the encoded parts into one string and converting it to base64 format
- Sending the base64-encoded string to the callback
The callback will receive a webhook with encrypted data in the "data" field.
The x-webhook-cart-id and x-webhook-timestamp headers are also available.
To decrypt the data, you need to perform actions with the received data in the reverse direction:
- Decode from base64
- Division of the string into equal parts (depending on the key length)
- Decrypt the received parts using the private key
- Combine the obtained decrypted parts into a single JSON string
Here's an example of PHP code:
As a result, you will receive data that can be used in the account.cart.add method to add a store.
Some fields in the Plugin Builder are validated, and an error will be displayed if incorrect data is entered. Also, next to each field is a hint with a brief description of what this field is for.
After successfully building the plugin, the downloaded archive with the plugin can be installed on the page of the selected platform.
Important Nuances for WooCommerce
When using the Plugin Builder for WooCommerce, there are specific nuances you should consider to avoid conflicts and ensure stable integration.
Why The WooCommerce Plugin Works Differently
Unlike other platforms where the generated plugin simply uploads the bridge file (bridge.php) to the store's server, WooCommerce follows a different approach. Due to WooCommerce Marketplace policies, plugins are not allowed to upload external files to the site.
Therefore, for WooCommerce, the bridge file is embedded directly into the plugin generated via the Plugin Builder.
Risk of Conflict: Incompatibility with the Standard Bridge
A potential issue occurs if both of the following are present on the same WooCommerce store:
- The standard bridge file uploaded manually (e.g., via FTP or SSH).
- A Bridge Connector plugin generated in the Plugin Builder without custom branding (using default settings).
What Happens When Both Are Installed
A default-generated plugin (such as the public api2cart-bridge-connector) uses the same internal class names, constants, and prefixes as the standard bridge file.
When both versions are loaded, WordPress attempts to initialize them simultaneously, resulting in PHP fatal errors such as “Cannot redeclare class…” or “Cannot redeclare constant…”. As a result, the API2Cart integration stops working completely.
How To Properly Build A WooCommerce Plugin
To prevent conflicts with other plugins or the standard bridge, always generate your WooCommerce plugin with unique identifiers.
- Set a custom Plugin Name
- Set a unique Plugin Slug
- Set a distinct Prefix
The Plugin Builder will automatically apply your chosen prefix to all internal bridge classes and constants, ensuring your plugin’s code remains isolated from other installations.
Conclusion
Never install the standard bridge and the api2cart-bridge-connector plugin simultaneously on the same WooCommerce site.
When building your own branded WooCommerce plugin, always define a unique slug and prefix in the Plugin Builder to guarantee compatibility and prevent code conflicts.