handle bundle product prices editor and prices summary
This commit is contained in:
@@ -48,4 +48,80 @@ function wiaas_get_recurrent_price_mortage($principal_amount, $pay_period, $marg
|
||||
function wiaas_get_price_margin($fixed_price, $principal_amount, $total_cost) {
|
||||
$total_gain = $fixed_price + $principal_amount;
|
||||
return $total_gain - $total_cost;
|
||||
}
|
||||
|
||||
function wiaas_get_package_hardware_procurement_cost($package) {
|
||||
$bundled_items = $package->get_bundled_items();
|
||||
$total_cost = 0;
|
||||
|
||||
foreach ($bundled_items as $bundled_item) {
|
||||
$product = $bundled_item->product;
|
||||
|
||||
if (Wiaas_Product_Category::get_category($product) === 'hardware') {
|
||||
$total_cost += Wiaas_Pricing::get_product_total_cost($product) * $bundled_item->get_quantity();
|
||||
}
|
||||
}
|
||||
|
||||
return $total_cost;
|
||||
}
|
||||
|
||||
function wiaas_get_package_software_procurement_cost($package) {
|
||||
$bundled_items = $package->get_bundled_items();
|
||||
$total_cost = 0;
|
||||
|
||||
foreach ($bundled_items as $bundled_item) {
|
||||
if (Wiaas_Product_Category::is_hardware($bundled_item->product)) {
|
||||
$total_cost += Wiaas_Pricing::get_product_total_cost($bundled_item->product) * $bundled_item->get_quantity();
|
||||
}
|
||||
}
|
||||
|
||||
return $total_cost;
|
||||
}
|
||||
|
||||
function wiaas_get_package_installation_procurement_cost($package) {
|
||||
$bundled_items = $package->get_bundled_items();
|
||||
$total_cost = 0;
|
||||
|
||||
foreach ($bundled_items as $bundled_item) {
|
||||
if (Wiaas_Product_Category::is_installation($bundled_item->product)) {
|
||||
$installation_cost = Wiaas_Pricing::get_product_total_cost($bundled_item->product);
|
||||
$total_cost = $total_cost > $installation_cost ? $total_cost : $installation_cost;
|
||||
}
|
||||
}
|
||||
|
||||
return $total_cost;
|
||||
}
|
||||
|
||||
function wiaas_get_package_one_time_services_procurement_cost($package) {
|
||||
$bundled_items = $package->get_bundled_items();
|
||||
$total_cost = 0;
|
||||
|
||||
foreach ($bundled_items as $bundled_item) {
|
||||
if (Wiaas_Product_Category::is_service($bundled_item->product)) {
|
||||
|
||||
$price = Wiaas_Product_Pricing::get_product_price($bundled_item->product);
|
||||
if (! $price['is_recurring']) {
|
||||
$total_cost += Wiaas_Pricing::get_product_total_cost($bundled_item->product) * $bundled_item->get_quantity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $total_cost;
|
||||
}
|
||||
|
||||
function wiaas_get_package_recurring_services_procurement_cost($package) {
|
||||
$bundled_items = $package->get_bundled_items();
|
||||
$total_cost = 0;
|
||||
|
||||
foreach ($bundled_items as $bundled_item) {
|
||||
if (Wiaas_Product_Category::is_service($bundled_item->product)) {
|
||||
|
||||
$price = Wiaas_Product_Pricing::get_product_price($bundled_item->product);
|
||||
if ( $price['is_recurring']) {
|
||||
$total_cost += $price['price'] * $bundled_item->get_quantity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $total_cost;
|
||||
}
|
||||
Reference in New Issue
Block a user