WC_Post_Data::variation_post_link( string $permalink, WP_Post $post )
Link to parent products when getting permalink for variation.
Description Description
Parameters Parameters
- $permalink
-
(Required) Permalink.
- $post
-
(Required) Post data.
Return Return
(string)
Source Source
File: includes/class-wc-post-data.php
public static function variation_post_link( $permalink, $post ) { if ( isset( $post->ID, $post->post_type ) && 'product_variation' === $post->post_type ) { $variation = wc_get_product( $post->ID ); if ( $variation && $variation->get_parent_id() ) { return $variation->get_permalink(); } } return $permalink; }