Skip to content

Instantly share code, notes, and snippets.

@alisonmf
Created August 6, 2014 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alisonmf/aec9a982f854c0754a34 to your computer and use it in GitHub Desktop.
Save alisonmf/aec9a982f854c0754a34 to your computer and use it in GitHub Desktop.
Remove price label from gravity form product field
<?php if ( is_page('slug') ) { // only executes on this page ?>
<script type="text/javascript">
function gform_format_option_label(fullLabel, fieldLabel, priceLabel, selectedPrice, price, formId, fieldId)
{
// Only for field with ID of 5
if (fieldId == 5)
// Disable option pricing. Simply return the field label.
// This removes the price differentials in the drop down
return fieldLabel;
}
</script>
<?php } ?>
@craigtommola
Copy link

I'm actually looking to do something similar, and wonder if you could shed some light, as I've never used the gform_format_option_label bit before. I have a Single Product field that I'm using as a conditional discount (i.e. if you register before X date, save $25). But I'd love to have the "Price" label become "Discount" if the number is below zero. Thoughts?

Much thanks
CT

... Later that day ...

Add the following filter to your theme's functions.php file:

add_filter( 'gform_product_price_13_133', 'set_price_label_1', 10, 2 );
function set_price_label_1( $sublabel, $form_id ) {
    return 'Discount';
}

The _13 added to the gform_product_price specifies the form id. The _133 specifies the field id, on form #13. I named my function set_price_label_1 because I was going to add another filter for fields 135, 136, 137. Perhaps there's an easier way to specify all four fields in the same filter, but I tried a couple and didn't find it and this is such a minor aspect having 4 wasn't a big deal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment