本文整理汇总了PHP中GFCommon::get_product_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::get_product_fields方法的具体用法?PHP GFCommon::get_product_fields怎么用?PHP GFCommon::get_product_fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFCommon
的用法示例。
在下文中一共展示了GFCommon::get_product_fields方法的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()) {
// 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);
}
}
示例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() || !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());
}
}
示例3: entry_detail_grid
//.........这里部分代码省略.........
$value[$field->id . '.3'] = '0';
}
}
}
$input_type = $field->get_input_type();
if ($input_type == 'hiddenproduct') {
$display_value = $value[$field->id . '.2'];
} else {
$display_value = GFCommon::get_lead_field_display($field, $value, $entry['currency']);
}
$display_value = apply_filters('gform_entry_field_value', $display_value, $field, $entry, $form);
if ($display_empty_fields || !empty($display_value) || $display_value === '0') {
$count++;
$is_last = $count >= $field_count && !$has_product_fields ? true : false;
$last_row = $is_last ? ' lastrow' : '';
$display_value = empty($display_value) && $display_value !== '0' ? ' ' : $display_value;
$content = '
<tr>
<td colspan="2" class="entry-view-field-name">' . esc_html(rgar($field, 'label')) . '</td>
</tr>
<tr>
<td colspan="2" class="entry-view-field-value' . $last_row . '">' . $display_value . '</td>
</tr>';
$content = apply_filters('gform_field_content', $content, $field, $value, $entry['id'], $form['id']);
$content = apply_filters('gravityflow_field_content', $content, $field, $value, $entry['id'], $form['id']);
echo $content;
}
}
break;
}
}
$products = array();
if ($has_product_fields) {
$products = GFCommon::get_product_fields($form, $entry);
if (!empty($products['products'])) {
?>
<tr>
<td colspan="2" class="entry-view-field-name"><?php
echo apply_filters("gform_order_label_{$form_id}", apply_filters('gform_order_label', __('Order', 'gravityflow'), $form_id), $form_id);
?>
</td>
</tr>
<tr>
<td colspan="2" class="entry-view-field-value lastrow">
<table class="entry-products" cellspacing="0" width="97%">
<colgroup>
<col class="entry-products-col1" />
<col class="entry-products-col2" />
<col class="entry-products-col3" />
<col class="entry-products-col4" />
</colgroup>
<thead>
<th scope="col"><?php
echo apply_filters("gform_product_{$form_id}", apply_filters('gform_product', __('Product', 'gravityflow'), $form_id), $form_id);
?>
</th>
<th scope="col" class="textcenter"><?php
echo esc_html(apply_filters("gform_product_qty_{$form_id}", apply_filters('gform_product_qty', __('Qty', 'gravityflow'), $form_id), $form_id));
?>
</th>
<th scope="col"><?php
echo esc_html(apply_filters("gform_product_unitprice_{$form_id}", apply_filters('gform_product_unitprice', __('Unit Price', 'gravityflow'), $form_id), $form_id));
?>
</th>
<th scope="col"><?php
echo esc_html(apply_filters("gform_product_price_{$form_id}", apply_filters('gform_product_price', __('Price', 'gravityflow'), $form_id), $form_id));
示例4: refresh_product_cache
public static function refresh_product_cache($form, $lead, $use_choice_text = false, $use_admin_label = false)
{
$cache_options = array(array(false, false), array(false, true), array(true, false), array(true, true));
foreach ($form['fields'] as $field) {
/* @var $field GF_Field */
if ($field->has_calculation()) {
//deleting field value cache for calculated fields
$cache_key = 'GFFormsModel::get_lead_field_value_' . $lead['id'] . '_' . $field->id;
GFCache::delete($cache_key);
}
}
foreach ($cache_options as $cache_option) {
list($use_choice_text, $use_admin_label) = $cache_option;
if (gform_get_meta(rgar($lead, 'id'), "gform_product_info_{$use_choice_text}_{$use_admin_label}")) {
gform_delete_meta(rgar($lead, 'id'), "gform_product_info_{$use_choice_text}_{$use_admin_label}");
GFCommon::get_product_fields($form, $lead, $use_choice_text, $use_admin_label);
}
}
}
示例5: lead_detail_grid
public static function lead_detail_grid($form, $lead, $allow_display_empty_fields = false)
{
$form_id = $form["id"];
$display_empty_fields = false;
if ($allow_display_empty_fields) {
$display_empty_fields = rgget("gf_display_empty_fields", $_COOKIE);
}
?>
<table cellspacing="0" class="widefat fixed entry-detail-view">
<thead>
<tr>
<th id="details">
<?php
echo $form["title"];
?>
: <?php
_e("Entry # ", "gravityforms");
?>
<?php
echo $lead["id"];
?>
</th>
<th style="width:140px; font-size:10px; text-align: right;">
<?php
if ($allow_display_empty_fields) {
?>
<input type="checkbox" id="gentry_display_empty_fields" <?php
echo $display_empty_fields ? "checked='checked'" : "";
?>
onclick="ToggleShowEmptyFields();"/> <label for="gentry_display_empty_fields"><?php
_e("show empty fields", "gravityforms");
?>
</label>
<?php
}
?>
</th>
</tr>
</thead>
<tbody>
<?php
$count = 0;
$field_count = sizeof($form["fields"]);
$has_product_fields = false;
foreach ($form["fields"] as $field) {
switch (RGFormsModel::get_input_type($field)) {
case "section":
if (!GFCommon::is_section_empty($field, $form, $lead) || $display_empty_fields) {
$count++;
$is_last = $count >= $field_count ? true : false;
?>
<tr>
<td colspan="2" class="entry-view-section-break<?php
echo $is_last ? " lastrow" : "";
?>
"><?php
echo esc_html(GFCommon::get_label($field));
?>
</td>
</tr>
<?php
}
break;
case "captcha":
case "html":
case "password":
case "page":
//ignore captcha, html, password, page field
break;
default:
//ignore product fields as they will be grouped together at the end of the grid
if (GFCommon::is_product_field($field["type"])) {
$has_product_fields = true;
continue;
}
$value = RGFormsModel::get_lead_field_value($lead, $field);
$display_value = GFCommon::get_lead_field_display($field, $value, $lead["currency"]);
$display_value = apply_filters("gform_entry_field_value", $display_value, $field, $lead, $form);
if ($display_empty_fields || !empty($display_value) || $display_value === "0") {
$count++;
$is_last = $count >= $field_count && !$has_product_fields ? true : false;
$last_row = $is_last ? " lastrow" : "";
$display_value = empty($display_value) && $display_value !== "0" ? " " : $display_value;
$content = '
<tr>
<td colspan="2" class="entry-view-field-name">' . esc_html(GFCommon::get_label($field)) . '</td>
</tr>
<tr>
<td colspan="2" class="entry-view-field-value' . $last_row . '">' . $display_value . '</td>
</tr>';
$content = apply_filters("gform_field_content", $content, $field, $value, $lead["id"], $form["id"]);
echo $content;
}
break;
}
}
$products = array();
if ($has_product_fields) {
$products = GFCommon::get_product_fields($form, $lead);
if (!empty($products["products"])) {
//.........这里部分代码省略.........
示例6: refresh_product_cache
public static function refresh_product_cache($form, $lead, $use_choice_text = false, $use_admin_label = false)
{
$cache_options = array(array(false, false), array(false, true), array(true, false), array(true, true));
foreach ($cache_options as $cache_option) {
list($use_choice_text, $use_admin_label) = $cache_option;
if (gform_get_meta(rgar($lead, 'id'), "gform_product_info_{$use_choice_text}_{$use_admin_label}")) {
gform_delete_meta(rgar($lead, 'id'), "gform_product_info_{$use_choice_text}_{$use_admin_label}");
GFCommon::get_product_fields($form, $lead, $use_choice_text, $use_admin_label);
}
}
}
示例7: get_submitted_pricing_fields
public static function get_submitted_pricing_fields($form, $lead, $format, $use_text = true, $use_admin_label = false)
{
$form_id = $form["id"];
$order_label = apply_filters("gform_order_label_{$form["id"]}", apply_filters("gform_order_label", __("Order", "gravityforms"), $form["id"]), $form["id"]);
$products = GFCommon::get_product_fields($form, $lead, $use_text, $use_admin_label);
$total = 0;
$field_data = "";
switch ($format) {
case "text":
if (!empty($products["products"])) {
$field_data = "--------------------------------\n" . $order_label . "\n\n";
foreach ($products["products"] as $product) {
$product_name = $product["quantity"] . " " . $product["name"];
$price = self::to_number($product["price"]);
if (!empty($product["options"])) {
$product_name .= " (";
$options = array();
foreach ($product["options"] as $option) {
$price += self::to_number($option["price"]);
$options[] = $option["option_name"];
}
$product_name .= implode(", ", $options) . ")";
}
$subtotal = floatval($product["quantity"]) * $price;
$total += $subtotal;
$field_data .= "{$product_name}: " . self::to_money($subtotal, $lead["currency"]) . "\n\n";
}
$total += floatval($products["shipping"]["price"]);
if (!empty($products["shipping"]["name"])) {
$field_data .= $products["shipping"]["name"] . ": " . self::to_money($products["shipping"]["price"], $lead["currency"]) . "\n\n";
}
$field_data .= __("Total", "gravityforms") . ": " . self::to_money($total, $lead["currency"]) . "\n\n";
}
break;
default:
if (!empty($products["products"])) {
$field_data = '<tr bgcolor="#EAF2FA">
<td colspan="2">
<font style="font-family: sans-serif; font-size:12px;"><strong>' . $order_label . '</strong></font>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="20"> </td>
<td>
<table cellspacing="0" width="97%" style="border-left:1px solid #DFDFDF; border-top:1px solid #DFDFDF">
<thead>
<th style="background-color:#F4F4F4; border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; font-family: sans-serif; font-size:12px; text-align:left">' . apply_filters("gform_product_{$form_id}", apply_filters("gform_product", __("Product", "gravityforms"), $form_id), $form_id) . '</th>
<th style="background-color:#F4F4F4; border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:50px; font-family: sans-serif; font-size:12px; text-align:center">' . apply_filters("gform_product_qty_{$form_id}", apply_filters("gform_product_qty", __("Qty", "gravityforms"), $form_id), $form_id) . '</th>
<th style="background-color:#F4F4F4; border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family: sans-serif; font-size:12px; text-align:left">' . apply_filters("gform_product_unitprice_{$form_id}", apply_filters("gform_product_unitprice", __("Unit Price", "gravityforms"), $form_id), $form_id) . '</th>
<th style="background-color:#F4F4F4; border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family: sans-serif; font-size:12px; text-align:left">' . apply_filters("gform_product_price_{$form_id}", apply_filters("gform_product_price", __("Price", "gravityforms"), $form_id), $form_id) . '</th>
</thead>
<tbody>';
foreach ($products["products"] as $product) {
$field_data .= '<tr>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; font-family: sans-serif; font-size:11px;" >
<strong style="color:#BF461E; font-size:12px; margin-bottom:5px">' . esc_html($product["name"]) . '</strong>
<ul style="margin:0">';
$price = self::to_number($product["price"]);
if (is_array(rgar($product, "options"))) {
foreach ($product["options"] as $option) {
$price += self::to_number($option["price"]);
$field_data .= '<li style="padding:4px 0 4px 0">' . $option["option_label"] . '</li>';
}
}
$subtotal = floatval($product["quantity"]) * $price;
$total += $subtotal;
$field_data .= '</ul>
</td>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; text-align:center; width:50px; font-family: sans-serif; font-size:11px;" >' . $product["quantity"] . '</td>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family: sans-serif; font-size:11px;" >' . self::to_money($price, $lead["currency"]) . '</td>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family: sans-serif; font-size:11px;" >' . self::to_money($subtotal, $lead["currency"]) . '</td>
</tr>';
}
$total += floatval($products["shipping"]["price"]);
$field_data .= '</tbody>
<tfoot>';
if (!empty($products["shipping"]["name"])) {
$field_data .= '
<tr>
<td colspan="2" rowspan="2" style="background-color:#F4F4F4; border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; font-size:11px;"> </td>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; text-align:right; width:155px; font-family: sans-serif;"><strong style="font-size:12px;">' . $products["shipping"]["name"] . '</strong></td>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family: sans-serif;"><strong style="font-size:12px;">' . self::to_money($products["shipping"]["price"], $lead["currency"]) . '</strong></td>
</tr>
';
}
$field_data .= '
<tr>';
if (empty($products["shipping"]["name"])) {
$field_data .= '
<td colspan="2" style="background-color:#F4F4F4; border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; font-size:11px;"> </td>';
}
$field_data .= '
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; text-align:right; width:155px; font-family: sans-serif;"><strong style="font-size:12px;">' . __("Total:", "gravityforms") . '</strong></td>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family: sans-serif;"><strong style="font-size:12px;">' . self::to_money($total, $lead["currency"]) . '</strong></td>
</tr>
</tfoot>
</table>
</td>
</tr>';
}
//.........这里部分代码省略.........
示例8: get_order_data
private function get_order_data($feed, $form, $entry)
{
$products = GFCommon::get_product_fields($form, $entry);
$payment_field = $feed["meta"]["transactionType"] == "product" ? $feed["meta"]["paymentAmount"] : $feed["meta"]["recurringAmount"];
$setup_fee_field = rgar($feed["meta"], "setupFee_enabled") ? $feed["meta"]["setupFee_product"] : false;
$trial_field = rgar($feed["meta"], "trial_enabled") ? rgars($feed, 'meta/trial_product') : false;
$amount = 0;
$line_items = array();
$fee_amount = 0;
$trial_amount = 0;
foreach ($products["products"] as $field_id => $product) {
$quantity = $product["quantity"] ? $product["quantity"] : 1;
$product_price = GFCommon::to_number($product['price']);
$options = array();
if (is_array(rgar($product, "options"))) {
foreach ($product["options"] as $option) {
$options[] = $option["option_name"];
$product_price += $option["price"];
}
}
if (!empty($trial_field) && $trial_field == $field_id) {
$trial_amount = $product_price * $quantity;
} else {
if (!empty($setup_fee_field) && $setup_fee_field == $field_id) {
$fee_amount = $product_price * $quantity;
} else {
if (is_numeric($payment_field) && $payment_field != $field_id) {
continue;
}
$amount += $product_price * $quantity;
$description = "";
if (!empty($options)) {
$description = __("options: ", "gravityforms") . " " . implode(", ", $options);
}
if ($product_price >= 0) {
$line_items[] = array("id" => $field_id, "name" => $product["name"], "description" => $description, "quantity" => $quantity, "unit_price" => GFCommon::to_number($product_price));
}
}
}
}
if (!empty($products["shipping"]["name"]) && !is_numeric($payment_field)) {
$line_items[] = array("id" => "", "name" => $products["shipping"]["name"], "description" => "", "quantity" => 1, "unit_price" => GFCommon::to_number($products["shipping"]["price"]));
$amount += $products["shipping"]["price"];
}
return array("payment_amount" => $amount, "setup_fee" => $fee_amount, "trial" => $trial_amount, "line_items" => $line_items);
}
示例9: export_feed
public static function export_feed($entry, $form, $settings)
{
$name_fields = array();
foreach ($form["fields"] as $field) {
if (RGFormsModel::get_input_type($field) == "name") {
$name_fields[] = $field;
}
}
//Creating client
self::log_debug("Checking to see if client exists or a new client needs to be created.");
$client = self::get_client($form, $entry, $settings, $name_fields);
//if client could not be created, ignore invoice and estimate
if (!$client) {
self::log_debug("Unable to create client, not creating invoice/estimate.");
return;
}
if ($settings["meta"]["alsocreate"] == "invoice") {
$invoice_estimate = new FreshBooks_Invoice();
} else {
if ($settings["meta"]["alsocreate"] == "estimate") {
$invoice_estimate = new FreshBooks_Estimate();
} else {
return;
}
}
//don't create invoice or estimate
if (!empty($settings["meta"]["ponumber"])) {
$invoice_estimate->poNumber = esc_html(self::get_entry_value($settings["meta"]["ponumber"], $entry, $name_fields));
}
$invoice_estimate->discount = $settings["meta"]["discount"];
$invoice_estimate->notes = esc_html($settings["meta"]["notes2"]);
$invoice_estimate->terms = esc_html($settings["meta"]["terms"]);
$total = 0;
$lines = array();
if ($settings["meta"]["is_fixed_cost"] == "2") {
//creating line items based on pricing fields
$products = GFCommon::get_product_fields($form, $entry, true, false);
foreach ($products["products"] as $product) {
$product_name = $product["name"];
$price = GFCommon::to_number($product["price"]);
if (!empty($product["options"])) {
$product_name .= " (";
$options = array();
foreach ($product["options"] as $option) {
$price += GFCommon::to_number($option["price"]);
$options[] = $option["option_name"];
}
$product_name .= implode(", ", $options) . ")";
}
$subtotal = floatval($product["quantity"]) * $price;
$total += $subtotal;
$lines[] = array("name" => esc_html($product["name"]), "description" => esc_html($product_name), "unitCost" => $price, "quantity" => $product["quantity"], "amount" => $subtotal);
}
//adding shipping if form has shipping
if (!empty($products["shipping"]["name"])) {
$total += floatval($products["shipping"]["price"]);
$lines[] = array("name" => esc_html($products["shipping"]["name"]), "description" => esc_html($products["shipping"]["name"]), "unitCost" => $products["shipping"]["price"], "quantity" => 1, "amount" => $products["shipping"]["price"]);
}
} else {
//creating line items based on fixed cost or mapped fields
foreach ($settings["meta"]["items"] as $item) {
$cost = $settings["meta"]["is_fixed_cost"] ? $item["cost"] : self::get_entry_value($item["cost"], $entry, $name_fields);
$cost = self::get_number($cost);
$quantity = $settings["meta"]["is_fixed_cost"] ? $item["quantity"] : self::get_entry_value($item["quantity"], $entry, $name_fields);
$amount = $quantity * $cost;
$total += $amount;
$lines[] = array("name" => $item["item_id"], "description" => esc_html($item["description"]), "unitCost" => $cost, "quantity" => $quantity, "amount" => $amount);
}
}
$invoice_estimate->amount = $total;
$invoice_estimate->clientId = $client->clientId;
$invoice_estimate->firstName = $client->firstName;
$invoice_estimate->lastName = $client->lastName;
$invoice_estimate->lines = $lines;
$invoice_estimate->organization = $client->organization;
$invoice_estimate->pStreet1 = $client->pStreet1;
$invoice_estimate->pStreet2 = $client->pStreet2;
$invoice_estimate->pCity = $client->pCity;
$invoice_estimate->pState = $client->pState;
$invoice_estimate->pCode = $client->pCode;
$invoice_estimate->pCountry = $client->pCountry;
self::log_debug("Creating invoice/estimate.");
$invoice_estimate->create();
$lastError = $invoice_estimate->lastError;
if (empty($lastError)) {
self::log_debug("Invoice/estimate created.");
} else {
self::log_error("The following error occurred when trying to create an invoice/estimate: {$lastError}");
}
}
示例10: lead_detail
//.........这里部分代码省略.........
}
break;
default:
//ignore product fields as they will be grouped together at the end of the grid
if (GFCommon::is_product_field($field["type"])) {
$has_product_fields = true;
continue;
}
$value = RGFormsModel::get_lead_field_value($lead, $field);
$display_value = GFCommon::get_lead_field_display($field, $value, $lead["currency"]);
break;
}
// end switch
$display_value = apply_filters("gform_entry_field_value", $display_value, $field, $lead, $Form);
if ($display_empty_fields || !empty($display_value) || $display_value === "0") {
$count++;
$is_last = $count >= $field_count && !$has_product_fields ? true : false;
$last_row = $is_last ? " lastrow" : "";
$display_value = empty($display_value) && $display_value !== "0" ? " " : $display_value;
$content = '
<tr>
<th colspan="2" class="entry-view-field-name">' . esc_html(GFCommon::get_label($field)) . '</th>
</tr>
<tr>
<td colspan="2" class="entry-view-field-value' . $last_row . '">' . $display_value . '</td>
</tr>';
$content = apply_filters("gform_field_content", $content, $field, $value, $lead["id"], $Form["id"]);
echo $content;
}
}
// End foreach
$products = array();
if ($has_product_fields) {
$products = GFCommon::get_product_fields($Form, $lead);
if (!empty($products["products"])) {
?>
<tr>
<td colspan="2" class="entry-view-field-name"><?php
echo apply_filters("gform_order_label_{$Form["id"]}", apply_filters("gform_order_label", __("Order", "gravityforms"), $Form["id"]), $Form["id"]);
?>
</td>
</tr>
<tr>
<td colspan="2" class="entry-view-field-value lastrow">
<table class="entry-products" cellspacing="0" width="97%">
<colgroup>
<col class="entry-products-col1">
<col class="entry-products-col2">
<col class="entry-products-col3">
<col class="entry-products-col4">
</colgroup>
<thead>
<th scope="col"><?php
echo apply_filters("gform_product_{$Form['id']}", apply_filters("gform_product", __("Product", "gravityforms"), $Form['id']), $Form['id']);
?>
</th>
<th scope="col" class="textcenter"><?php
echo apply_filters("gform_product_qty_{$Form['id']}", apply_filters("gform_product_qty", __("Qty", "gravityforms"), $Form['id']), $Form['id']);
?>
</th>
<th scope="col"><?php
echo apply_filters("gform_product_unitprice_{$Form['id']}", apply_filters("gform_product_unitprice", __("Unit Price", "gravityforms"), $Form['id']), $Form['id']);
?>
</th>
<th scope="col"><?php
echo apply_filters("gform_product_price_{$Form['id']}", apply_filters("gform_product_price", __("Price", "gravityforms"), $Form['id']), $Form['id']);
示例11: get_form_data
/**
* Get form data
*
* @since
*
* @uses RGFormsModel::create_lead()
* @uses GFCommon::get_product_fields()
* @uses rgpost()
* @uses apply_filters()
* @uses GFP_Stripe::get_order_info()
*
* @param $form
* @param $feed
*
* @return mixed|void
*/
public static function get_form_data($form, $feed)
{
// get products
$tmp_lead = RGFormsModel::create_lead($form);
$products = GFCommon::get_product_fields($form, $tmp_lead);
$form_data = array();
// getting billing information
$form_data['form_title'] = $form['title'];
$form_data['name'] = rgpost('input_' . str_replace('.', '_', $feed['meta']['customer_fields']['first_name'])) . ' ' . rgpost('input_' . str_replace('.', '_', $feed['meta']['customer_fields']['last_name']));
$form_data['email'] = rgpost('input_' . str_replace('.', '_', $feed['meta']['customer_fields']['email']));
$form_data['address1'] = rgpost('input_' . str_replace('.', '_', $feed['meta']['customer_fields']['address1']));
$form_data['address2'] = rgpost('input_' . str_replace('.', '_', $feed['meta']['customer_fields']['address2']));
$form_data['city'] = rgpost('input_' . str_replace('.', '_', $feed['meta']['customer_fields']['city']));
$form_data['state'] = rgpost('input_' . str_replace('.', '_', $feed['meta']['customer_fields']['state']));
$form_data['zip'] = rgpost('input_' . str_replace('.', '_', $feed['meta']['customer_fields']['zip']));
$form_data['country'] = rgpost('input_' . str_replace('.', '_', $feed['meta']['customer_fields']['country']));
$form_data["credit_card"] = rgpost('stripeToken');
$form_data = apply_filters('gfp_stripe_get_form_data', $form_data, $feed, $products);
$order_info_args = '';
$order_info = self::$_this->get_order_info($products, apply_filters('gfp_stripe_get_form_data_order_info', $order_info_args, $feed));
$form_data["line_items"] = $order_info["line_items"];
$form_data["amount"] = $order_info["amount"];
return $form_data;
}
示例12: get_product_billing_data
public static function get_product_billing_data($form, $lead, $config)
{
// get products
$products = GFCommon::get_product_fields($form, $lead);
$data = array();
$data["billing"] = array('DESC' => '');
$data["products"] = $products;
$data["amount"] = 0;
$item = 0;
//------------------------------------------------------
//creating line items and recurring description
$recurring_amount_field = $config["meta"]["recurring_amount_field"];
foreach ($products["products"] as $product_id => $product) {
if (!self::include_in_total($product_id, $config)) {
continue;
}
$product_amount = GFCommon::to_number($product["price"]);
if (is_array(rgar($product, "options"))) {
foreach ($product["options"] as $option) {
$product_amount += $option["price"];
}
}
$data["amount"] += $product_amount * $product["quantity"];
//adding line items
if ($config["meta"]["type"] == "product") {
$data["billing"]['L_NAME' . $item] = $product["name"];
$data["billing"]['L_DESC' . $item] = $product["name"];
$data["billing"]['L_AMT' . $item] = $product_amount;
$data["billing"]['L_NUMBER' . $item] = $item + 1;
$data["billing"]['L_QTY' . $item] = $product["quantity"];
} else {
//adding recurring description
$data["billing"]['DESC'] .= $item > 1 ? ", " . $product["name"] : $product["name"];
}
$item++;
}
//adding shipping information if feed is configured for products and services or a subscription based on the form total
if (!empty($products["shipping"]["name"]) && ($config["meta"]["type"] == "product" || $recurring_amount_field == "all")) {
if ($config["meta"]["type"] == "product") {
$data["billing"]['L_NAME' . $item] = $products["shipping"]["name"];
$data["billing"]['L_AMT' . $item] = $products["shipping"]["price"];
$data["billing"]['L_NUMBER' . $item] = $item + 1;
$data["billing"]['L_QTY' . $item] = 1;
}
$data["amount"] += $products["shipping"]["price"];
}
$data["line_items"] = $item;
return $data;
}
示例13: get_donation_query_string
private static function get_donation_query_string($form, $entry)
{
$fields = "";
//getting all donation fields
$donations = GFCommon::get_fields_by_type($form, array("donation"));
$total = 0;
$purpose = "";
foreach ($donations as $donation) {
$value = RGFormsModel::get_lead_field_value($entry, $donation);
list($name, $price) = explode("|", $value);
if (empty($price)) {
$price = $name;
$name = $donation["label"];
}
$purpose .= $name . ", ";
$price = GFCommon::to_number($price);
$total += $price;
}
//using product fields for donation if there aren't any legacy donation fields in the form
if ($total == 0) {
//getting all product fields
$products = GFCommon::get_product_fields($form, $entry, true);
foreach ($products["products"] as $product) {
$options = "";
if (is_array($product["options"]) && !empty($product["options"])) {
$options = " (";
foreach ($product["options"] as $option) {
$options .= $option["option_name"] . ", ";
}
$options = substr($options, 0, strlen($options) - 2) . ")";
}
$quantity = GFCommon::to_number($product["quantity"]);
$quantity_label = $quantity > 1 ? $quantity . " " : "";
$purpose .= $quantity_label . $product["name"] . $options . ", ";
}
$total = GFCommon::get_order_total($form, $entry);
}
if (!empty($purpose)) {
$purpose = substr($purpose, 0, strlen($purpose) - 2);
}
$purpose = urlencode($purpose);
//truncating to maximum length allowed by Paytm Form
if (strlen($purpose) > 127) {
$purpose = substr($purpose, 0, 124) . "...";
}
$fields = "&amount={$total}&desc={$purpose}";
return $total > 0 ? $fields : false;
}
示例14: export_feed
public function export_feed($entry, $form, $feed)
{
$name_fields = array();
foreach ($form['fields'] as $field) {
if (RGFormsModel::get_input_type($field) == 'name') {
$name_fields[] = $field;
}
}
//Creating client
$this->log_debug(__METHOD__ . '(): Checking to see if client exists or a new client needs to be created.');
$client = $this->get_client($form, $entry, $feed, $name_fields);
//if client could not be created, ignore invoice and estimate
if (!$client) {
$this->log_debug(__METHOD__ . '(): Unable to create client, not creating invoice/estimate.');
return;
}
$type = rgars($feed, 'meta/alsoCreate');
if ($type == 'invoice') {
$invoice_estimate = new FreshBooks_Invoice();
} elseif ($type == 'estimate') {
$invoice_estimate = new FreshBooks_Estimate();
} else {
return;
}
//don't create invoice or estimate
if (!empty($feed['meta']['poNumber'])) {
$po_number = esc_html($this->get_entry_value($feed['meta']['poNumber'], $entry, $name_fields));
//trim po_number to 25 characters because FreshBooks only allows 25 and more will cause invoice/estimate to not be created
$invoice_estimate->poNumber = substr($po_number, 0, 25);
}
$invoice_estimate->discount = $feed['meta']['discount'];
$invoice_estimate->notes = esc_html(GFCommon::replace_variables($feed['meta']['notes2'], $form, $entry, false, false, false, 'text'));
$invoice_estimate->terms = esc_html($feed['meta']['terms']);
$total = 0;
$lines = array();
if ($feed['meta']['lineItems'] == 'pricing') {
$this->log_debug(__METHOD__ . '(): Creating line items based on pricing fields.');
//creating line items based on pricing fields
$products = GFCommon::get_product_fields($form, $entry, true, false);
foreach ($products['products'] as $product) {
$product_name = $product['name'];
$price = GFCommon::to_number($product['price']);
if (!empty($product['options'])) {
$product_name .= ' (';
$options = array();
foreach ($product['options'] as $option) {
$price += GFCommon::to_number($option['price']);
$options[] = $option['option_name'];
}
$product_name .= implode(', ', $options) . ')';
}
$subtotal = floatval($product['quantity']) * $price;
$total += $subtotal;
$lines[] = array('name' => esc_html($product['name']), 'description' => esc_html($product_name), 'unitCost' => $price, 'quantity' => $product['quantity'], 'amount' => $subtotal);
}
//adding shipping if form has shipping
if (!empty($products['shipping']['name'])) {
$total += floatval($products['shipping']['price']);
$lines[] = array('name' => esc_html($products['shipping']['name']), 'description' => esc_html($products['shipping']['name']), 'unitCost' => $products['shipping']['price'], 'quantity' => 1, 'amount' => $products['shipping']['price']);
}
} else {
$i = 0;
$this->log_debug(__METHOD__ . '(): Creating line items based on fixed costs and quantities.');
//creating line items based on fixed cost or mapped fields
/**
* Determines if the item ID should be used instead of the item name.
*
* @since 2.0
*
* @param bool false Defaults to false. Set to the item ID to use it.
*/
$send_item_id = apply_filters('gform_freshbooks_send_item_id_for_fixed_dynamic', false);
foreach ($feed['meta']['item'] as $item) {
$cost = $feed['meta']['lineItems'] == 'fixed' ? $feed['meta']['cost'][$i] : $this->get_entry_value($feed['meta']['cost'][$i], $entry, $name_fields);
$cost = $this->get_number($cost);
$quantity = $feed['meta']['lineItems'] == 'fixed' ? $feed['meta']['quantity'][$i] : $this->get_entry_value($feed['meta']['quantity'][$i], $entry, $name_fields);
$amount = $quantity * $cost;
$total += $amount;
if ($send_item_id) {
//item id is what is saved in the database, use it
$item_name = $item;
} else {
//get item name using saved item id
$item_name = $this->get_item_name($item);
if (empty($item_name)) {
//default to item id if no name found
$item_name = $item;
}
}
$lines[] = array('name' => $item_name, 'description' => esc_html($feed['meta']['description'][$i]), 'unitCost' => $cost, 'quantity' => $quantity, 'amount' => $amount);
$i++;
}
}
$invoice_estimate->amount = $total;
$invoice_estimate->clientId = $client->clientId;
$invoice_estimate->firstName = $client->firstName;
$invoice_estimate->lastName = $client->lastName;
$invoice_estimate->lines = $lines;
$invoice_estimate->organization = $client->organization;
$invoice_estimate->pStreet1 = $client->pStreet1;
//.........这里部分代码省略.........
示例15: get_submitted_pricing_fields
public static function get_submitted_pricing_fields($form, $lead)
{
$field_data .= '<tr bgcolor="#EAF2FA">
<td colspan="2">
<font style="font-family:verdana,sans-serif; font-size:12px;"><strong>' . apply_filters("gform_order_label_{$form["id"]}", apply_filters("gform_order_label", __("Order", "gravityforms"), $form["id"]), $form["id"]) . '</strong></font>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="20"> </td>
<td>
<table cellspacing="0" width="97%" style="border-left:1px solid #DFDFDF; border-top:1px solid #DFDFDF">
<thead>
<th style="background-color:#F4F4F4; border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; font-family:verdana,sans-serif; font-size:12px; text-align:left">' . __("Product", "gravityforms") . '</th>
<th style="background-color:#F4F4F4; border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:50px; font-family:verdana,sans-serif; font-size:12px; text-align:center">' . __("Qty", "gravityforms") . '</th>
<th style="background-color:#F4F4F4; border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family:verdana,sans-serif; font-size:12px; text-align:left">' . __("Unit Price", "gravityforms") . '</th>
<th style="background-color:#F4F4F4; border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family:verdana,sans-serif; font-size:12px; text-align:left">' . __("Price", "gravityforms") . '</th>
</thead>
<tbody>';
$products = GFCommon::get_product_fields($form, $lead);
$total = 0;
foreach ($products["products"] as $product) {
$field_data .= '<tr>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; font-family:verdana,sans-serif; font-size:11px;" >
<strong style="color:#BF461E; font-size:12px; margin-bottom:5px">' . esc_html($product["name"]) . '</strong>
<ul style="margin:0">';
$price = self::to_number($product["price"]);
if (is_array($product["options"])) {
foreach ($product["options"] as $option) {
$price += self::to_number($option["price"]);
$field_data .= '<li style="padding:4px 0 4px 0">' . $option["option_label"] . '</li>';
}
}
$subtotal = floatval($product["quantity"]) * $price;
$total += $subtotal;
$field_data .= '</ul>
</td>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; text-align:center; width:50px; font-family:verdana,sans-serif; font-size:11px;" >' . $product["quantity"] . '</td>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family:verdana,sans-serif; font-size:11px;" >' . self::to_money($price, $lead["currency"]) . '</td>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family:verdana,sans-serif; font-size:11px;" >' . self::to_money($subtotal, $lead["currency"]) . '</td>
</tr>';
}
$total += floatval($products["shipping"]["price"]);
$field_data .= '</tbody>
<tfoot>';
if (!empty($products["shipping"]["name"])) {
$field_data .= '
<tr>
<td colspan="2" rowspan="2" style="background-color:#F4F4F4; border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; font-size:11px;"> </td>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; text-align:right; width:155px; font-family:verdana,sans-serif;"><strong style="font-size:12px;">' . $products["shipping"]["name"] . '</strong></td>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family:verdana,sans-serif;"><strong style="font-size:12px;">' . self::to_money($products["shipping"]["price"], $lead["currency"]) . '</strong></td>
</tr>
';
}
$field_data .= '
<tr>';
if (empty($products["shipping"]["name"])) {
$field_data .= '
<td colspan="2" style="background-color:#F4F4F4; border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; font-size:11px;"> </td>';
}
$field_data .= '
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; text-align:right; width:155px; font-family:verdana,sans-serif;"><strong style="font-size:12px;">' . __("Total:", "gravityforms") . '</strong></td>
<td style="border-bottom:1px solid #DFDFDF; border-right:1px solid #DFDFDF; padding:7px; width:155px; font-family:verdana,sans-serif;"><strong style="font-size:12px;">' . self::to_money($total, $lead["currency"]) . '</strong></td>
</tr>
</tfoot>
</table>
</td>
</tr>';
return $field_data;
}