Skip to content

gpnf-hide-quantity-in-summary-field-values.php: Added snippet to hide quantity from GPNF summary field values. #1101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions gp-nested-forms/gpnf-hide-quantity-in-summary-field-values.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* Gravity Perks // Nested Forms // Hide Quantity in Summary Field Values
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
*
* Product field display values are formatted as "Label, Quantity, Price". This snippet removes the quantity from the display value.
Copy link
Contributor

@veryspry veryspry May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any cases where the order could change? E.g. is that order configurable?

A more specific question is: is there a config somewhere we could grab and dynamically build the regex from that?

I wouldn't sink too much time into this, if any. More so just a question in case it's an easy thing to add. Feel free to skip this suggestion if it's going to be a big time sink

*/
add_filter( 'gpnf_display_value', function( $display_value, $field, $form, $entry ) {

if ( $field->type != 'product' ) {
return $display_value;
}

$display_value['label'] = preg_replace( '/,\s*[^,]+,\s*/', ', ', $display_value['label']);

return $display_value;
}, 10, 4 );
Loading