Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lucasstark/7d7ed93efa505f333e599732cfeba24c to your computer and use it in GitHub Desktop.
Save lucasstark/7d7ed93efa505f333e599732cfeba24c to your computer and use it in GitHub Desktop.
Attempt to remove GRavity Form price labels from items added to the WooCommerce cart.
add_filter( 'woocommerce_gforms_get_item_data', function ( $data, $field, $lead, $form_meta ) {
if ( strpos( $data['display'], '(' ) !== false && strpos( $data['display'], ')' ) !== false ) {
$data['display'] = substr( $data['display'], 0, strpos( $data['display'], '(' ) );
}
return $data;
}, 10, 4 );
add_filter( 'woocommerce_gforms_field_display_text', function ( $value, $text, $field ) {
if ( strpos( $value, '(' ) !== false && strpos( $value, ')' ) !== false ) {
$value = substr( $value, 0, strpos( $value, '(' ) );
}
return $value;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment