admin管理员组文章数量:1134588
I wrote WC plugin (Integration). I want to create in my plugin a file with the following content:
require_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');
$WC_Some_Integration->simple_redirect($_POST);
And send POST requests to this file. But I don't know, how I can get instance of my integration, in other words, I don't know what I must will wrote instead WC_Some_Integration
(what to assign to this variable).
Tell me, pls, how do I do the above? Or is it the only way out to use static methods (functions)? It does not suit me too much.
I wrote WC plugin (Integration). I want to create in my plugin a file with the following content:
require_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');
$WC_Some_Integration->simple_redirect($_POST);
And send POST requests to this file. But I don't know, how I can get instance of my integration, in other words, I don't know what I must will wrote instead WC_Some_Integration
(what to assign to this variable).
Tell me, pls, how do I do the above? Or is it the only way out to use static methods (functions)? It does not suit me too much.
Share Improve this question asked Jul 25, 2017 at 9:18 Stanislav BelichenkoStanislav Belichenko 1951 silver badge9 bronze badges 4 |1 Answer
Reset to default 0You can get the integration instance using the integrations
object from the global WooCommerce
object:
WC()->integrations->integrations['id-of-the-integration']
where 'id-of-the-integration'
is the $id
field of the integration class, like 'maxmind_geolocation'.
With WC()
you can get most collections of instances attached to WooCommerce.
本文标签: How to get woocommerce integration instance
版权声明:本文标题:How to get woocommerce integration instance? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736806250a1953702.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
action
attrribute in the<form></form>
. – Stanislav Belichenko Commented Jul 25, 2017 at 9:51template_redirect
. In your callback, check the$_POST
variable for your form's field. If it exists, do your thing, otherwise do nothing. – Jacob Peattie Commented Jul 25, 2017 at 10:02