在Woocommerce中,如何在其他插件代码中使用旧版API? p>
< p>目前,最新的Woocommerce API版本已加载,因此在使用WC_API_Server时,它使用最新版本,而不是旧版本(需要版本 3 strong>): p>
我无法更改Woocommerce插件及其版本 - 理想情况下,我应该做的就是 在我开发的第三方插件中。 p>
在woocommerce文件夹中: p>
注意 em >:Woocommerce是wordpress的插件 - 而API就在这个插件中。 (即使最新的API使用wordpress'API本身) p>
更新 em>:与通常不同,这里我们需要使用wordpress实例的API - 我们会 喜欢扩展API中的一些woocomerce方法。 因此,我们不希望使用 em> API,而是提供 em>扩展的API。 strong> p>
div>
调用类LMB_API_Server扩展WC_API_Server
code> pre>
包括\
api \
* manyPHPfileofcurrentVersion *
...
legacy \
v1 \
v2
n v3 \
* oldPHPfilesOfAPInneded *
code> pre>
In Woocommerce, how to use a legacy API version within another plugin code ?
Currently, the newest API version of Woocommerce is loaded, thus when using WC_API_Server, it uses the latest one, and not a legacy one (version 3 needed) :
calling the class LMB_API_Server extends WC_API_Server
I cannot change the Woocommerce plugin, nor its version - ideally, all I should be able to do is within the third party plugin that I develop.
In the woocommerce folder :
includes\
api\
*manyPHPfileofcurrentVersion*
...
legacy\
v1\
v2\
v3\
*oldPHPfilesOfAPInneded*
Note : Woocommerce is a plugin for wordpress - and the API is inside this plugin. (even if the latest API uses wordpress' API itself)
Update : Unlike usual, here we need to use the API from the wordpress instance perspective - we would like to extend some of woocomerce methods located in the API. We therefore do not want to consume the API, but to provide an extended one.