use only customer specific prices if set

This commit is contained in:
Almira Krdzic
2018-10-15 14:59:57 +02:00
parent f14d35b1aa
commit b7ac53d195
3 changed files with 212 additions and 31 deletions

View File

@@ -46,28 +46,29 @@ class Wiaas_Package_API {
$query['tax_query'] = array();
}
// Moved package status handling here
// Retrieve only packages with available package status
$query['tax_query'][] = array(
'taxonomy' => 'package_status',
'field' => 'name',
'terms' => Wiaas_Package_Status::AVAILABLE
);
$commercial_lead_id = absint($request['cl_id']);
$customer_id = wiaas_get_current_user_organization_id();
$pay_types = array_keys(Wiaas_Package_Pricing::get_available_pay_types());
$price_serch_terms = array();
$price_search_terms = array();
foreach ($pay_types as $pay_type) {
$price_serch_terms[] = '_' . $commercial_lead_id . '_' . $pay_type . '_default';
$price_serch_terms[] = '_' . $commercial_lead_id . '_' . $pay_type . '_customer_' . $customer_id;
$price_search_terms[] = '_' . $commercial_lead_id . '_' . $pay_type . '_default';
$price_search_terms[] = '_' . $commercial_lead_id . '_' . $pay_type . '_customer_' . $customer_id;
}
$args['tax_query'][] = array(
'taxonomy' => '_wiaas_shop_prices',
'terms' => $price_serch_terms,
'terms' => $price_search_terms,
'field' => 'slug'
);