【发布时间】:2016-08-26 11:18:57
【问题描述】:
我正在使用带有 WooCommerce 2.6.4 和 Smart Coupon 3.1.2 插件的 Wordpress 4.6。 我想将结帐页面顶部的“可用优惠券”部分移至底部。
在插件文件中,我检测到了这种结构以及需要更改的操作。
我需要将其更改为“woocommerce_after_checkout_form”,但我不知道如何从 functions.php 文件中覆盖它。
我已经尝试直接从插件中更改它,它可以像我一样工作,但我们都知道编辑插件的行为是错误的方法。
任何帮助和文档都会很有帮助。
class WC_Smart_Coupons {
...
public function __construct() {
...
add_action( 'woocommerce_before_checkout_form', array( $this, 'show_available_coupons_before_checkout_form' ), 11 );
...
}
}
...
function initialize_smart_coupons() {
$GLOBALS['woocommerce_smart_coupon'] = new WC_Smart_Coupons();
}
add_action( 'plugins_loaded', 'initialize_smart_coupons' );
【问题讨论】:
-
这是我迄今为止通过检查文档所做的,但它不起作用:
function remove_plugin_actions(){ global $WC_Smart_Coupons; remove_action( 'woocommerce_before_checkout_form', array( $WC_Smart_Coupons, 'show_available_coupons_before_checkout_form' ), 11 ); } add_action('woocommerce_before_checkout_form','remove_plugin_actions');
标签: php wordpress function woocommerce overriding