Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Gravity Perks // GP Conditional Pricing // Display Price Labels
<script>
gform.addAction( 'gpcp_after_update_pricing', function( triggerFieldId, gpcp ) {
( function( $ ) {
$( '.gpcp-price' ).each( function() {
var price = $( this ).closest( 'li' ).find( 'input' ).val().split( '|' )[1];
$( this ).html( gformFormatMoney( price ) );
} );
} )( jQuery );
} );
</script>
/**
* Gravity Perks // GP Conditional Pricing // Display Price Labels
* http://gravitywiz.com/documentation/gravity-forms-conditional-pricing/
*/
add_filter( 'gform_field_choice_markup_pre_render', function ( $choice_markup, $choice, $field, $value ) {
if ( $field->type == 'product' ) {
$new_string = sprintf( '>%s - <span class="gpcp-price">%s</span><', $choice['text'], GFCommon::to_money( $choice['price'] ) );
return str_replace( ">{$choice['text']}<", $new_string, $choice_markup );
}
return $choice_markup;
}, 10, 4 );
@ntreegdesigns

This comment has been minimized.

Copy link

ntreegdesigns commented Feb 22, 2019

Hello, thanks for this code. I am attempting to show the conditional price as a label on radio selections but when I add the php, it only shows $0.00 as the label instead of the conditional price. How could I go about placing the conditional prices directly on radio labels? Thanks for your time.

@Wordna1

This comment has been minimized.

Copy link

Wordna1 commented Jan 18, 2020

I agree with @ntreegdesigns - The default prices are displayed, but I can't get the conditional price(s) to appear, even if I put the condition field on an earlier page. The {subtotal} merge tag updates correctly, so I know that my conditional pricing is setup correctly.

@spivurno

This comment has been minimized.

Copy link
Owner Author

spivurno commented Jan 18, 2020

@Wordna1 Drop us a line via support and we'll be happy to dig in. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.