【发布时间】:2019-10-04 10:44:56
【问题描述】:
我在禁用 Woocommerce Force Sells 扩展程序中的功能时遇到问题。该函数在前端产品页面的购买按钮下添加了一些我想删除的文本。
我想我在 woocommerce-force-sells.php 文件中找到了有问题的函数:
/**
* Displays information of what linked products that will get added when current
* product is added to cart.
*/
public function show_force_sell_products() {
global $post;
$product_ids = $this->get_force_sell_ids( $post->ID, array( 'normal', 'synced' ) );
$titles = array();
// Make sure the products still exist and don't display duplicates.
foreach( array_values( array_unique( $product_ids ) ) as $key => $product_id ) {
$product = wc_get_product( $product_id );
if ( $product && $product->exists() && 'trash' !== $product->get_status() ) {
$titles[] = version_compare( WC_VERSION, '3.0', '>=' ) ? $product->get_title() : get_the_title( $product_id );
}
}
if ( ! empty( $titles ) ) {
echo '<div class="clear"></div>';
echo '<div class="wc-force-sells">';
echo '<p>' . __( 'This will also add the following products to your cart:', 'woocommerce-force-sells' ) . '</p>';
echo '<ul>';
foreach ( $titles as $title ) {
echo '<li>' . $title . '</li>';
}
echo '</ul></div>';
}
}
我查看了https://codex.wordpress.org/Function_Reference/remove_action,但我真的不知道如何在上面的代码中使用它。
提前非常感谢!
【问题讨论】:
-
remove_action只会在调用此方法本身时为您提供帮助,因为它首先被添加为作为一个动作/过滤器。 -
您不能使用删除操作,因为没有添加/使用任何操作。我相信做你想做的事情的唯一方法就是破解那个文件,代价是你永远不能自动更新它。
标签: php wordpress woocommerce