Crating a new custom product type

as you know gravity forms comes shipped with default product field types:


is there a way to add to this list a new product type with custom functionality?

alternatively i would make a custom filed like this:

<?php

if (!class_exists('GFForms')) {
  die();
}


class GF_Field_Event_Product extends GF_Field{

  public $type = 'event_product';

  public function get_form_editor_field_title(){
    return esc_attr__('Event Product', 'gravityforms');
  }

  /**
   * Returns the field's form editor description.
   *
   * @since 2.5
   *
   * @return string
   */
  public function get_form_editor_field_description(){
    return esc_attr__('Allows the creation of event product in the form.', 'gravityforms');
  }

  /**
   * Returns the field's form editor icon.
   *
   * This could be an icon url or a gform-icon class.
   *
   * @since 2.5
   *
   * @return string
   */
  public function get_form_editor_field_icon(){
    return 'gform-icon--product';
  }

  public function get_form_editor_button(){
    return array(
      'group' => 'custom_addon',
      'text' => $this->get_form_editor_field_title()
    );
  }


  function get_form_editor_field_settings(){
    return array(
      'product_field_type_setting',
      'prepopulate_field_setting',
      'label_setting',
      'admin_label_setting',
      'label_placement_setting',
      'description_setting',
      'css_class_setting',
    );
  }

  public function get_field_input($form, $value = '', $entry = null){
    return '';
  }
}

GF_Fields::register(new GF_Field_Event_Product());

and add custom settings

any help would be appreciated
thanks

Check the documentation here

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.