本文整理汇总了PHP中PDF_Common::is_currency_decimal_dot方法的典型用法代码示例。如果您正苦于以下问题:PHP PDF_Common::is_currency_decimal_dot方法的具体用法?PHP PDF_Common::is_currency_decimal_dot怎么用?PHP PDF_Common::is_currency_decimal_dot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDF_Common
的用法示例。
在下文中一共展示了PDF_Common::is_currency_decimal_dot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_product_array
private static function get_product_array($form, $lead, $has_product_fields, $form_array)
{
$currency_type = method_exists('GFCommon', 'is_currency_decimal_dot') ? GFCommon::is_currency_decimal_dot() : PDF_Common::is_currency_decimal_dot();
$currency_format = $currency_type ? 'decimal_dot' : 'decimal_comma';
if ($has_product_fields) {
$products = GFCommon::get_product_fields($form, $lead, true);
/* check that there are actual product fields */
if (sizeof($products['products']) > 0) {
/*
* Set up our variables
*/
$total = 0;
$subtotal = 0;
foreach ($products['products'] as $id => $product) {
$price = GFCommon::to_number($product['price']);
/* add all options to total price */
if (is_array(rgar($product, 'options'))) {
foreach ($product['options'] as $option) {
$price += GFCommon::to_number($option['price']);
}
}
/* calculate subtotal */
$subtotal = floatval($product['quantity']) * $price;
$total += $subtotal;
/*
* Check if we should include options
*/
$options = isset($product['options']) ? $product['options'] : array();
/*
* Add formated price for each product option
*/
foreach ($options as &$o) {
if (is_numeric($o['price'])) {
$o['price_formatted'] = GFCommon::format_number($o['price'], 'currency');
}
}
/*
* Store product in $form_array array
*/
$form_array['products'][$id] = array('name' => esc_html($product['name']), 'price' => esc_html($product['price']), 'price_unformatted' => GFCommon::clean_number($product['price'], $currency_format), 'options' => $options, 'quantity' => $product['quantity'], 'subtotal' => $subtotal, 'subtotal_formatted' => GFCommon::format_number($subtotal, 'currency'));
}
/* Increment total */
$total += floatval($products['shipping']['price']);
$subtotal = $total - floatval($products['shipping']['price']);
/* add totals to form data */
$form_array['products_totals'] = array('subtotal' => $subtotal, 'shipping' => $products['shipping']['price'], 'total' => $total, 'shipping_formatted' => GFCommon::format_number($products['shipping']['price'], 'currency'), 'subtotal_formatted' => GFCommon::format_number($subtotal, 'currency'), 'total_formatted' => GFCommon::format_number($total, 'currency'));
}
}
return $form_array;
}