admin管理员组文章数量:1208155
I'm currently developing a Wordpress Multisite website. I need to have the mainsites payment methods on all subsites (Any user should be able to create their own subsite, thats why I can't do this manually).
On this stackoverflow post they show how to get the payment gateways, but I wasn't able to find any information on how to modify those variables programatically. I have also found this post on how to unset any payment method, but again, they don't say how to set a new payment method or how to modify existing payment methods.
I've tryed this code with no success:
add_filter('woocommerce_available_payment_gateways', 'filter_gateways', 1);
function filter_gateways($gateways){
global $woocommerce;
switch_to_blog( 1 );
$wc_gateways = new WC_Payment_Gateways();
$mainsite_gateways = $wc_gateways->get_available_payment_gateways();
restore_current_blog();
return $mainsite_gateways;
}
Also tried this just to be sure that it didn't work and nothing happened
add_filter('woocommerce_available_payment_gateways', 'filter_gateways', 1, 100);
function filter_gateways($gateways){
global $woocommerce;
switch_to_blog( 1 );
$mainsite_gateways = WC()->payment_gateways->get_available_payment_gateways(); //modified this
restore_current_blog();
return $mainsite_gateways;
}
I have a similar issue with emails. I need the mainsite email address to handle all woocommerce emails using the mainsite email templates...
本文标签: multisiteHow to configure Woocommerce Payment Methods programmatically
版权声明:本文标题:multisite - How to configure Woocommerce Payment Methods programmatically? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738694826a2107313.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论