I was wondering how to override the default product bundles permalink function. I use the plugin Woocommerce Product bundles for this.
The default function from “class-wc-bundled-item” is this:
/**
* Item permalink.
*
* @since 5.5.0
*
* @return string
*/
public function get_permalink() {
/**
* 'woocommerce_bundled_item_permalink' filter.
*
* @param string $permalink
* @param WC_Bundled_Item $this
*/
return apply_filters( 'woocommerce_bundled_item_permalink', $this->is_visible() && $this->product->is_visible() ? $this->product->get_permalink() : '', $this );
}
I want to override this function in my functions.php file. Unfortunately it returns the permalink of the product bundle and not from the linked (underlaying) product.
This is the code i tried:
add_filter( 'woocommerce_bundled_item_permalink', 'get_bundle_product_permalink' );
function get_bundle_product_permalink() {
return get_permalink();
}
What am i doing wrong?
2
Answers
Something like this?
Try this code snippet to bypass is_visble check