handle bundle product prices editor and prices summary
This commit is contained in:
@@ -49,30 +49,10 @@ class Wiaas_Package_Pricing {
|
||||
);
|
||||
|
||||
public static function init() {
|
||||
|
||||
add_filter('woocommerce_bundle_price_html', array( __CLASS__, 'get_package_price_html' ), 10, 2);
|
||||
|
||||
add_action('woocommerce_update_product', array(__CLASS__, 'on_product_update' ), 10, 1 );
|
||||
}
|
||||
|
||||
public static function get_package_price_html($price_html, $package) {
|
||||
$bundled_items = $package->get_bundled_items();
|
||||
|
||||
$recurring_price = 0;
|
||||
|
||||
foreach ($bundled_items as $bundled_item) {
|
||||
$product = $bundled_item->product;
|
||||
$product_price = Wiaas_Product_Pricing::get_product_price($product);
|
||||
if ($product_price['is_recurring']) {
|
||||
$recurring_price += $product_price['price'] * $bundled_item->get_quantity();
|
||||
}
|
||||
}
|
||||
|
||||
$price_html = 'Fixed: ' . $price_html . ' and ' . $recurring_price . ' / month';
|
||||
|
||||
return $price_html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get configuration for available payment types
|
||||
* @return array
|
||||
@@ -121,6 +101,8 @@ class Wiaas_Package_Pricing {
|
||||
$package->delete_meta_data( '_wiaas_pricing_rules' );
|
||||
}
|
||||
$package->save_meta_data();
|
||||
|
||||
self::_validate_package($package);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,6 +129,11 @@ class Wiaas_Package_Pricing {
|
||||
|
||||
private static function _get_package_prices($package) {
|
||||
$pricing_rules = $package->get_meta( '_wiaas_pricing_rules' );
|
||||
|
||||
if (empty($pricing_rules)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$commision = self::_get_package_pricing_commision($package);
|
||||
|
||||
$prices = array();
|
||||
|
||||
Reference in New Issue
Block a user