{"id":6574,"date":"2022-01-06T10:00:00","date_gmt":"2022-01-06T10:00:00","guid":{"rendered":"https:\/\/musilda.cz\/?p=6574"},"modified":"2022-01-06T10:00:00","modified_gmt":"2022-01-06T10:00:00","slug":"rozepsani-celkove-ceny-objednavky-bez-a-s-dph-ve-woocommerce-e-mailu","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/rozepsani-celkove-ceny-objednavky-bez-a-s-dph-ve-woocommerce-e-mailu\/","title":{"rendered":"Rozeps\u00e1n\u00ed celkov\u00e9 ceny objedn\u00e1vky bez a s DPH ve WooCommerce e-mailu"},"content":{"rendered":"\n

V p\u0159\u00edpad\u011b, \u017ee prod\u00e1v\u00e1te zbo\u017e\u00ed a jste pl\u00e1tci DPH, mo\u017en\u00e1 budete cht\u00edt, aby se v e-mailu zobrazovaly vy\u010d\u00edslen\u00e9 celkov\u00e9 sou\u010dty bez dan\u011b a s dan\u00ed. Uk\u00e1\u017eeme si, jak na to. <\/p>\n\n\n\n

V p\u0159edchoz\u00edm \u010dl\u00e1nku jsme si ukazovali, jak editovat soubory \u0161ablony e-mailu, tak\u017ee to si ji\u017e ukazovat nebudeme a rovnou si p\u0159edstav\u00edme postup.<\/p>\n\n\n\n

V z\u00e1kladu vypadaj\u00ed sou\u010dty takto:<\/p>\n\n\n\n

\"\"<\/a><\/figure>\n\n\n\n

K\u00f3d vypad\u00e1 takto:<\/p>\n\n\n\n

$item_totals = $order->get_order_item_totals();\n\nif ( $item_totals ) {\n\t$i = 0;\n\tforeach ( $item_totals as $total ) {\n\t\t$i++;\n\t\t?>\n\t\t<tr>\n\t\t\t<th class=\"td\" scope=\"row\" colspan=\"3\" style=\"text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>\"><?php echo wp_kses_post( $total['label'] ); ?><\/th>\n\t\t\t<td class=\"td\" style=\"text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>\"><?php echo wp_kses_post( $total['value'] ); ?><\/td>\n\t\t<\/tr>\n\t\t<?php\n\t}\n}<\/code><\/pre>\n\n\n\n

Z k\u00f3du je z\u0159ejm\u00e9, \u017ee polo\u017eek „totals“ je v\u00edce ne\u017e jedna. My budeme hledat totals s key order_total<\/strong>. K\u00f3d uprav\u00edme n\u00e1sledovn\u011b:<\/p>\n\n\n\n

foreach ( $item_totals as  $key => $total ) {\n\t$i++;\n\n\tif ( 'order_total' == $key ) {\n\n\t\t$order_total = $order->get_total();\n\t\t$tax_totals = $order->get_tax_totals();\n\t\t$total_tax = 0;\n\t\tforeach( $tax_totals as $tax_item ) {\n\t\t\t$total_tax += $tax_item->amount;\n\t\t}\n\t\t$without_tax = $order_total - $total_tax;\n\n\t?>\n\t<tr>\n\t\t<th class=\"td\" scope=\"row\" colspan=\"3\" data-key=\"<?php echo $key; ?>\" style=\"text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>\"><?php echo wp_kses_post( 'Celkem bez DPH:', 'musilda' ); ?><\/th>\n\t\t<td class=\"td\" style=\"text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>\"><?php echo wc_price( $without_tax ); ?><\/td>\n\t<\/tr>\n\t<tr>\n\t\t<th class=\"td\" scope=\"row\" colspan=\"3\" data-key=\"<?php echo $key; ?>\" style=\"text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>\"><?php echo wp_kses_post( $total['label'] ); ?><\/th>\n\t\t<td class=\"td\" style=\"text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>\"><?php echo wc_price( $order_total ); ?><\/td>\n\t<\/tr>\n\t<?php\n\t} else {\n\n\t?>\n\t<tr>\n\t\t<th class=\"td\" scope=\"row\" colspan=\"3\" data-key=\"<?php echo $key; ?>\" style=\"text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>\"><?php echo wp_kses_post( $total['label'] ); ?><\/th>\n\t\t<td class=\"td\" style=\"text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>\"><?php echo wp_kses_post( $total['value'] ); ?><\/td>\n\t<\/tr>\n\t<?php\n\t}\n}<\/code><\/pre>\n\n\n\n

V e-mailu to vypad\u00e1 n\u00e1sledovn\u011b:<\/p>\n\n\n\n

\"\"<\/a><\/figure>\n\n\n\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

V p\u0159\u00edpad\u011b, \u017ee prod\u00e1v\u00e1te zbo\u017e\u00ed a jste pl\u00e1tci DPH, mo\u017en\u00e1 budete cht\u00edt, aby se v e-mailu zobrazovaly vy\u010d\u00edslen\u00e9 celkov\u00e9 sou\u010dty bez dan\u011b a s dan\u00ed. Uk\u00e1\u017eeme si, jak na to. V p\u0159edchoz\u00edm \u010dl\u00e1nku jsme si ukazovali, jak editovat soubory \u0161ablony e-mailu, tak\u017ee to si ji\u017e ukazovat nebudeme a rovnou si p\u0159edstav\u00edme postup. V z\u00e1kladu vypadaj\u00ed<\/p>\n","protected":false},"author":1,"featured_media":5600,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"class_list":["post-6574","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\/6574"}],"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=6574"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/6574\/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=6574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=6574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=6574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}