Hide Quantity in Summary Field Values

Product field display values are formatted as “Label, Quantity, Price”. This snippet removes the quantity from the display value.

Code

Filename: gpnf-hide-quantity-in-summary-field-values.php

<?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.
 */
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 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.