Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save spivurno/a52923aadd37cc0151ce33c92662ba60 to your computer and use it in GitHub Desktop.
Save spivurno/a52923aadd37cc0151ce33c92662ba60 to your computer and use it in GitHub Desktop.
Gravity Wiz // Gravity Forms // Display Price for Drop Down and Radio Button Product Fields
<?php
/**
* Gravity Wiz // Gravity Forms // Display Price for Drop Down and Radio Button Product Fields
* http://gravitywiz.com/
* Source: https://www.gravityhelp.com/documentation/article/gform_field_choice_markup_pre_render/#2-include-price-for-product-fields
*/
add_filter( 'gform_field_choice_markup_pre_render', function ( $choice_markup, $choice, $field, $value ) {
if ( $field->type == 'product' ) {
$new_string = sprintf( '>%s - %s<', $choice['text'], GFCommon::to_money( $choice['price'] ) );
return str_replace( ">{$choice['text']}<", $new_string, $choice_markup );
}
return $choice_markup;
}, 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment