';
$hidden = ! $is_single ? 'wpforms-hidden' : '';
echo '
';
echo wp_kses(
'' . $single_label . '',
[
'span' => [
'class' => [],
],
]
);
echo '
';
$hidden = ! $this->is_hidden( $field ) ? 'wpforms-hidden' : '';
echo '
';
printf(
wp_kses( /* translators: %1$s - Item Price value. */
__( 'Price: %1$s', 'wpforms-lite' ),
[
'span' => [
'class' => [],
],
]
),
esc_html( $price )
);
echo '
';
$hidden = ! $is_single ? 'wpforms-hidden' : '';
$this->field_preview_option( 'quantity', $field, [ 'class' => $hidden ] );
echo '
';
printf(
'',
esc_attr( $placeholder ),
esc_attr( $value )
);
$hidden = $this->is_min_price_passed( $field ) ? 'wpforms-hidden' : '';
echo '';
echo '
';
$this->field_preview_option( 'description', $field );
$hidden = ! isset( $field['min_price'] ) || empty( (float) wpforms_sanitize_amount( $field['min_price'] ) ) ? 'wpforms-hidden' : '';
echo '
';
printf(
wp_kses( /* translators: %1$s - Minimum Price value. */
__( 'Minimum Price: %1$s', 'wpforms-lite' ),
[
'span' => [
'class' => [],
],
]
),
esc_html( $min_price )
);
echo '
';
echo '
';
esc_html_e( 'Note: Item type is set to hidden and will not be visible when viewing the form.', 'wpforms-lite' );
echo '
';
echo '
';
}
/**
* Field display on the form front-end.
*
* @since 1.8.2
*
* @param array $field Field data and settings.
* @param array $deprecated Deprecated field attributes.
* @param array $form_data Form data and settings.
*/
public function field_display( $field, $deprecated, $form_data ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
// Shortcut for easier access.
$primary = $field['properties']['inputs']['primary'];
$field_format = ! empty( $field['format'] ) ? $field['format'] : self::FORMAT_SINGLE;
// Placeholder attribute is only applicable to password, search, tel, text and url inputs, not hidden.
// aria-errormessage attribute is not allowed for hidden inputs.
if ( ! $this->is_user_defined( $field ) ) {
unset( $primary['attr']['placeholder'], $primary['attr']['aria-errormessage'] );
}
switch ( $field_format ) {
case self::FORMAT_SINGLE:
case self::FORMAT_HIDDEN:
if ( $field_format === self::FORMAT_SINGLE ) {
$price = ! empty( $field['price'] ) ? $field['price'] : 0;
$field_label = str_replace( '{price}', '';
echo '
';
echo wp_kses(
$field_label,
[
'span' => [
'class' => [],
],
]
);
echo '
';
$this->display_quantity_dropdown( $field );
echo '
';
}
// Primary price field.
printf(
'