We've got some experience on individual product calculators based on Drupal Commerce. Today I'd like to share a bit of that with you: Individual line item price calculation based on rules.
We're for example using these methods in custom calculations for product.
I was searching for the API methods to use for a period of time and these are they:
rules_invoke_event('commerce_product_calculate_sell_price', $line_item);
commerce_line_item_rebase_unit_price($line_item);
// Line item total = unit price because quantity is always 1 in our case
$line_item->commerce_total = $line_item->commerce_unit_price;
$line_item_total_price_array = commerce_line_items_total(array($line_item));
// Format the price
$price_formatted = commerce_currency_format($line_item_total_price_array['amount'], $line_item_total_price_array['currency_code'], $line_item)
?>
Furthermore you will need line item price calculation rules and a bit more stuff to make the magic happen :)