{"id":1353705,"date":"2017-09-22T16:32:55","date_gmt":"2017-09-22T23:32:55","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/"},"modified":"2017-09-22T16:32:55","modified_gmt":"2017-09-22T23:32:55","slug":"woocommerce-cart-update-quantity-field","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/","title":{"rendered":"WooCommerce cart update quantity field"},"content":{"rendered":"<p>I found a forum post which showed a code snippet on how to disable the cart update quantity field because he had ticket meta fields that WooCommerce would not see. I used the code and it worked great, except when I applied a coupon it invalidated the code. I am only basically familar with the hooks and functions that are used and don&#8217;t have the knowledge to troubleshoot this. Is it a simple fix? The snippet is below:<\/p>\n<pre><code>\/**\n * Make WooCommerce cart Quantity input field non-editable (readonly) ONLY FOR Event Tickets Plus products\n *\n * By Matt B and Cliff P\n *\n * From https:\/\/gist.github.com\/cliffordp\/66bf05df61ee269c60ff20d6f39e2cab\n *\/\n      \nfunction cliff_etplus_woo_cart_quantity_readonly() {\n   \tif ( ! class_exists( &#039;Tribe__Tickets_Plus__Commerce__WooCommerce__Main&#039; ) ) {\n        return;\n    }\n    $args = array(\n        &#039;post_type&#039; =&gt; &#039;product&#039;,\n        &#039;fields&#039; =&gt; &#039;ids&#039;,\n        &#039;meta_query&#039; =&gt; array(\n            array(\n                &#039;key&#039; =&gt; Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance()-&gt;event_key,\n                &#039;value&#039; =&gt; 0,\n                &#039;compare&#039; =&gt; &#039;&gt;&#039;,\n            ),\n        ),\n    );\n    $product_ids_readonly = get_posts( $args );\n    $product_ids_readonly = array_unique( $product_ids_readonly );\n    if ( ! count( $product_ids_readonly ) ) {\n        return;\n    }\n    wp_enqueue_script( &#039;jquery&#039; );\n    ?&gt;\n    &lt;script&gt;\n        jQuery( function( $ ) {\n            var product_ids = &lt;?php echo json_encode( $product_ids_readonly ); ?&gt;;\n            var $remove_links = $( &#039;body.woocommerce-cart .woocommerce tr.cart_item td.product-remove a&#039; );\n            $remove_links.each( function() {\n                var product_id = parseInt( $( this ).data( &#039;product_id&#039; ), 10 );\n                if ( -1 === $.inArray( product_id, product_ids ) ) {\n                    return;\n                }\n                var $row = $( this ).closest( &#039;tr&#039; );\n                $row.find( &#039;td.product-quantity input&#039; ).attr( &#039;readonly&#039;, true );\n            } );\n        } );\n    &lt;\/script&gt;\n    &lt;?php\n}\nadd_action( &#039;wp_head&#039;, &#039;cliff_etplus_woo_cart_quantity_readonly&#039; );\n<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-1353705","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>WooCommerce cart update quantity field -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WooCommerce cart update quantity field -\" \/>\n<meta property=\"og:description\" content=\"I found a forum post which showed a code snippet on how to disable the cart update quantity field because he had ticket meta fields that WooCommerce would not see. I used the code and it worked great, except when I applied a coupon it invalidated the code. I am only basically familar with the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/\",\"name\":\"WooCommerce cart update quantity field -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2017-09-22T23:32:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Ticket Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Event Tickets Plus\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"WooCommerce cart update quantity field\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WooCommerce cart update quantity field -","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:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/","og_locale":"en_US","og_type":"article","og_title":"WooCommerce cart update quantity field -","og_description":"I found a forum post which showed a code snippet on how to disable the cart update quantity field because he had ticket meta fields that WooCommerce would not see. I used the code and it worked great, except when I applied a coupon it invalidated the code. I am only basically familar with the [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/","name":"WooCommerce cart update quantity field -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2017-09-22T23:32:55+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/woocommerce-cart-update-quantity-field\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Ticket Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/"},{"@type":"ListItem","position":4,"name":"Event Tickets Plus","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/"},{"@type":"ListItem","position":5,"name":"WooCommerce cart update quantity field"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1353705","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1353705\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1353705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}