Created
September 24, 2023 05:41
-
-
Save codersaiful/f08172001410cf04da88234482dbbd71 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( !function_exists( 'wpt_variation_table_args' ) ){ | |
/** | |
* Args manipulation for variable product | |
* | |
* @param array $args WPT default args array | |
* @return array | |
*/ | |
function wpt_variation_table_args( $args ){ | |
$_ID = get_the_ID(); | |
if( empty( $_ID ) || ! is_product() ) return $args; | |
$product_includes = []; | |
$this_post_variable = new WC_Product_Variable( $_ID ); | |
$available_post_includes = $this_post_variable->get_children(); | |
if( isset( $available_post_includes ) && is_array($available_post_includes) && count( $available_post_includes ) > 0 ){ | |
foreach ($available_post_includes as $pperItem){ | |
$product_includes[$pperItem] = $pperItem; | |
} | |
} | |
$args['post_type'] = array( 'product', 'product_variation' ); | |
$args['post__in'] = $product_includes; | |
unset( $args['tax_query'] ); | |
// unset( $args['meta_query'] ); //stock kaj korchilona bole off korechi. notun somossay paile abar dekhote hobe: 8.0.8.1 | |
return $args; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment