Php 如何在WooCommerce捆绑商品功能中使用底层产品permalink

Php 如何在WooCommerce捆绑商品功能中使用底层产品permalink,php,wordpress,function,woocommerce,hook-woocommerce,Php,Wordpress,Function,Woocommerce,Hook Woocommerce,我想知道如何覆盖默认的product bundles permalink函数。我使用插件Woocommerce产品包来实现这一点 “class wc bundled item”的默认功能如下: 我想在functions.php文件中重写此函数。不幸的是,它返回产品捆绑包的永久链接,而不是从链接的(底层)产品返回 这是我尝试的代码: add_filter( 'woocommerce_bundled_item_permalink', 'get_bundle_product_permalink' );

我想知道如何覆盖默认的product bundles permalink函数。我使用插件Woocommerce产品包来实现这一点

“class wc bundled item”的默认功能如下:

我想在functions.php文件中重写此函数。不幸的是,它返回产品捆绑包的永久链接,而不是从链接的(底层)产品返回

这是我尝试的代码:

add_filter( 'woocommerce_bundled_item_permalink', 'get_bundle_product_permalink' );
function get_bundle_product_permalink() {
    return get_permalink();
}
我做错了什么

add_filter( 'woocommerce_product_is_visible', '__return_true' );
请尝试此代码段以绕过“是否可见”检查

请尝试此代码段以绕过是否可见检查

/* Set the visibility function */
function filter_woocommerce_product_is_visible( $visible, $this_get_id ) {
    return apply_filters( 'woocommerce_bundled_item_permalink', '__return_true' );
}; 
add_filter( 'woocommerce_product_is_visible', 'filter_woocommerce_product_is_visible', 10, 2 ); 
像这样的

/* Set the visibility function */
function filter_woocommerce_product_is_visible( $visible, $this_get_id ) {
    return apply_filters( 'woocommerce_bundled_item_permalink', '__return_true' );
}; 
add_filter( 'woocommerce_product_is_visible', 'filter_woocommerce_product_is_visible', 10, 2 ); 

最后,我想绕过apply过滤器中的“is_visible”函数。我希望链接始终可见。最后,我希望从应用过滤器中绕过“is_visible”函数。我希望链接始终可见。不幸的是,这并不能解决问题。它在永久链接后返回主捆绑产品的永久链接,编号为“1”。@Justus移除您的挂钩,仅使用我刚才做的。my functions.php文件中唯一有效的规则是您的代码段。;-)它仍然会在永久链接后返回主捆绑产品的永久链接,编号为“1”。@Justus更新hook。不幸的是,这并不能解决问题。它在永久链接后返回主捆绑产品的永久链接,编号为“1”。@Justus移除您的挂钩,仅使用我刚才做的。my functions.php文件中唯一有效的规则是您的代码段。;-)它仍然在永久链接后返回主捆绑产品的永久链接,编号为“1”。@Justus更新挂钩