{"id":2646,"date":"2015-12-14T05:54:18","date_gmt":"2015-12-14T05:54:18","guid":{"rendered":"http:\/\/musilda.cz\/?p=2646"},"modified":"2015-12-14T05:54:18","modified_gmt":"2015-12-14T05:54:18","slug":"jak-zobrazit-sazbu-dane-produktu-ve-woocommerce","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/jak-zobrazit-sazbu-dane-produktu-ve-woocommerce\/","title":{"rendered":"Jak zobrazit sazbu dan\u011b produktu ve WooCommerce"},"content":{"rendered":"

P\u0159i zobrazen\u00ed produktu ve WooCommerce, je pom\u011brn\u011b jednoduch\u00e9 zobrazit v\u00fd\u0161i DPH z ceny produktu. V\u011bt\u0161\u00ed probl\u00e9m, je ale zobrazit sazbu dan\u011b, pro konkr\u00e9tn\u00ed produkt.<\/p>\n

P\u016fvodn\u011b tento dotaz zazn\u011bl na Facebooku, kde jsem na n\u011bj odpov\u011bd\u011bl. Autor dotazu v\u0161ak nijak nereagoval a proto\u017ee jsem zrovna tento t\u00fdden, pot\u0159eboval \u0159e\u0161it podobn\u00fd probl\u00e9m, v tomto \u010dl\u00e1nku si uk\u00e1\u017eeme jednoduch\u00fd snippet, kter\u00fd sazbu zobraz\u00ed.<\/p>\n

Nebudu zde zapisovat \u017e\u00e1dnou funkci, script si vlo\u017ete do vlastn\u00ed funkce a vyu\u017eijte takov\u00fd hook, jak\u00fd pot\u0159ebujete.<\/p>\n

Jedin\u00e9, co budete pot\u0159ebovat, je id produktu. Proto\u017ee je produkt custom post type, m\u016f\u017eete pou\u017e\u00edt i „global $post;“.<\/p>\n

$_product = new WC_Product($post->ID);\n$tax_rates  = WC_Tax::get_rates( $_product->get_tax_class() );\n      if(!empty($tax_rates)){\n            foreach($tax_rates as $tax ){\n                $dph   = $tax['rate'];\n                $nazev = $tax['label'];\n            }\n      }\n<\/pre>\n

V prom\u011bnn\u00e9 $dph je sazba dan\u011b, v $nazev je jej\u00ed jm\u00e9no.<\/p>\n

A\u0165 slou\u017e\u00ed.<\/p>\n\n\n

Dal\u0161\u00ed u\u017eite\u010dn\u00e9 snippety najdete na str\u00e1nce U\u017eite\u010dn\u00e9 snippety pro WooCommerce<\/a><\/strong> <\/p>\n","protected":false},"excerpt":{"rendered":"

P\u0159i zobrazen\u00ed produktu ve WooCommerce, je pom\u011brn\u011b jednoduch\u00e9 zobrazit v\u00fd\u0161i DPH z ceny produktu. V\u011bt\u0161\u00ed probl\u00e9m, je ale zobrazit sazbu dan\u011b, pro konkr\u00e9tn\u00ed produkt. P\u016fvodn\u011b tento dotaz zazn\u011bl na Facebooku, kde jsem na n\u011bj odpov\u011bd\u011bl. Autor dotazu v\u0161ak nijak nereagoval a proto\u017ee jsem zrovna tento t\u00fdden, pot\u0159eboval \u0159e\u0161it podobn\u00fd probl\u00e9m, v tomto \u010dl\u00e1nku si uk\u00e1\u017eeme<\/p>\n","protected":false},"author":1,"featured_media":2635,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,25,29],"tags":[122],"class_list":["post-2646","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippety","category-woocommerce","category-woocommerce-snippety","tag-dph-produktu"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2646"}],"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=2646"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/2646\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/2635"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=2646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=2646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=2646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}