Handle commercial lead prices

This commit is contained in:
Almira Krdzic
2018-10-11 07:12:53 +02:00
parent 84cd11f9c9
commit b53fbe5402
21 changed files with 1278 additions and 232 deletions

View File

@@ -138,8 +138,12 @@ class Wiaas_Cart {
// Retrieve package country
$country = Wiaas_Countries::get_package_country($package);
// Retrieve package price
$package_prices = Wiaas_Pricing::get_standard_package_customer_prices($package);
// TODO: Change this so commercial lead is sent via request
$customer_id = wiaas_get_current_user_organization_id();
$commercial_lead_id = array_keys(wiaas_get_commercial_leads())[0];
// Retrieve package price
$package_prices = Wiaas_Pricing::get_standard_package_customer_prices($package, $customer_id, $commercial_lead_id);
$selected_price_index = array_search($price_id, array_column($package_prices, 'id'));
// Initialize additional cart item data for wiaas packages
@@ -638,6 +642,10 @@ class Wiaas_Cart {
$addon_items_keys = array();
$option_items_keys = array();
// TODO: Change this so commercial lead is sent via request
$customer_id = wiaas_get_current_user_organization_id();
$commercial_lead_id = array_keys(wiaas_get_commercial_leads())[0];
// Try adding package addons to cart
foreach ($addons_ids as $addon_id) {
//Check if addon package exists
@@ -646,8 +654,13 @@ class Wiaas_Cart {
throw new Exception( __( 'Sorry, additional package does not exist.', 'wiaas' ) );
}
// Retrieve addon package price
$package_prices = Wiaas_Pricing::get_addon_package_customer_price($addon_package, $parent_item['data']);
// Retrieve addon package price
$package_prices = Wiaas_Pricing::get_addon_package_customer_price(
$addon_package,
$parent_item['data'],
$customer_id,
$commercial_lead_id
);
$selected_price_index = array_search($price_id, array_column($package_prices, 'id'));
// Initialize additional cart item data for wiaas addon packages
@@ -678,8 +691,12 @@ class Wiaas_Cart {
throw new Exception( __( 'Sorry, option package does not exist.', 'wiaas' ) );
}
// Retrieve option package price
$package_prices = Wiaas_Pricing::get_option_package_customer_price($option_package, $parent_item['data']);
// Retrieve option package price
$package_prices = Wiaas_Pricing::get_option_package_customer_price(
$option_package,
$parent_item['data'],
$customer_id,
$commercial_lead_id);
$selected_price_index = array_search($price_id, array_column($package_prices, 'id'));
// Retrieve option package group name