Skip to content
Snippets Groups Projects
Commit e1a64478 authored by Jonathan Sacksick's avatar Jonathan Sacksick Committed by Ryan Szrama
Browse files

Issue #1518084 by jsacksick, bojanz: add a computed property to price fields...

Issue #1518084 by jsacksick, bojanz: add a computed property to price fields called amount_decimal that allows comparisons against the currency specific decimal value for a price field amount; currently read only.
parent 7752123c
No related branches found
Tags 6.x-1.3
No related merge requests found
......@@ -796,6 +796,13 @@ function commerce_price_field_data_property_info($name = NULL) {
'getter callback' => 'entity_property_verbatim_get',
'setter callback' => 'entity_property_verbatim_set',
),
'amount_decimal' => array(
'label' => t('Amount (decimal)'),
'description' => !empty($name) ? t('Amount value of field %name (as a decimal)', array('%name' => $name)) : '',
'type' => 'decimal',
'getter callback' => 'commerce_price_amount_decimal_get',
'computed' => TRUE,
),
'currency_code' => array(
'label' => t('Currency'),
'description' => !empty($name) ? t('Currency code of field %name', array('%name' => $name)) : '',
......@@ -814,6 +821,13 @@ function commerce_price_field_data_property_info($name = NULL) {
);
}
/**
* Property getter callback returing the amount (as a decimal).
*/
function commerce_price_amount_decimal_get($data, array $options, $name, $type, $info) {
return commerce_currency_amount_to_decimal($data['amount'], $data['currency_code']);
}
/**
* Returns the data array of a single value price field from a wrapped entity,
* using an optional default value if the entity does not have data in the field.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment