{"id":71,"date":"2021-05-01T20:05:50","date_gmt":"2021-05-01T18:05:50","guid":{"rendered":"https:\/\/alessandromasciadri.com\/?p=71"},"modified":"2022-07-21T19:03:19","modified_gmt":"2022-07-21T17:03:19","slug":"come-rimuovere-in-woocommerce-il-testo-opzionale-dai-campi","status":"publish","type":"post","link":"https:\/\/alessandromasciadri.com\/come-rimuovere-in-woocommerce-il-testo-opzionale-dai-campi\/","title":{"rendered":"Come rimuovere in WooCommerce il testo (opzionale) dai campi"},"content":{"rendered":"\t\t<div data-akihiro-type=\"ama-post\" data-akihiro-id=\"71\" class=\"akihiro akihiro-71\" data-akihiro-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"akihiro-section akihiro-top-section akihiro-element akihiro-element-5653873c akihiro-section-boxed akihiro-section-height-default akihiro-section-height-default\" data-id=\"5653873c\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"akihiro-container akihiro-column-gap-default\">\n\t\t\t\t\t<div class=\"akihiro-column akihiro-col-100 akihiro-top-column akihiro-element akihiro-element-2ccdd1f6\" data-id=\"2ccdd1f6\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"akihiro-widget-wrap akihiro-element-populated\">\n\t\t\t\t\t\t<div class=\"akihiro-element akihiro-element-9f3fa42 akihiro-widget akihiro-widget-text-editor\" data-id=\"9f3fa42\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"akihiro-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>WooCommere \u00e8 un eccellente plugin che permette di amministrare un ecommerce utilizzando il motore WordPress.<\/p>\n<p>Nella circostanza in cui sia necessario rimuovere il testo Opzionale di un campo in un form di acquisto WooCommerce, possiamo utilizzare un code snippet come il seguente.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"akihiro-element akihiro-element-b4caa9f akihiro-widget akihiro-widget-code-highlight\" data-id=\"b4caa9f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t<div class=\"akihiro-widget-container\">\n\t\t\t\t\t\t\t<div class=\"prismjs-okaidia copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-php line-numbers\">\n\t\t\t\t<code readonly=\"true\" class=\"language-php\">\n\t\t\t\t\t<xmp>add_filter('woocommerce_form_field', 'elex_remove_checkout_optional_text', 10, 4);\r\nfunction elex_remove_checkout_optional_text($field, $key, $args, $value) {\r\n\tif(is_checkout() && ! is_wc_endpoint_url()) {\r\n\t\t$optional = '&nbsp;<span class=\"optional\">(' . esc_html__('optional', 'woocommerce') . ')<\/span>';\r\n\t\t$field = str_replace($optional, '', $field);\r\n\t}\r\n\treturn $field;\r\n}<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"akihiro-element akihiro-element-800c8b6 akihiro-widget akihiro-widget-text-editor\" data-id=\"800c8b6\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"akihiro-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Questo snippet pu\u00f2 essere aggiunto direttamente nel file functions.php del proprio tema attivo. Si ricorda per\u00f2 che in questo caso \u00e8 necessario utilizzare un tema child al fine di prevenire la sovrascrittura in caso di aggiornamento del tema.<\/p>\n<p>La migliore alternativa \u00e8 comunque sempre quella di non mettere mano direttamente al file functions.php, bens\u00ec di passare tramite la mediazione di un plugin come il consigliatissimo Code Snippets.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>WooCommere \u00e8 un eccellente plugin che permette di amministrare un ecommerce utilizzando il motore WordPress. Nella circostanza in cui sia necessario rimuovere il testo Opzionale di un campo in un form di acquisto WooCommerce, possiamo utilizzare un code snippet come il seguente. add_filter(&#8216;woocommerce_form_field&#8217;, &#8216;elex_remove_checkout_optional_text&#8217;, 10, 4); function elex_remove_checkout_optional_text($field, $key, $args, $value) { if(is_checkout() &#038;&#038; ! [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[2,11,10],"class_list":["post-71","post","type-post","status-publish","format-standard","hentry","category-programmazione","tag-code","tag-woocommerce","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/alessandromasciadri.com\/ama-json\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alessandromasciadri.com\/ama-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alessandromasciadri.com\/ama-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alessandromasciadri.com\/ama-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alessandromasciadri.com\/ama-json\/wp\/v2\/comments?post=71"}],"version-history":[{"count":6,"href":"https:\/\/alessandromasciadri.com\/ama-json\/wp\/v2\/posts\/71\/revisions"}],"predecessor-version":[{"id":889,"href":"https:\/\/alessandromasciadri.com\/ama-json\/wp\/v2\/posts\/71\/revisions\/889"}],"wp:attachment":[{"href":"https:\/\/alessandromasciadri.com\/ama-json\/wp\/v2\/media?parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alessandromasciadri.com\/ama-json\/wp\/v2\/categories?post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alessandromasciadri.com\/ama-json\/wp\/v2\/tags?post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}