当前位置: 首页>>代码示例>>PHP>>正文


PHP GFCommon::to_number方法代码示例

本文整理汇总了PHP中GFCommon::to_number方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::to_number方法的具体用法?PHP GFCommon::to_number怎么用?PHP GFCommon::to_number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GFCommon的用法示例。


在下文中一共展示了GFCommon::to_number方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_pending_referral

 /**
  * Add pending referral
  *
  * @access public
  * @uses GFFormsModel::get_lead()
  * @uses GFCommon::get_product_fields()
  * @uses GFCommon::to_number()
  *
  * @param array $entry
  * @param array $form
  */
 public function add_pending_referral($entry, $form)
 {
     if (!$this->was_referred() || !rgar($form, 'affwp_allow_referrals')) {
         return;
     }
     // Do some craziness to determine the price (this should be easy but is not)
     $desc = isset($form['title']) ? $form['title'] : '';
     $entry = GFFormsModel::get_lead($entry['id']);
     $products = GFCommon::get_product_fields($form, $entry);
     $total = 0;
     foreach ($products['products'] as $key => $product) {
         $price = GFCommon::to_number($product['price']);
         if (is_array(rgar($product, 'options'))) {
             $count = sizeof($product['options']);
             $index = 1;
             foreach ($product['options'] as $option) {
                 $price += GFCommon::to_number($option['price']);
             }
         }
         $subtotal = floatval($product['quantity']) * $price;
         $total += $subtotal;
     }
     // replace description if there are products
     if (!empty($products['products'])) {
         $product_names = wp_list_pluck($products['products'], 'name');
         $desc = implode(', ', $product_names);
     }
     $total += floatval($products['shipping']['price']);
     $referral_total = $this->calculate_referral_amount($total, $entry['id']);
     $this->insert_pending_referral($referral_total, $entry['id'], $desc);
     if (empty($total)) {
         $this->mark_referral_complete($entry, array());
     }
 }
开发者ID:nerrad,项目名称:AffiliateWP,代码行数:45,代码来源:class-gravityforms.php

示例2: add_pending_referral

 /**
  * Add pending referral
  *
  * @access public
  * @uses GFFormsModel::get_lead()
  * @uses GFCommon::get_product_fields()
  * @uses GFCommon::to_number()
  *
  * @param array $entry
  * @param array $form
  */
 public function add_pending_referral($entry, $form)
 {
     if ($this->was_referred()) {
         // Do some craziness to determine the price (this should be easy but is not)
         $desc = '';
         $entry = GFFormsModel::get_lead($entry['id']);
         $products = GFCommon::get_product_fields($form, $entry);
         $total = 0;
         foreach ($products['products'] as $key => $product) {
             $desc .= $product['name'];
             if ($key + 1 < count($products)) {
                 $description .= ', ';
             }
             $price = GFCommon::to_number($product['price']);
             if (is_array(rgar($product, 'options'))) {
                 $count = sizeof($product['options']);
                 $index = 1;
                 foreach ($product['options'] as $option) {
                     $price += GFCommon::to_number($option['price']);
                 }
             }
             $subtotal = floatval($product['quantity']) * $price;
             $total += $subtotal;
         }
         $total += floatval($products['shipping']['price']);
         $referral_total = $this->calculate_referral_amount($total, $entry['id']);
         $this->insert_pending_referral($referral_total, $entry['id'], $desc);
     }
 }
开发者ID:jwondrusch,项目名称:AffiliateWP,代码行数:40,代码来源:class-gravityforms.php

示例3: validate

 public function validate($value, $form)
 {
     if (!class_exists('RGCurrency')) {
         require_once GFCommon::get_base_path() . '/currency.php';
     }
     $price = GFCommon::to_number($value);
     if (!rgblank($value) && ($price === false || $price < 0)) {
         $this->failed_validation = true;
         $this->validation_message = empty($this->errorMessage) ? __('Please enter a valid amount.', 'gravityforms') : $this->errorMessage;
     }
 }
开发者ID:renztoygwapo,项目名称:lincoln,代码行数:11,代码来源:class-gf-field-price.php

