{"id":10269,"date":"2016-05-17T18:26:08","date_gmt":"2016-05-17T22:26:08","guid":{"rendered":"https:\/\/docs.gravityforms.com\/?post_type=gdoc&#038;p=10269"},"modified":"2019-04-12T09:57:38","modified_gmt":"2019-04-12T13:57:38","slug":"gf_field_quantity","status":"publish","type":"post","link":"https:\/\/docs.gravityforms.com\/gf_field_quantity\/","title":{"rendered":"GF_Field_Quantity"},"content":{"rendered":"<h2 id=\"h-introduction\">Introduction<\/h2>\n<p>The GF_Field_Quantity class extends the <a data-autolink=\"autolink_gf_field\" href=\"\/gf_field\">GF_Field<\/a> class, also known as the <a data-autolink=\"autolink_field-object\" href=\"\/field-object\">Field Object<\/a>. This class is responsible for handling the Quantity field. Because Quantity fields are either a Number, Drop Down or Hidden field, this class only adds some settings and sets the title for the field in the editor. The rendering of the Quantity field is handled by the class associated with its sub-type. The field &#8220;type&#8221; property will be set to &#8220;quantity&#8221; and the field &#8220;inputType&#8221; property will be &#8220;number&#8221;, &#8220;select&#8221;, or &#8220;hidden&#8221;.<\/p>\n<p>For more details about rendering the Quantity field, check out the articles below for the specific type of Quantity field:<\/p>\n<p>Number &#8211; <a data-autolink=\"autolink_gf_field_number\" href=\"\/gf_field_number\">GF_Field_Number<\/a> class<br \/>\nDrop Down &#8211; <a data-autolink=\"autolink_gf_field_select\" href=\"\/gf_field_select\">GF_Field_Select<\/a> class<br \/>\nHidden Product &#8211; <a data-autolink=\"autolink_gf_field_hiddenproduct\" href=\"\/gf_field_hiddenproduct\">GF_Field_Hiddenproduct<\/a> class<\/p>\n<h2 id=\"h-settings-and-properties\">Settings and Properties<\/h2>\n<p>Settings control what options are available to the admin user when configuring the field in the form editor. Gravity Forms includes many built-in settings such as Field Label, Field Description, Choices, Conditional Logic, etc. In addition to built-in settings, custom settings can also be developed. For more information on how to develop custom settings and how to associate settings to a field, visit the <a href=\"https:\/\/docs.gravityforms.com\/gf_field\/#get_form_editor_field_settings\" target=\"_blank\" rel=\"noopener noreferrer\">GF_Field page<\/a>.<\/p>\n<p>Properties contain the values specified by the settings and generally are part of the <a data-autolink=\"autolink_field-object\" href=\"\/field-object\">Field Object<\/a>.<\/p>\n<p>The properties may be retrieved by accessing the <a data-autolink=\"autolink_field-object\" href=\"\/field-object\">Field Object<\/a> as follows:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\/\/get the field\r\n$field = GFFormsModel::get_field( $form, 1 );\r\n\r\n\/\/get the admin label\r\n$admin_label = $field-&gt;adminLabel;\r\n<\/pre>\n<h3 id=\"h-settings-0\">Settings<\/h3>\n<p>The following settings are available for the field:<\/p>\n<ul>\n<li><strong>admin_label_setting<\/strong><br \/>\nControls whether the &#8220;Admin Field Label&#8221; setting appears.<\/p>\n<\/li>\n<li>\n<p><strong>conditional_logic_field_setting<\/strong><br \/>\nControls whether the &#8220;Enable Conditional Logic&#8221; setting appears.<\/p>\n<\/li>\n<li>\n<p><strong>css_class_setting<\/strong><br \/>\nControls whether the &#8220;Custom CSS Class&#8221; setting displays. This allows a custom css to be used for the field.<\/p>\n<\/li>\n<li>\n<p><strong>default_value_setting<\/strong><br \/>\nControls whether the &#8220;Default Values&#8221; section displays. This allows a value to be set for the field.<\/p>\n<\/li>\n<li>\n<p><strong>description_setting<\/strong><br \/>\nControls whether the &#8220;Description&#8221; setting appears. This allows a description for the field to be displayed.<\/p>\n<\/li>\n<li>\n<p><strong>label_setting<\/strong><br \/>\nControls whether the &#8220;Field Label&#8221; setting which allows the label to be changed appears.<\/p>\n<\/li>\n<li>\n<p><strong>placeholder_setting<\/strong><br \/>\nControls whether the &#8220;Placeholders&#8221; section appears. This allows placeholder text to display for the field.<\/p>\n<\/li>\n<li>\n<p><strong>prepopulate_field_setting<\/strong><br \/>\nControls whether the &#8220;Allow field to be populated dynamically&#8221; setting appears.<\/p>\n<\/li>\n<li>\n<p><strong>product_field_setting<\/strong><br \/>\nDetermines whether the &#8220;Product Field Mapping&#8221; section displays. This allows you to select to which product field the Option is associated.<\/p>\n<\/li>\n<li>\n<p><strong>quantity_field_type_setting<\/strong><br \/>\nDetermines whether the &#8220;Field Type&#8221; section displays. This allows the Quantity field to be set to a specific type: Number, Drop Down, Hidden.<\/p>\n<\/li>\n<\/ul>\n<h2 id=\"h-source-code\">Source Code<\/h2>\n<p>The source code is located in <em>includes\/fields\/class-gf-field-quantity.php<\/em> in the Gravity Forms folder of your sites plugins directory.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Need to create a custom Quantity field within Gravity Forms for handling your product quantities? The GF_Field_Quantity class is what you&#8217;re looking for.<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_autodraft_ids":[],"_sb_is_suggestion_mode":false,"_sb_show_suggestion_boards":false,"_sb_show_comment_boards":false,"_sb_suggestion_history":"","_sb_update_block_changes":"","_is_real_time_mode":false,"_realtime_collaborators":"","footnotes":"","jetpack_post_was_ever_published":false,"cf_checklist_status":[]},"categories":[301],"tags":[],"class_list":["post-10269","post","type-post","status-publish","format-standard","hentry","category-field-classes","wpautop"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>GF_Field_Quantity - Gravity Forms Documentation<\/title>\n<meta name=\"description\" content=\"Need to create a custom Quantity field within Gravity Forms for handling your product quantities? The GF_Field_Quantity class is what you&#039;re looking for.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/docs.gravityforms.com\/gf_field_quantity\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"GF_Field_Quantity\" \/>\n<meta property=\"og:description\" content=\"Need to create a custom Quantity field within Gravity Forms for handling your product quantities? The GF_Field_Quantity class is what you&#039;re looking for.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/docs.gravityforms.com\/gf_field_quantity\/\" \/>\n<meta property=\"og:site_name\" content=\"Gravity Forms Documentation\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-17T22:26:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-04-12T13:57:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/docs.gravityforms.com\/wp-content\/uploads\/2023\/08\/gf-docs-default-v3.png\" \/>\n\t<meta property=\"og:image:width\" content=\"544\" \/>\n\t<meta property=\"og:image:height\" content=\"288\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Justin Pakes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@gravityforms\" \/>\n<meta name=\"twitter:site\" content=\"@gravityforms\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Justin Pakes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/gf_field_quantity\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/gf_field_quantity\\\/\"},\"author\":{\"name\":\"Justin Pakes\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#\\\/schema\\\/person\\\/8a88745ec2ee5bc1bb24eea8634bf376\"},\"headline\":\"GF_Field_Quantity\",\"datePublished\":\"2016-05-17T22:26:08+00:00\",\"dateModified\":\"2019-04-12T13:57:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/gf_field_quantity\\\/\"},\"wordCount\":461,\"publisher\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#organization\"},\"articleSection\":[\"Field Classes\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/gf_field_quantity\\\/\",\"url\":\"https:\\\/\\\/docs.gravityforms.com\\\/gf_field_quantity\\\/\",\"name\":\"GF_Field_Quantity - Gravity Forms Documentation\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#website\"},\"datePublished\":\"2016-05-17T22:26:08+00:00\",\"dateModified\":\"2019-04-12T13:57:38+00:00\",\"description\":\"Need to create a custom Quantity field within Gravity Forms for handling your product quantities? The GF_Field_Quantity class is what you're looking for.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/gf_field_quantity\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/docs.gravityforms.com\\\/gf_field_quantity\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/gf_field_quantity\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/docs.gravityforms.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"GF_Field_Quantity\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#website\",\"url\":\"https:\\\/\\\/docs.gravityforms.com\\\/\",\"name\":\"Gravity Forms Documentation\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/docs.gravityforms.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#organization\",\"name\":\"Gravity Forms\",\"url\":\"https:\\\/\\\/docs.gravityforms.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/docs.gravityforms.com\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/gravity-forms-2020-logo-stacked.png\",\"contentUrl\":\"https:\\\/\\\/docs.gravityforms.com\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/gravity-forms-2020-logo-stacked.png\",\"width\":392,\"height\":515,\"caption\":\"Gravity Forms\"},\"image\":{\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/gravityforms\",\"http:\\\/\\\/@gravityforms.com\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/docs.gravityforms.com\\\/#\\\/schema\\\/person\\\/8a88745ec2ee5bc1bb24eea8634bf376\",\"name\":\"Justin Pakes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/791cb5bec00c6dd4bec2e80cf4df9638297207d8f77890c96b6b483be434ecea?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/791cb5bec00c6dd4bec2e80cf4df9638297207d8f77890c96b6b483be434ecea?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/791cb5bec00c6dd4bec2e80cf4df9638297207d8f77890c96b6b483be434ecea?s=96&d=mm&r=g\",\"caption\":\"Justin Pakes\"},\"url\":\"https:\\\/\\\/docs.gravityforms.com\\\/author\\\/pakes\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"GF_Field_Quantity - Gravity Forms Documentation","description":"Need to create a custom Quantity field within Gravity Forms for handling your product quantities? The GF_Field_Quantity class is what you're looking for.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/docs.gravityforms.com\/gf_field_quantity\/","og_locale":"en_US","og_type":"article","og_title":"GF_Field_Quantity","og_description":"Need to create a custom Quantity field within Gravity Forms for handling your product quantities? The GF_Field_Quantity class is what you're looking for.","og_url":"https:\/\/docs.gravityforms.com\/gf_field_quantity\/","og_site_name":"Gravity Forms Documentation","article_published_time":"2016-05-17T22:26:08+00:00","article_modified_time":"2019-04-12T13:57:38+00:00","og_image":[{"width":544,"height":288,"url":"https:\/\/docs.gravityforms.com\/wp-content\/uploads\/2023\/08\/gf-docs-default-v3.png","type":"image\/png"}],"author":"Justin Pakes","twitter_card":"summary_large_image","twitter_creator":"@gravityforms","twitter_site":"@gravityforms","twitter_misc":{"Written by":"Justin Pakes","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/docs.gravityforms.com\/gf_field_quantity\/#article","isPartOf":{"@id":"https:\/\/docs.gravityforms.com\/gf_field_quantity\/"},"author":{"name":"Justin Pakes","@id":"https:\/\/docs.gravityforms.com\/#\/schema\/person\/8a88745ec2ee5bc1bb24eea8634bf376"},"headline":"GF_Field_Quantity","datePublished":"2016-05-17T22:26:08+00:00","dateModified":"2019-04-12T13:57:38+00:00","mainEntityOfPage":{"@id":"https:\/\/docs.gravityforms.com\/gf_field_quantity\/"},"wordCount":461,"publisher":{"@id":"https:\/\/docs.gravityforms.com\/#organization"},"articleSection":["Field Classes"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/docs.gravityforms.com\/gf_field_quantity\/","url":"https:\/\/docs.gravityforms.com\/gf_field_quantity\/","name":"GF_Field_Quantity - Gravity Forms Documentation","isPartOf":{"@id":"https:\/\/docs.gravityforms.com\/#website"},"datePublished":"2016-05-17T22:26:08+00:00","dateModified":"2019-04-12T13:57:38+00:00","description":"Need to create a custom Quantity field within Gravity Forms for handling your product quantities? The GF_Field_Quantity class is what you're looking for.","breadcrumb":{"@id":"https:\/\/docs.gravityforms.com\/gf_field_quantity\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/docs.gravityforms.com\/gf_field_quantity\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/docs.gravityforms.com\/gf_field_quantity\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/docs.gravityforms.com\/"},{"@type":"ListItem","position":2,"name":"GF_Field_Quantity"}]},{"@type":"WebSite","@id":"https:\/\/docs.gravityforms.com\/#website","url":"https:\/\/docs.gravityforms.com\/","name":"Gravity Forms Documentation","description":"","publisher":{"@id":"https:\/\/docs.gravityforms.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/docs.gravityforms.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/docs.gravityforms.com\/#organization","name":"Gravity Forms","url":"https:\/\/docs.gravityforms.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/docs.gravityforms.com\/#\/schema\/logo\/image\/","url":"https:\/\/docs.gravityforms.com\/wp-content\/uploads\/2020\/01\/gravity-forms-2020-logo-stacked.png","contentUrl":"https:\/\/docs.gravityforms.com\/wp-content\/uploads\/2020\/01\/gravity-forms-2020-logo-stacked.png","width":392,"height":515,"caption":"Gravity Forms"},"image":{"@id":"https:\/\/docs.gravityforms.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/gravityforms","http:\/\/@gravityforms.com"]},{"@type":"Person","@id":"https:\/\/docs.gravityforms.com\/#\/schema\/person\/8a88745ec2ee5bc1bb24eea8634bf376","name":"Justin Pakes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/791cb5bec00c6dd4bec2e80cf4df9638297207d8f77890c96b6b483be434ecea?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/791cb5bec00c6dd4bec2e80cf4df9638297207d8f77890c96b6b483be434ecea?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/791cb5bec00c6dd4bec2e80cf4df9638297207d8f77890c96b6b483be434ecea?s=96&d=mm&r=g","caption":"Justin Pakes"},"url":"https:\/\/docs.gravityforms.com\/author\/pakes\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pdGaEa-2FD","_links":{"self":[{"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/posts\/10269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/comments?post=10269"}],"version-history":[{"count":0,"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/posts\/10269\/revisions"}],"wp:attachment":[{"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/media?parent=10269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/categories?post=10269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.gravityforms.com\/wp-json\/wp\/v2\/tags?post=10269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}