{"id":1193668,"date":"2016-11-16T21:03:43","date_gmt":"2016-11-17T05:03:43","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/"},"modified":"2016-11-16T21:03:43","modified_gmt":"2016-11-17T05:03:43","slug":"help-adding-buttons-to-ticket-form","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/","title":{"rendered":"Help adding +\/- buttons to ticket form"},"content":{"rendered":"<p>I am attempting to add plus and minus buttons to the quantity field in Event Tickets Plus &#8211; Woocommerce.  While I can get the buttons to appear on the page, I don&#8217;t seem to be able to tag in the Javascript to make it work.<\/p>\n<p>Code for the buttons is simple enough:<\/p>\n<pre><code>&lt;input class=&quot;plus&quot; type=&quot;button&quot; value=&quot;+&quot;&gt;\n&lt;input class=&quot;minus&quot; type=&quot;button&quot; value=&quot;-&quot;&gt;<\/code><\/pre>\n<p>Javascript (loaded at the top of the tickets.php page:<\/p>\n<pre><code>&lt;script type=&quot;text\/javascript&quot;&gt;\n    jQuery(document).ready(function($){\n        $(&#039;.woocommerce_quantity_input&#039;).on(&#039;click&#039;, &#039;.plus&#039;, function(e) {\n            $input = $(this).prev(&#039;input.qty&#039;);\n            var val = parseInt($input.val());\n            $input.val( val+1 ).change();\n        });\n \n        $(&#039;.woocommerce_quantity_input&#039;).on(&#039;click&#039;, &#039;.minus&#039;, \n            function(e) {\n            $input = $(this).next(&#039;input.qty&#039;);\n            var val = parseInt($input.val());\n            if (val &gt; 0) {\n                $input.val( val-1 ).change();\n            } \n        });\n    });\n    &lt;\/script&gt;<\/code><\/pre>\n<p>And the full code for the template page:<\/p>\n<pre><code>&lt;?php\n\/**\n * Renders the WooCommerce tickets table\/form\n *\n * @version 4.3.2\n *\n * @var bool $global_stock_enabled\n * @var bool $must_login\n *\/\nglobal $woocommerce;\n\n$is_there_any_product         = false;\n$is_there_any_product_to_sell = false;\n$unavailability_messaging     = is_callable( array( $this, &#039;do_not_show_tickets_unavailable_message&#039; ) );\n\nob_start();\n\n\/**\n * Filter classes on the Cart Form\n *\n * @since  4.3.2\n *\n * @param array $cart_classes\n *\/\n$cart_classes = (array) apply_filters( &#039;tribe_events_tickets_woo_cart_class&#039;, array( &#039;cart&#039; ) );\n?&gt;\n&lt;script type=&quot;text\/javascript&quot;&gt;\n    jQuery(document).ready(function($){\n        $(&#039;.woocommerce_quantity_input&#039;).on(&#039;click&#039;, &#039;.plus&#039;, function(e) {\n            $input = $(this).prev(&#039;input.qty&#039;);\n            var val = parseInt($input.val());\n            $input.val( val+1 ).change();\n        });\n \n        $(&#039;.woocommerce_quantity_input&#039;).on(&#039;click&#039;, &#039;.minus&#039;, \n            function(e) {\n            $input = $(this).next(&#039;input.qty&#039;);\n            var val = parseInt($input.val());\n            if (val &gt; 0) {\n                $input.val( val-1 ).change();\n            } \n        });\n    });\n    &lt;\/script&gt;\n&lt;form action=&quot;&lt;?php echo esc_url( $woocommerce-&gt;cart-&gt;get_cart_url() ) ?&gt;&quot; class=&quot;&lt;?php echo implode( &#039; &#039;, $cart_classes ); ?&gt;&quot; method=&quot;post&quot; enctype=&#039;multipart\/form-data&#039;&gt;\n\t&lt;h2 class=&quot;tribe-events-tickets-title&quot;&gt;&lt;?php esc_html_e( &#039;Tickets&#039;, &#039;event-tickets-plus&#039; ) ?&gt;&lt;\/h2&gt;\n\n\t&lt;table width=&quot;100%&quot; class=&quot;tribe-events-tickets&quot;&gt;\n\t\t&lt;?php\n\t\tforeach ( $tickets as $ticket ) {\n\t\t\t\/**\n\t\t\t * @var Tribe__Tickets__Ticket_Object $ticket\n\t\t\t * @var WC_Product $product\n\t\t\t *\/\n\t\t\tglobal $product;\n\n\t\t\tif ( class_exists( &#039;WC_Product_Simple&#039; ) ) {\n\t\t\t\t$product = new WC_Product_Simple( $ticket-&gt;ID );\n\t\t\t} else {\n\t\t\t\t$product = new WC_Product( $ticket-&gt;ID );\n\t\t\t}\n\n\t\t\tif ( $ticket-&gt;date_in_range( current_time( &#039;timestamp&#039; ) ) ) {\n\n\t\t\t\t$is_there_any_product = true;\n\t\t\t\t$data_product_id = &#039;data-product-id=&quot;&#039; . esc_attr( $ticket-&gt;ID ) . &#039;&quot;&#039;;\n\n\t\t\t\techo sprintf( &#039;&lt;input type=&quot;hidden&quot; name=&quot;product_id[]&quot; value=&quot;%d&quot;&gt;&#039;, esc_attr( $ticket-&gt;ID ) );\n\n\t\t\t\techo &#039;&lt;tr&gt;&lt;td width=&quot;20px&quot;&gt;&lt;input class=&quot;plus&quot; type=&quot;button&quot; value=&quot;+&quot;&gt;&lt;br&gt;&lt;input class=&quot;minus&quot; type=&quot;button&quot; value=&quot;-&quot;&gt;&lt;\/td&gt;&#039;;\n\n\t\t\t\t\/**\n\t\t\t\t * Filter classes on the Price column\n\t\t\t\t *\n\t\t\t\t * @since  4.3.2\n\t\t\t\t *\n\t\t\t\t * @param array $column_classes\n\t\t\t\t *\/\n\t\t\t\t$column_classes = (array) apply_filters( &#039;tribe_events_tickets_woo_quantity_column_class&#039;, array( &#039;woocommerce&#039; ) );\n\t\t\t\techo &#039;&lt;td class=&quot;&#039; . implode( &#039; &#039;, $column_classes ) . &#039;&quot; &#039; . $data_product_id . &#039;&gt;&#039;;\n\n\t\t\t\tif ( $product-&gt;is_in_stock() ) {\n\t\t\t\t\t\/\/ Max quantity will be left open if backorders allowed, restricted to 1 if the product is\n\t\t\t\t\t\/\/ constrained to be sold individually or else set to the available stock quantity\n\t\t\t\t\t$max_quantity = $product-&gt;backorders_allowed() ? &#039;&#039; : $product-&gt;get_stock_quantity();\n\t\t\t\t\t$max_quantity = $product-&gt;is_sold_individually() ? 1 : $max_quantity;\n\t\t\t\t\t$original_stock = $ticket-&gt;original_stock();\n\n\t\t\t\t\t\/\/ For global stock enabled tickets with a cap, use the cap as the max quantity\n\t\t\t\t\tif ( $global_stock_enabled &amp;&amp; Tribe__Tickets__Global_Stock::CAPPED_STOCK_MODE === $ticket-&gt;global_stock_mode()) {\n\t\t\t\t\t\t$max_quantity = $ticket-&gt;global_stock_cap();\n\t\t\t\t\t\t$original_stock = $ticket-&gt;global_stock_cap();\n\t\t\t\t\t}\n\n\t\t\t\t\twoocommerce_quantity_input( array(\n\t\t\t\t\t\t&#039;input_name&#039;  =&gt; &#039;quantity_&#039; . $ticket-&gt;ID,\n\t\t\t\t\t\t&#039;input_value&#039; =&gt; 0,\n\t\t\t\t\t\t&#039;min_value&#039;   =&gt; 1,\n\t\t\t\t\t\t&#039;max_value&#039;   =&gt; $must_login ? 0 : $max_quantity, \/\/ Currently WC does not support a &#039;disable&#039; attribute\n\t\t\t\t\t) );\n\n\t\t\t\t\t$is_there_any_product_to_sell = true;\n\n\t\t\t\t\t$remaining = $ticket-&gt;remaining();\n\n\t\t\t\t\tif ( $remaining ) {\n\t\t\t\t\t\t?&gt;\n\t\t\t\t\t\t&lt;span class=&quot;tribe-tickets-remaining&quot;&gt;\n\t\t\t\t\t\t\t&lt;?php\n\t\t\t\t\t\t\techo sprintf( esc_html__( &#039;%1$s tickets available&#039;, &#039;event-tickets-plus&#039; ),\n\t\t\t\t\t\t\t\t&#039;&lt;span class=&quot;available-stock&quot; &#039; . $data_product_id . &#039;&gt;&#039; . esc_html( $remaining ) . &#039;&lt;\/span&gt;&#039;\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t?&gt;\n\n\t\t\t\t\t\t&lt;\/span&gt;\n\t\t\t\t\t\t&lt;?php\n\t\t\t\t\t}\n\n\t\t\t\t\tdo_action( &#039;wootickets_tickets_after_quantity_input&#039;, $ticket, $product );\n\t\t\t\t} else {\n\t\t\t\t\techo &#039;&lt;span class=&quot;tickets_nostock&quot;&gt;&#039; . esc_html__( &#039;Out of stock!&#039;, &#039;event-tickets-plus&#039; ) . &#039;&lt;\/span&gt;&#039;;\n\t\t\t\t}\n\t\t\t\techo &#039;&lt;\/td&gt;&#039;;\n\n\t\t\t\techo &#039;&lt;td class=&quot;tickets_name&quot;&gt;&#039;;\n\t\t\t\techo $ticket-&gt;name;\n\t\t\t\techo &#039;&lt;\/td&gt;&#039;;\n\n\t\t\t\techo &#039;&lt;td class=&quot;tickets_price&quot;&gt;&#039;;\n\t\t\t\techo $this-&gt;get_price_html( $product );\n\t\t\t\techo &#039;&lt;\/td&gt;&#039;;\n\n\t\t\t\techo &#039;&lt;td class=&quot;tickets_description&quot;&gt;&#039;;\n\t\t\t\techo $ticket-&gt;description;\n\t\t\t\techo &#039;&lt;\/td&gt;&#039;;\n\n\t\t\t\techo &#039;&lt;\/tr&gt;&#039;;\n\n\t\t\t\tif ( class_exists( &#039;Tribe__Tickets_Plus__Attendees_List&#039; ) &amp;&amp; ! Tribe__Tickets_Plus__Attendees_List::is_hidden_on( get_the_ID() ) ) {\n\t\t\t\t\techo &#039;&lt;tr class=&quot;tribe-tickets-attendees-list-optout&quot;&gt;&#039; . &#039;&lt;td colspan=&quot;4&quot;&gt;&#039; .\n\t\t\t\t\t\t &#039;&lt;input type=&quot;checkbox&quot; name=&quot;optout_&#039; . $ticket-&gt;ID . &#039;&quot; id=&quot;tribe-tickets-attendees-list-optout-woo&quot;&gt;&#039; .\n\t\t\t\t\t\t &#039;&lt;label for=&quot;tribe-tickets-attendees-list-optout-woo&quot;&gt;&#039; . esc_html__( &#039;Don\\&#039;t list me on the public attendee list&#039;, &#039;event-tickets&#039; ) . &#039;&lt;\/label&gt;&#039; . &#039;&lt;\/td&gt;&#039; .\n\t\t\t\t\t\t &#039;&lt;\/tr&gt;&#039;;\n\t\t\t\t}\n\n\t\t\t\tinclude Tribe__Tickets_Plus__Main::instance()-&gt;get_template_hierarchy( &#039;meta.php&#039; );\n\t\t\t}\n\t\t}\n\n\t\tif ( $is_there_any_product_to_sell ) {\n\t\t\t?&gt;\n\t\t\t&lt;tr&gt;\n\t\t\t\t&lt;td colspan=&quot;4&quot; class=&quot;woocommerce add-to-cart&quot;&gt;\n\t\t\t\t\t&lt;?php if ( $must_login ): ?&gt;\n\t\t\t\t\t\t&lt;?php include Tribe__Tickets_Plus__Main::instance()-&gt;get_template_hierarchy( &#039;login-to-purchase&#039; ); ?&gt;\n\t\t\t\t\t&lt;?php else: ?&gt;\n\t\t\t\t\t\t&lt;button type=&quot;submit&quot; name=&quot;wootickets_process&quot; value=&quot;1&quot;\n\t\t\t\t\t\t\tclass=&quot;button alt&quot;&gt;&lt;?php esc_html_e( &#039;Add to cart&#039;, &#039;event-tickets-plus&#039; );?&gt;&lt;\/button&gt;\n\t\t\t\t\t&lt;?php endif; ?&gt;\n\t\t\t\t&lt;\/td&gt;\n\t\t\t&lt;\/tr&gt;\n\t\t\t&lt;?php\n\t\t} ?&gt;\n\t&lt;\/table&gt;\n&lt;\/form&gt;\n\n&lt;?php\n$content = ob_get_clean();\nif ( $is_there_any_product ) {\n\techo $content;\n\n\t\/\/ @todo remove safeguard in 4.3 or later\n\tif ( $unavailability_messaging ) {\n\t\t\/\/ If we have rendered tickets there is generally no need to display a &#039;tickets unavailable&#039; message\n\t\t\/\/ for this post\n\t\t$this-&gt;do_not_show_tickets_unavailable_message();\n\t}\n} else {\n\t\/\/ @todo remove safeguard in 4.3 or later\n\tif ( $unavailability_messaging ) {\n\t\t$unavailability_message = $this-&gt;get_tickets_unavailable_message( $tickets );\n\n\t\t\/\/ if there isn&#039;t an unavailability message, bail\n\t\tif ( ! $unavailability_message ) {\n\t\t\treturn;\n\t\t}\n\t}\n}<\/code><\/pre>\n<p>What am I missing?  Does the javascript need to call to a different function name?<\/p>\n<p>The code I am using was culled from a Woocommerce guide to accomplish the same effect.  Obviously, it needs to  be altered for TEC Event Tickets Plus, but if I can link the buttons to the right quantity field, it SHOULD work.<\/p>\n<p>Any help would be appreciated.<\/p>\n<p>NOTE: To anyone else trying to use this code in the future, you&#8217;ll still want to style your +\/- with CSS.  I&#8217;ll link my code later once we actually get it working.<\/p>\n","protected":false},"template":"","class_list":["post-1193668","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>Help adding +\/- buttons to ticket form -<\/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\/help-adding-buttons-to-ticket-form\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Help adding +\/- buttons to ticket form -\" \/>\n<meta property=\"og:description\" content=\"I am attempting to add plus and minus buttons to the quantity field in Event Tickets Plus &#8211; Woocommerce. While I can get the buttons to appear on the page, I don&#8217;t seem to be able to tag in the Javascript to make it work. Code for the buttons is simple enough: &lt;input class=&quot;plus&quot; type=&quot;button&quot; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/\" \/>\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=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/\",\"name\":\"Help adding +\/- buttons to ticket form -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2016-11-17T05:03:43+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/#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\":\"Help adding +\/- buttons to ticket form\"}]},{\"@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":"Help adding +\/- buttons to ticket form -","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\/help-adding-buttons-to-ticket-form\/","og_locale":"en_US","og_type":"article","og_title":"Help adding +\/- buttons to ticket form -","og_description":"I am attempting to add plus and minus buttons to the quantity field in Event Tickets Plus &#8211; Woocommerce. While I can get the buttons to appear on the page, I don&#8217;t seem to be able to tag in the Javascript to make it work. Code for the buttons is simple enough: &lt;input class=&quot;plus&quot; type=&quot;button&quot; [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/","name":"Help adding +\/- buttons to ticket form -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2016-11-17T05:03:43+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/help-adding-buttons-to-ticket-form\/#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":"Help adding +\/- buttons to ticket form"}]},{"@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\/1193668","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\/1193668\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1193668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}