示例4: affiliates_gravity_forms_products_amount

 /**
  * Product amount filter - this will deduct any field named 'Tax' (case-insensitive) from the $amount.
  * 
  * @param float $amount
  * @param array $products
  * @param array $entry
  * @return float
  */
 public static function affiliates_gravity_forms_products_amount($amount, $products, $entry)
 {
     if (isset($products['products']) && is_array($products['products'])) {
         foreach ($products['products'] as $id => $values) {
             if (isset($values['name']) && isset($values['price']) && in_array(strtolower($values['name']), array_map('strtolower', self::$tax_fields))) {
                 if (class_exists('GFCommon') && method_exists('GFCommon', 'to_number')) {
                     $tax = GFCommon::to_number($values['price']);
                     $amount -= floatval($tax);
                 }
             }
         }
     }
     return $amount;
 }
开发者ID:itthinx,项目名称:affiliates-gravityforms-tax-example,代码行数:22,代码来源:affiliates-gravityforms-tax-example.php

示例5: get_value_merge_tag

 public function get_value_merge_tag($value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format)
 {
     $format_numeric = $modifier == 'price';
     $value = $format_numeric ? GFCommon::to_number($value) : GFCommon::to_money($value);
     return GFCommon::format_variable_value($value, $url_encode, $esc_html, $format);
 }
开发者ID:healthcommcore,项目名称:osnap,代码行数:6,代码来源:class-gf-field-total.php

示例6: sanitize_settings

 public function sanitize_settings()
 {
     parent::sanitize_settings();
     $price_number = GFCommon::to_number($this->basePrice);
     $this->basePrice = GFCommon::to_money($price_number);
 }
开发者ID:nomadicmarc,项目名称:goodbay,代码行数:6,代码来源:class-gf-field-singleshipping.php

示例7: get_conditional_logic

 private static function get_conditional_logic($form, $field_values = array())
 {
     $logics = "";
     $dependents = "";
     $fields_with_logic = array();
     $default_values = array();
     foreach ($form["fields"] as $field) {
         //use section's logic if one exists
         $section = RGFormsModel::get_section($form, $field["id"]);
         $section_logic = !empty($section) ? rgar($section, "conditionalLogic") : null;
         $field_logic = $field["type"] != "page" ? RGForms::get("conditionalLogic", $field) : null;
         //page break conditional logic will be handled during the next button click
         $next_button_logic = isset($field["nextButton"]) && isset($field["nextButton"]["conditionalLogic"]) ? $field["nextButton"]["conditionalLogic"] : null;
         if (!empty($field_logic) || !empty($next_button_logic)) {
             $field_section_logic = array("field" => $field_logic, "nextButton" => $next_button_logic, "section" => $section_logic);
             $logics .= $field["id"] . ": " . GFCommon::json_encode($field_section_logic) . ",";
             $fields_with_logic[] = $field["id"];
             $peers = $field["type"] == "section" ? GFCommon::get_section_fields($form, $field["id"]) : array($field);
             $peer_ids = array();
             foreach ($peers as $peer) {
                 $peer_ids[] = $peer["id"];
             }
             $dependents .= $field["id"] . ": " . GFCommon::json_encode($peer_ids) . ",";
         }
         //-- Saving default values so that they can be restored when toggling conditional logic ---
         $field_val = "";
         $input_type = RGFormsModel::get_input_type($field);
         //get parameter value if pre-populate is enabled
         if (rgar($field, "allowsPrepopulate")) {
             if (is_array(rgar($field, "inputs"))) {
                 $field_val = array();
                 foreach ($field["inputs"] as $input) {
                     $field_val["input_{$input["id"]}"] = RGFormsModel::get_parameter_value(rgar($input, "name"), $field, $field_values);
                 }
             } else {
                 if ($input_type == "time") {
                     $parameter_val = RGFormsModel::get_parameter_value(rgar($field, "inputName"), $field, $field_values);
                     if (!empty($parameter_val) && preg_match('/^(\\d*):(\\d*) ?(.*)$/', $parameter_val, $matches)) {
                         $field_val = array();
                         $field_val[] = esc_attr($matches[1]);
                         //hour
                         $field_val[] = esc_attr($matches[2]);
                         //minute
                         $field_val[] = rgar($matches, 3);
                         //am or pm
                     }
                 } else {
                     if ($input_type == "list") {
                         $parameter_val = RGFormsModel::get_parameter_value(rgar($field, "inputName"), $field, $field_values);
                         $field_val = explode(",", str_replace("|", ",", $parameter_val));
                     } else {
                         $field_val = RGFormsModel::get_parameter_value(rgar($field, "inputName"), $field, $field_values);
                     }
                 }
             }
         }
         //use default value if pre-populated value is empty
         $field_val = self::default_if_empty($field, $field_val);
         if (is_array(rgar($field, "choices")) && $input_type != "list") {
             //radio buttons start at 0 and checkboxes start at 1
             $choice_index = $input_type == "radio" ? 0 : 1;
             foreach ($field["choices"] as $choice) {
                 if (rgar($choice, "isSelected") && $input_type == "select") {
                     $val = isset($choice["price"]) ? $choice["value"] . "|" . GFCommon::to_number($choice["price"]) : $choice["value"];
                     $default_values[$field["id"]] = $val;
                 } else {
                     if (rgar($choice, "isSelected")) {
                         if (!isset($default_values[$field["id"]])) {
                             $default_values[$field["id"]] = array();
                         }
                         $default_values[$field["id"]][] = "choice_{$field["id"]}_{$choice_index}";
                     }
                 }
                 $choice_index++;
             }
         } else {
             if (!empty($field_val)) {
                 $default_values[$field["id"]] = $field_val;
             }
         }
     }
     $button_conditional_script = "";
     //adding form button conditional logic if enabled
     if (isset($form["button"]["conditionalLogic"])) {
         $logics .= "0: " . GFCommon::json_encode(array("field" => $form["button"]["conditionalLogic"], "section" => null)) . ",";
         $dependents .= "0: " . GFCommon::json_encode(array(0)) . ",";
         $fields_with_logic[] = 0;
         $button_conditional_script = "jQuery('#gform_{$form['id']}').submit(" . "function(event, isButtonPress){" . "    var visibleButton = jQuery('.gform_next_button:visible, .gform_button:visible, .gform_image_button:visible');" . "    return visibleButton.length > 0 || isButtonPress == true;" . "}" . ");";
     }
     if (!empty($logics)) {
         $logics = substr($logics, 0, strlen($logics) - 1);
     }
     //removing last comma;
     if (!empty($dependents)) {
         $dependents = substr($dependents, 0, strlen($dependents) - 1);
     }
     //removing last comma;
     $animation = rgar($form, "enableAnimation") ? "1" : "0";
     global $wp_locale;
     $number_format = $wp_locale->number_format['decimal_point'] == "," ? "decimal_comma" : "decimal_dot";
//.........这里部分代码省略.........
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:101,代码来源:form_display.php

示例8: sanitize_settings_choices

 /**
  * Sanitize the field choices property.
  *
  * @param array|null $choices The field choices property.
  *
  * @return array|null
  */
 public function sanitize_settings_choices($choices = null)
 {
     if (is_null($choices)) {
         $choices =& $this->choices;
     }
     if (!is_array($choices)) {
         return $choices;
     }
     $allowed_tags = wp_kses_allowed_html('post');
     foreach ($choices as &$choice) {
         if (isset($choice['isSelected'])) {
             $choice['isSelected'] = (bool) $choice['isSelected'];
         }
         if (isset($choice['price']) && !empty($choice['price'])) {
             $price_number = GFCommon::to_number($choice['price']);
             $choice['price'] = GFCommon::to_money($price_number);
         }
         if (isset($choice['text'])) {
             $choice['text'] = wp_kses($choice['text'], $allowed_tags);
         }
         if (isset($choice['value'])) {
             $choice['value'] = wp_kses($choice['value'], $allowed_tags);
         }
     }
     return $choices;
 }
开发者ID:timk85,项目名称:DIT,代码行数:33,代码来源:class-gf-field.php

示例9: get_paypal_payment_amount

 public static function get_paypal_payment_amount($form, $entry, $paypal_config)
 {
     //TODO: need to support old "paypal_config" format as well as new format when delayed payment suported feed addons are released
     $products = GFCommon::get_product_fields($form, $entry, true);
     $recurring_field = rgar($paypal_config['meta'], 'recurring_amount_field');
     $total = 0;
     foreach ($products['products'] as $id => $product) {
         if ($paypal_config['meta']['type'] != 'subscription' || $recurring_field == $id || $recurring_field == 'all') {
             $price = GFCommon::to_number($product['price']);
             if (is_array(rgar($product, 'options'))) {
                 foreach ($product['options'] as $option) {
                     $price += GFCommon::to_number($option['price']);
                 }
             }
             $total += $price * $product['quantity'];
         }
     }
     if ($recurring_field == 'all' && !empty($products['shipping']['price'])) {
         $total += floatval($products['shipping']['price']);
     }
     return $total;
 }
开发者ID:sbayer55,项目名称:The-Road-Gallery,代码行数:22,代码来源:class-gf-feed-addon.php

示例10: push_event

 /**
  * Push the Google Analytics Event!
  * 
  * @since 1.4.0
  * @param array $event Gravity Forms event object
  * @param array $form Gravity Forms form object
  */
 private function push_event($entry, $form, $ga_event_data)
 {
     // Init tracking object
     $this->tracking = new \Racecore\GATracking\GATracking(apply_filters('gform_ua_id', $this->ua_id, $form), true);
     $event = new \Racecore\GATracking\Tracking\Event();
     // Set some defaults
     $event->setDocumentLocation($ga_event_data['document_location']);
     $event->setDocumentTitle($ga_event_data['document_title']);
     // Set our event object variables
     $event->setEventCategory(apply_filters('gform_event_category', $ga_event_data['gaEventCategory'], $form));
     $event->setEventAction(apply_filters('gform_event_action', $ga_event_data['gaEventAction'], $form));
     $event->setEventLabel(apply_filters('gform_event_label', $ga_event_data['gaEventLabel'], $form));
     if ($event_value = apply_filters('gform_event_value', $ga_event_data['gaEventValue'], $form)) {
         // Event value must be a valid float!
         $event_value = GFCommon::to_number($event_value);
         $event->setEventValue($event_value);
     }
     // Pppp Push it!
     $this->tracking->addTracking($event);
     try {
         $this->tracking->send();
     } catch (Exception $e) {
         error_log($e->getMessage() . ' in ' . get_class($e));
     }
 }
开发者ID:resoundcreative-dev,项目名称:wordpress-gravity-forms-event-tracking,代码行数:32,代码来源:class-gravity-forms-event-tracking-feed.php

示例11: sanitize_settings_choices

 /**
  * Sanitize the field choices property.
  *
  * @param array|null $choices The field choices property.
  *
  * @return array|null
  */
 public function sanitize_settings_choices($choices = null)
 {
     if (is_null($choices)) {
         $choices =& $this->choices;
     }
     if (!is_array($choices)) {
         return $choices;
     }
     foreach ($choices as &$choice) {
         if (isset($choice['isSelected'])) {
             $choice['isSelected'] = (bool) $choice['isSelected'];
         }
         if (isset($choice['price']) && !empty($choice['price'])) {
             $price_number = GFCommon::to_number($choice['price']);
             $choice['price'] = GFCommon::to_money($price_number);
         }
         if (isset($choice['text'])) {
             $choice['text'] = $this->maybe_wp_kses($choice['text']);
         }
         if (isset($choice['value'])) {
             // Strip scripts but don't encode
             $allowed_protocols = wp_allowed_protocols();
             $choice['value'] = wp_kses_no_null($choice['value'], array('slash_zero' => 'keep'));
             $choice['value'] = wp_kses_hook($choice['value'], 'post', $allowed_protocols);
             $choice['value'] = wp_kses_split($choice['value'], 'post', $allowed_protocols);
         }
     }
     return $choices;
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:36,代码来源:class-gf-field.php

示例12: get_payment_amount

 public static function get_payment_amount($form, $entry, $paypal_config)
 {
     $products = GFCommon::get_product_fields($form, $entry, true);
     $recurring_field = rgar($paypal_config["meta"], "recurring_amount_field");
     $total = 0;
     foreach ($products["products"] as $id => $product) {
         if ($paypal_config["meta"]["type"] != "subscription" || $recurring_field == $id || $recurring_field == "all") {
             $price = GFCommon::to_number($product["price"]);
             if (is_array(rgar($product, "options"))) {
                 foreach ($product["options"] as $option) {
                     $price += GFCommon::to_number($option["price"]);
                 }
             }
             $total += $price * $product['quantity'];
         }
     }
     if ($recurring_field == "all" && !empty($products["shipping"]["price"])) {
         $total += floatval($products["shipping"]["price"]);
     }
     return $total;
 }
开发者ID:simgooder,项目名称:blaycation,代码行数:21,代码来源:mailchimp.php

示例13: clean_number

 public function clean_number($value)
 {
     if ($this->numberFormat == 'currency') {
         return GFCommon::to_number($value);
     } else {
         return GFCommon::clean_number($value, $this->numberFormat);
     }
 }
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:8,代码来源:class-gf-field-number.php

示例14: get_calculation_value

 public static function get_calculation_value($field_id, $form, $lead)
 {
     $filters = array('price', 'value', '');
     $value = false;
     foreach ($filters as $filter) {
         if (is_numeric($value)) {
             //value found, exit loop
             break;
         }
         $value = GFCommon::to_number(GFCommon::replace_variables("{:{$field_id}:{$filter}}", $form, $lead));
     }
     if (!$value || !is_numeric($value)) {
         GFCommon::log_debug("GFCommon::get_calculation_value(): No value or non-numeric value available for field #{$field_id}. Returning zero instead.");
         $value = 0;
     }
     return $value;
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:17,代码来源:common.php

示例15: get_select_choices

 public static function get_select_choices($field, $value = '', $support_placeholders = true)
 {
     $choices = '';
     if (RG_CURRENT_VIEW == 'entry' && empty($value) && empty($field->placeholder)) {
         $choices .= "<option value=''></option>";
     }
     if (is_array($field->choices)) {
         if ($support_placeholders && !empty($field->placeholder)) {
             $selected = empty($value) ? "selected='selected'" : '';
             $choices .= sprintf("<option value='' %s class='gf_placeholder'>%s</option>", $selected, esc_html($field->placeholder));
         }
         foreach ($field->choices as $choice) {
             //needed for users upgrading from 1.0
             $field_value = !empty($choice['value']) || $field->enableChoiceValue || $field->type == 'post_category' ? $choice['value'] : $choice['text'];
             if ($field->enablePrice) {
                 $price = rgempty('price', $choice) ? 0 : GFCommon::to_number(rgar($choice, 'price'));
                 $field_value .= '|' . $price;
             }
             if (!isset($_GET['gf_token']) && empty($_POST) && rgblank($value) && RG_CURRENT_VIEW != 'entry') {
                 $selected = rgar($choice, 'isSelected') ? "selected='selected'" : '';
             } else {
                 if (is_array($value)) {
                     $is_match = false;
                     foreach ($value as $item) {
                         if (RGFormsModel::choice_value_match($field, $choice, $item)) {
                             $is_match = true;
                             break;
                         }
                     }
                     $selected = $is_match ? "selected='selected'" : '';
                 } else {
                     $selected = RGFormsModel::choice_value_match($field, $choice, $value) ? "selected='selected'" : '';
                 }
             }
             $choice_markup = sprintf("<option value='%s' %s>%s</option>", esc_attr($field_value), $selected, esc_html($choice['text']));
             $choices .= gf_apply_filters(array('gform_field_choice_markup_pre_render', $field->formId, $field->id), $choice_markup, $choice, $field, $value);
         }
     }
     return $choices;
 }
开发者ID:Friends-School-Atlanta,项目名称:Deployable-WordPress,代码行数:40,代码来源:common.php


注:本文中的GFCommon::to_number方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。