Variation Displayed in Cross-Sell and Upsells with Parent's Post Status set to 'draft' and 'pending review' (#17423)
* Fix - #17413 Update the `json_search_products` function to use the `wc_products_array_filter_visible` filter rather then the `wc_products_array_filter_editable` filter Added an additional if condition to the `is_visible` function to check if the product had a parent and it's post status * remove additional comment from code to keep it clean * Reverted filter * Updated the is_visable to check parent product post status using WooCommerce class methods * Updated the `if empty` check to make it is compatible with older versions of php * Removed the empty check infavor of just testing on the returned value Updated the way we are retrieving the partent product object * Moved the `$parent_product` variable assigment out of the if statement.
This commit is contained in:
parent
ef4c05a393
commit
abea378245
|
@ -1420,6 +1420,14 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
$visible = false;
|
||||
}
|
||||
|
||||
if ( $this->get_parent_id() ) {
|
||||
$parent_product = wc_get_product( $this->get_parent_id() );
|
||||
|
||||
if ( $parent_product && 'publish' !== $parent_product->get_status() ) {
|
||||
$visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && ! $this->is_in_stock() ) {
|
||||
$visible = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue