Skip to content

Commit 009e3e5

Browse files
authored
gpnf-hide-quantity-in-summary-field-values.php: Added snippet to hide quantity from GPNF summary field values.
1 parent 9c32b47 commit 009e3e5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Nested Forms // Hide Quantity in Summary Field Values
4+
* https://gravitywiz.com/documentation/gravity-forms-nested-forms/
5+
*
6+
* Product field display values are formatted as "Label, Quantity, Price". This snippet removes the quantity from the display value.
7+
*/
8+
add_filter( 'gpnf_display_value', function( $display_value, $field, $form, $entry ) {
9+
10+
if ( $field->type != 'product' ) {
11+
return $display_value;
12+
}
13+
14+
$display_value['label'] = preg_replace( '/,\s*[^,]+,\s*/', ', ', $display_value['label']);
15+
16+
return $display_value;
17+
}, 10, 4 );

0 commit comments

Comments
 (0)