{"id":117,"date":"2016-07-28T10:31:09","date_gmt":"2016-07-28T10:31:09","guid":{"rendered":"https:\/\/plugins.yithemes.com\/yith-woocommerce-barcodes\/?page_id=117"},"modified":"2016-09-21T15:15:56","modified_gmt":"2016-09-21T15:15:56","slug":"actions-on-product-barcodes","status":"publish","type":"page","link":"https:\/\/plugins.yithemes.com\/yith-woocommerce-barcodes\/shortcodes\/actions-on-product-barcodes\/","title":{"rendered":"Actions on product barcodes"},"content":{"rendered":"<p>YITH WooCommerce Barcodes lets you perform actions on products based on the barcodes generated, you have to simply use the following shortcode:<\/p>\n<pre>&#091;yith_product_barcode&#093;<\/pre>\n<p>With this shortcode you can show a text field where the user can enter a barcode value and perform some action, from some custom action like the search to customized actions hooked by third party plugins.<\/p>\n<p>The available parameter are the following:<\/p>\n<p><strong>&#8216;capability&#8217;<\/strong><br \/>\n(string) The capability needed in order to see this shortcode rendered on front end pages.<br \/>\nIt could be useful to allow only admins or shop managers to see and work with the shortcode area, hiding the shortcode results to all the other users.<br \/>\nDefault: &#8216;manage_woocommerce&#8217;<\/p>\n<p><strong>&#8216;actions&#8217;<\/strong><br \/>\n(string) A comma separated string with the list of the actions that could be performed on product based on their barcode value.<br \/>\nEvery action will be shown as a button and all custom actions need a third party code to manage the action itself.<br \/>\nDefault: &#8216;search&#8217;<\/p>\n<h4>Examples<\/h4>\n<h6>Show the shortcode area to all the users<\/h6>\n<p>You can choose to let everyone see and manage the content area rendered by the shortcode, setting the capability attribute as &#8216;all&#8217;.<br \/>\nThe following example will show the shortcode area to everyone.<\/p>\n<pre>&#091;yith_product_barcode capability=\"all\"&#093;<\/pre>\n<p>The result will be the following(use 994 as value for performing a search on product barcodes):<\/p>\n<div class=\"yith-barcode-actions\">\n\t<form class=\"ywbc-shortcode-form\" name=\"yith-barcodes-form\" method=\"post\" data-barcode-type=\"product\" data-barcode-actions='{&quot;increase-stock&quot;:true,&quot;decrease-stock&quot;:true}'>\n\t\t\t\t<p class=\"ywbc-shortcode-form-title\">Product barcode<\/p>\n\t\t<label class=\"ywbc-shortcode-form-label\">Type or scan the barcode value here<\/label>\n\t\t<input class=\"ywbc-shortcode-text-input\" type=\"text\" name=\"yith-barcode-value\" value=\"\" autofocus>\n\t<\/form>\n<\/div>\n\n<h6>Show the shortcode area only to user with capability &#8216;manage_woocommerce&#8217;<\/h6>\n<p>You can choose to let users to see the shortcode area only if they have a specific capability.<br \/>\nThe following example will show the shortcode area only to users with &#8216;manage_woocommerce&#8217; capability.<\/p>\n<pre>&#091;yith_product_barcode capability=\"manage_woocommerce\"&#093;<\/pre>\n<p>or leaving the capability attribute empty(the default value is &#8216;manage_woocommerce&#8217;<\/p>\n<pre>&#091;yith_product_barcode&#093;<\/pre>\n<p>The result will be:<\/p>\n<p><div class=\"yith-barcode-actions\">\n\t<form class=\"ywbc-shortcode-form\" name=\"yith-barcodes-form\" method=\"post\" data-barcode-type=\"product\" data-barcode-actions='{&quot;increase-stock&quot;:true,&quot;decrease-stock&quot;:true}'>\n\t\t\t\t<p class=\"ywbc-shortcode-form-title\">Product barcode<\/p>\n\t\t<label class=\"ywbc-shortcode-form-label\">Type or scan the barcode value here<\/label>\n\t\t<input class=\"ywbc-shortcode-text-input\" type=\"text\" name=\"yith-barcode-value\" value=\"\" autofocus>\n\t<\/form>\n<\/div>\n<br \/>\n<em>(if you do not see any content, you do not have enough capability).<br \/>\n<\/em><\/p>\n<h6>Show additional buttons in the shortcode area<\/h6>\n<p>There is a default action(&#8216;search&#8217;) that can be performed on products but it&#8217;s possible to add as many buttons, one for every additional actions, allowing third party plugins to manage their custom actions.<\/p>\n<p>The following example will show 3 buttons, labelled &#8216;search&#8217;, &#8216;increase stock&#8217;, &#8216;decrease stock&#8217;.<br \/>\nWhile the &#8216;search&#8217; button will perform really a search based on the barcode value entered, the other 2 buttons wont do anything because there aren&#8217;t any custom code associated to them.<\/p>\n<pre>&#091;yith_product_barcode actions=\"search, increase stock, decrease stock\"&#093;<\/pre>\n<p>The result will be:<\/p>\n<div class=\"yith-barcode-actions\">\n\t<form class=\"ywbc-shortcode-form\" name=\"yith-barcodes-form\" method=\"post\" data-barcode-type=\"product\" data-barcode-actions='&quot;search, increase stock, decrease stock&quot;'>\n\t\t\t\t<p class=\"ywbc-shortcode-form-title\">Product barcode<\/p>\n\t\t<label class=\"ywbc-shortcode-form-label\">Type or scan the barcode value here<\/label>\n\t\t<input class=\"ywbc-shortcode-text-input\" type=\"text\" name=\"yith-barcode-value\" value=\"\" autofocus>\n\t<\/form>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>YITH WooCommerce Barcodes lets you perform actions on products based on the barcodes generated, you have to simply use the following shortcode: &#091;yith_product_barcode&#093; With this shortcode you can show a text field where the user can enter a barcode value and perform some action, from some custom action like the search to customized actions hooked<a class=\"more-link\" href=\"https:\/\/plugins.yithemes.com\/yith-woocommerce-barcodes\/shortcodes\/actions-on-product-barcodes\/\">Read more  &#10230;<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"parent":173,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"footnotes":""},"class_list":["post-117","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/plugins.yithemes.com\/yith-woocommerce-barcodes\/wp-json\/wp\/v2\/pages\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/plugins.yithemes.com\/yith-woocommerce-barcodes\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/plugins.yithemes.com\/yith-woocommerce-barcodes\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/plugins.yithemes.com\/yith-woocommerce-barcodes\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/plugins.yithemes.com\/yith-woocommerce-barcodes\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":17,"href":"https:\/\/plugins.yithemes.com\/yith-woocommerce-barcodes\/wp-json\/wp\/v2\/pages\/117\/revisions"}],"predecessor-version":[{"id":199,"href":"https:\/\/plugins.yithemes.com\/yith-woocommerce-barcodes\/wp-json\/wp\/v2\/pages\/117\/revisions\/199"}],"up":[{"embeddable":true,"href":"https:\/\/plugins.yithemes.com\/yith-woocommerce-barcodes\/wp-json\/wp\/v2\/pages\/173"}],"wp:attachment":[{"href":"https:\/\/plugins.yithemes.com\/yith-woocommerce-barcodes\/wp-json\/wp\/v2\/media?parent=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}