";
}
}
/**
* Retrieve the field label.
*
* @since 2.5
*
* @param bool $force_frontend_label Should the frontend label be displayed in the admin even if an admin label is configured.
* @param string $value The field value. From default/dynamic population, $_POST, or a resumed incomplete submission.
*
* @return string
*/
public function get_field_label( $force_frontend_label, $value ) {
$field_label = parent::get_field_label( $force_frontend_label, $value );
// Checking the defined product name.
if ( ! rgempty( $this->id . '.1', $value ) ) {
$field_label = rgar( $value, $this->id . '.1' );
}
if ( $this->disableQuantity || ! $this->get_context_property( 'rendering_form' ) ) {
$label = esc_html( $field_label );
} else {
$product_quantity_sub_label = $this->get_product_quantity_label( $this->formId );
$label = '' . esc_html( $field_label ) . '' . ' ' . $product_quantity_sub_label . '';
}
return $label;
}
/**
* Format the entry value for display on the entry detail page and for the {all_fields} merge tag.
*
* @since 1.9
* @since 2.9.29 Changed the second parameter $currency (string) to $entry (array).
*
* @param string|array $value The field value.
* @param array $entry The entry.
* @param bool|false $use_text When processing choice based fields should the choice text be returned instead of the value.
* @param string $format The format requested for the location the merge is being used. Possible values: html, text or url.
* @param string $media The location where the value will be displayed. Possible values: screen or email.
*
* @return string
*/
public function get_value_entry_detail( $value, $entry = array(), $use_text = false, $format = 'html', $media = 'screen' ) {
if ( is_array( $value ) && ! empty( $value ) ) {
$product_name = trim( $value[ $this->id . '.1' ] );
$price = trim( $value[ $this->id . '.2' ] );
$quantity = trim( $value[ $this->id . '.3' ] );
$product_details = $product_name;
if ( ! rgblank( $quantity ) ) {
$product_details .= ', ' . esc_html__( 'Qty: ', 'gravityforms' ) . $quantity;
}
if ( ! rgblank( $price ) ) {
$product_details .= ', ' . esc_html__( 'Price: ', 'gravityforms' ) . GFCommon::format_number( $price, 'currency', rgar( $entry, 'currency' ) );
}
return wp_kses( $product_details, wp_kses_allowed_html( 'data' ) );
} else {
return '';
}
}
/**
* Actions to be performed after the field has been converted to an object.
*
* @since 2.4.8.2
*/
public function post_convert_field() {
parent::post_convert_field();
// Ensure the choices property is not an array to prevent issues with some features such as the conditional logic reset to default.
$this->choices = null;
}
}
GF_Fields::register( new GF_Field_SingleProduct() );