{"id":6440,"date":"2021-11-02T20:22:10","date_gmt":"2021-11-02T20:22:10","guid":{"rendered":"https:\/\/musilda.cz\/?p=6440"},"modified":"2021-11-02T20:22:10","modified_gmt":"2021-11-02T20:22:10","slug":"jak-nastavit-vyber-zeme-jako-disabled-na-pokladne-woocommerce","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/jak-nastavit-vyber-zeme-jako-disabled-na-pokladne-woocommerce\/","title":{"rendered":"Jak nastavit v\u00fdb\u011br zem\u011b jako disabled na pokladn\u011b WooCommerce"},"content":{"rendered":"\n
Dne\u0161n\u00ed snippet umo\u017e\u0148uje nastavit jak\u00e9mukoliv poli na pokladn\u011b atribut disabled. <\/p>\n\n\n\n
Kdy\u017e budete hledat, jak nastavit pole jako disabled, najdete v\u011bt\u0161inou jen postupy, kter\u00e9 pomoc\u00ed javascriptu p\u0159idaj\u00ed inputu atribut. <\/p>\n\n\n\n
Na\u0161t\u011bst\u00ed je mo\u017en\u00e9 pou\u017e\u00edt filtr, kter\u00fd v\u00e1m umo\u017en\u00ed vstoupit p\u0159\u00edmo do pole atribut\u016f ka\u017ed\u00e9ho pole na pokladn\u011b. <\/p>\n\n\n\n
Sice atribut disabled v seznamu nen\u00ed, ale m\u016f\u017eete vyu\u017e\u00edt custom_attributes, pomoc\u00ed kter\u00e9ho m\u016f\u017eete p\u0159id\u00e1vat vlastn\u00ed atributy, jako je pr\u00e1v\u011b disabled, nebo data atributy. <\/p>\n\n\n\n
Samotn\u00fd snippet je jednoduch\u00fd:<\/p>\n\n\n\n
add_filter( 'woocommerce_form_field_args', 'musilda_billing_country', 10, 3 );\nfunction musilda_billing_country( $args, $key, $value ) {\n\n\tif ( 'billing_country' === $key ) {\n\t\tif ( !empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) {\n\t\t\t$args['custom_attributes']['disabled'] = 'disabled';\n\t\t} else {\n\t\t\t$args['custom_attributes'] = array( 'disabled' => 'disabled' );\n\t\t}\n\t}\n\n\treturn $args;\n\n}<\/code><\/pre>\n\n\n\nFiltr je vol\u00e1n ve funkci woocommerce_form_field a ta je pou\u017e\u00edv\u00e1na p\u0159i proch\u00e1zen\u00ed v\u0161ech billing a shipping input\u016f, tak\u017ee mus\u00edte zjistit pomoc\u00ed $key, zda se jedn\u00e1 o tan input, kter\u00fd pot\u0159ebujete. <\/p>\n\n\n\n
V\u00fdhoda tohoto filtru je, \u017ee se \u00faprava projev\u00ed i ve formul\u00e1\u0159i v nastaven\u00ed \u00fa\u010dtu u\u017eivatele.<\/p>\n","protected":false},"excerpt":{"rendered":"
Dne\u0161n\u00ed snippet umo\u017e\u0148uje nastavit jak\u00e9mukoliv poli na pokladn\u011b atribut disabled. Kdy\u017e budete hledat, jak nastavit pole jako disabled, najdete v\u011bt\u0161inou jen postupy, kter\u00e9 pomoc\u00ed javascriptu p\u0159idaj\u00ed inputu atribut. Na\u0161t\u011bst\u00ed je mo\u017en\u00e9 pou\u017e\u00edt filtr, kter\u00fd v\u00e1m umo\u017en\u00ed vstoupit p\u0159\u00edmo do pole atribut\u016f ka\u017ed\u00e9ho pole na pokladn\u011b. Sice atribut disabled v seznamu nen\u00ed, ale m\u016f\u017eete vyu\u017e\u00edt custom_attributes,<\/p>\n","protected":false},"author":1,"featured_media":5600,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[29],"tags":[],"class_list":["post-6440","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-woocommerce-snippety"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/6440"}],"collection":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/comments?post=6440"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/6440\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/5600"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=6440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=6440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=6440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}