{"id":29827,"date":"2026-02-04T09:29:34","date_gmt":"2026-02-04T09:29:34","guid":{"rendered":"https:\/\/makemehappy.sk\/?p=29827"},"modified":"2026-02-04T09:50:42","modified_gmt":"2026-02-04T09:50:42","slug":"woocommerce-suma-v-tlacidle-objednavky","status":"publish","type":"post","link":"https:\/\/makemehappy.sk\/en\/woocommerce-suma-v-tlacidle-objednavky\/","title":{"rendered":"Dynamic order button with total amount display"},"content":{"rendered":"<p class=\"wp-block-paragraph\">This handy snippet modifies the text of the main checkout button in your e-shop. Instead of the standard \u201eOrder with payment required\u201c or \u201eSubmit order\u201c, it also adds to the text <strong>the final amount<\/strong>, to be paid by the customer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From a psychological point of view, this is an excellent element - the customer has the exact amount in front of his eyes at the last step, which increases the transparency and credibility of the purchasing process.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"co-kod-robi\">What does the code do?<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>He's checking the basket:<\/strong> First, it verifies that the customer actually has something in the basket.<\/li>\n\n\n\n<li><strong>He takes over the finished amount:<\/strong> The code does not recalculate the amount, but takes the already calculated value directly from WooCommerce, which saves server performance.<\/li>\n\n\n\n<li><strong>Cleans formatting:<\/strong> Removes redundant HTML tags and correctly handles currency symbols (e.g. \u20ac) so that the text on the button displays correctly and cleanly.<\/li>\n\n\n\n<li><strong>Connects the text:<\/strong> The original text of the button \u201eOrder with payment required\u201c and adds after it \u201efor the AMOUNT \u20ac\u201c The result is a format of type: <em>\u201eOrder with payment obligation for 22,00 \u20ac\u201c<\/em>.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"721\" height=\"66\" src=\"https:\/\/makemehappy.sk\/wp-content\/uploads\/2026\/02\/Snimka-obrazovky-2026-02-04-101706.png\" alt=\"\" class=\"wp-image-29828\" title=\"\" srcset=\"https:\/\/makemehappy.sk\/wp-content\/uploads\/2026\/02\/Snimka-obrazovky-2026-02-04-101706.png 721w, https:\/\/makemehappy.sk\/wp-content\/uploads\/2026\/02\/Snimka-obrazovky-2026-02-04-101706-400x37.png 400w, https:\/\/makemehappy.sk\/wp-content\/uploads\/2026\/02\/Snimka-obrazovky-2026-02-04-101706-18x2.png 18w, https:\/\/makemehappy.sk\/wp-content\/uploads\/2026\/02\/Snimka-obrazovky-2026-02-04-101706-430x39.png 430w, https:\/\/makemehappy.sk\/wp-content\/uploads\/2026\/02\/Snimka-obrazovky-2026-02-04-101706-700x64.png 700w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"pouzitie\">Use<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Put the snippet into a file <code>functions.php<\/code> your active theme (ideally Child Theme) or use a snippet management plugin (e.g. <em>Code Snippets<\/em>).<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/makemehappy.sk\/en\/snippets\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to insert the code<\/a><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">PHP<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy of\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>add_filter( 'woocommerce_order_button_text', 'custom_checkout_button_text_optimized' );\n\nfunction custom_checkout_button_text_optimized( $button_text ) {\n\n    if ( WC()->cart &amp;&amp; ! WC()->cart->is_empty() ) {\n        \n        $total_string = WC()->cart->get_total();\n        \n        $clean_total = html_entity_decode( strip_tags( $total_string ) );\n        \n        return $button_text . ' za ' . $clean_total;\n    }\n    \n    return $button_text;\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewbox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #DCDCAA\">add_filter<\/span><span style=\"color: #D4D4D4\">( <\/span><span style=\"color: #CE9178\">'woocommerce_order_button_text'<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #CE9178\">'custom_checkout_button_text_optimized'<\/span><span style=\"color: #D4D4D4\"> );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">function<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">custom_checkout_button_text_optimized<\/span><span style=\"color: #D4D4D4\">( <\/span><span style=\"color: #9CDCFE\">$button_text<\/span><span style=\"color: #D4D4D4\"> ) {<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> ( <\/span><span style=\"color: #DCDCAA\">WC<\/span><span style=\"color: #D4D4D4\">()-&gt;<\/span><span style=\"color: #9CDCFE\">cart<\/span><span style=\"color: #D4D4D4\"> &amp;&amp; ! <\/span><span style=\"color: #DCDCAA\">WC<\/span><span style=\"color: #D4D4D4\">()-&gt;<\/span><span style=\"color: #9CDCFE\">cart<\/span><span style=\"color: #D4D4D4\">-&gt;<\/span><span style=\"color: #DCDCAA\">is_empty<\/span><span style=\"color: #D4D4D4\">() ) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #9CDCFE\">$total_string<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">WC<\/span><span style=\"color: #D4D4D4\">()-&gt;<\/span><span style=\"color: #9CDCFE\">cart<\/span><span style=\"color: #D4D4D4\">-&gt;<\/span><span style=\"color: #DCDCAA\">get_total<\/span><span style=\"color: #D4D4D4\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #9CDCFE\">$clean_total<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #DCDCAA\">html_entity_decode<\/span><span style=\"color: #D4D4D4\">( <\/span><span style=\"color: #DCDCAA\">strip_tags<\/span><span style=\"color: #D4D4D4\">( <\/span><span style=\"color: #9CDCFE\">$total_string<\/span><span style=\"color: #D4D4D4\"> ) );<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">$button_text<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">' for '<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">$clean_total<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">$button_text<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>","protected":false},"excerpt":{"rendered":"<p>Tento \u0161ikovn\u00fd snippet upravuje text hlavn\u00e9ho tla\u010didla v pokladni (Checkout) v\u00e1\u0161ho e-shopu. Namiesto \u0161tandardn\u00e9ho \u201eObjedna\u0165 s povinnos\u0165ou platby\u201c alebo \u201eOdosla\u0165 objedn\u00e1vku\u201c prid\u00e1 k textu aj fin\u00e1lnu sumu, ktor\u00fa m\u00e1 z\u00e1kazn\u00edk zaplati\u0165. Z psychologick\u00e9ho h\u013eadiska ide o v\u00fdborn\u00fd prvok \u2013 z\u00e1kazn\u00edk m\u00e1 v poslednom kroku pred o\u010dami presn\u00fa sumu, \u010do zvy\u0161uje transparentnos\u0165 a d\u00f4veryhodnos\u0165 n\u00e1kupn\u00e9ho procesu. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":29535,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gspb_post_css":"","footnotes":""},"categories":[105],"tags":[],"class_list":["post-29827","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippet"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/makemehappy.sk\/en\/wp-json\/wp\/v2\/posts\/29827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/makemehappy.sk\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/makemehappy.sk\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/makemehappy.sk\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/makemehappy.sk\/en\/wp-json\/wp\/v2\/comments?post=29827"}],"version-history":[{"count":4,"href":"https:\/\/makemehappy.sk\/en\/wp-json\/wp\/v2\/posts\/29827\/revisions"}],"predecessor-version":[{"id":29835,"href":"https:\/\/makemehappy.sk\/en\/wp-json\/wp\/v2\/posts\/29827\/revisions\/29835"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/makemehappy.sk\/en\/wp-json\/wp\/v2\/media\/29535"}],"wp:attachment":[{"href":"https:\/\/makemehappy.sk\/en\/wp-json\/wp\/v2\/media?parent=29827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/makemehappy.sk\/en\/wp-json\/wp\/v2\/categories?post=29827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/makemehappy.sk\/en\/wp-json\/wp\/v2\/tags?post=29827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}