fetch only available packages
This commit is contained in:
@@ -17,6 +17,30 @@ class Wiaas_Package {
|
||||
require_once dirname( __FILE__ ) . '/package/wiaas-package-functions.php';
|
||||
|
||||
add_filter('woocommerce_rest_prepare_product_object', array(__CLASS__, 'transform_rest_package'), 999, 3);
|
||||
|
||||
add_filter('woocommerce_rest_product_object_query', array( __CLASS__, 'edit_product_query'), 10, 2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change product query to fetch only available packages (available status)
|
||||
* @param $query
|
||||
* @param $instance
|
||||
*/
|
||||
public static function edit_product_query($query, $request){
|
||||
if (isset($request['id'])){
|
||||
return;
|
||||
}
|
||||
|
||||
$query['tax_query'] = array(
|
||||
array(
|
||||
'taxonomy' => 'package_status',
|
||||
'field' => 'name',
|
||||
'terms' => Wiaas_Package_Status::AVAILABLE
|
||||
)
|
||||
);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user