{"id":58,"date":"2023-12-15T12:24:01","date_gmt":"2023-12-15T12:24:01","guid":{"rendered":"https:\/\/blog.hostinger.io\/es\/support\/2023\/12\/15\/8343753-hostinger-creador-de-sitios-web-como-cambiar-el-formato-del-precio-en-la-tienda-online\/"},"modified":"2025-08-26T20:48:03","modified_gmt":"2025-08-26T20:48:03","slug":"8343753-hostinger-creador-de-sitios-web-como-cambiar-el-formato-del-precio-en-la-tienda-online","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/es\/support\/8343753-hostinger-creador-de-sitios-web-como-cambiar-el-formato-del-precio-en-la-tienda-online\/","title":{"rendered":"Hostinger Creador de Sitios Web: C\u00f3mo Cambiar el Formato del Precio en la Tienda Online"},"content":{"rendered":"<p class=\"no-margin\">Este art&iacute;culo explica c&oacute;mo <b>cambiar el formato de los precios de los productos<\/b> en la tienda online creada con <b>Hostinger Website Builder<\/b>.<\/p><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">\n<p class=\"no-margin\">Los cambios ser&aacute;n visibles en las <b>secciones de la lista de productos<\/b>, en las <b>p&aacute;ginas de productos<\/b> y en la <b>bolsa de la compra<\/b>. Los precios predeterminados se seguir&aacute;n mostrando en la caja, las facturas y el &aacute;rea de gesti&oacute;n de la tienda &#128161;.<\/p>\n<\/div><p class=\"no-margin\">\n<\/p><h1 id=\"h_7307cf1086\">Copia el c&oacute;digo<\/h1><pre><code>&lt;script&gt;<br>    const currency = '&euro;';<br>    const thousandsSeparator = '.';<br>    const removeCents = false;<br>    const priceInTheEnd = false;<br>    let fullPrice;<br><br>    const addCommaToPrice = (price, currency) =&gt; {<br>        \/* currency at the end *\/<br>        if (price.innerText.slice(0, currency.length) !== currency) {<br>            fullPrice = price.innerText.substring(0, price.innerText.indexOf(currency));<br>        }<br>        \/* currency in front *\/ <br>        else {<br>            fullPrice = price.innerText.slice(currency.length);<br>        }<br><br>        \/* if cents exist *\/<br>        if (removeCents) {<br>            fullPrice = fullPrice.slice(0, -3);<br>        }<br>        fullPrice = fullPrice.toString().replace(\/\\B(?=(\\d{3})+(?!\\d))\/g, thousandsSeparator);<br><br>        if (priceInTheEnd) {<br>            fullPrice = `${fullPrice} ${currency}\\n`;<br>        } <br>        else {<br>            fullPrice = `${currency} ${fullPrice}\\n`;<br>        }<br><br>        price.innerText = fullPrice;<br>    };<br><br>    const priceChanged = (price) =&gt; {<br>        if (price.innerHTML.indexOf('&lt;br&gt;') &gt; -1) {<br>            return true;<br>        }<br><br>        else {<br>            return false;<br>        }<br>    };<br><br>    setInterval(() =&gt; {<br>        \/*Product pages*\/<br>        if (document.querySelector('.block-product__price') &amp;&amp; !priceChanged(document.querySelector('.block-product__price'))) {<br><br>            document.querySelectorAll('.block-product__price').forEach(price =&gt; {<br>                addCommaToPrice(price, currency);<br>            });<br>        }<br><br>        \/*Cart*\/<br>        if (document.querySelector('.cart__price') &amp;&amp; !priceChanged(document.querySelector('.cart__price'))) {<br><br>            document.querySelectorAll('li.cart__list-item').forEach(product =&gt; {<br><br>                if (product.contains(product.querySelector('.cart__sale-price'))) {<br>                    addCommaToPrice(product.querySelector('.cart__price'), currency);<br>                    addCommaToPrice(product.querySelector('.cart__sale-price'), currency);<br>                }<br><br>                else {<br>                    addCommaToPrice(product.querySelector('.cart__price'), currency);<br>                }<br>            })<br><br>            if (!priceChanged(document.querySelector('.cart__title span'))) {<br>                addCommaToPrice(document.querySelector('.cart__title span'), currency);<br>            }<br>        }<br><br>        \/*Section*\/<br>        if (document.querySelector('.product-list-item__price-wrapper span') &amp;&amp; !priceChanged(document.querySelector('.product-list-item__price-wrapper span'))) {<br><br>            document.querySelectorAll('.product-list-item').forEach(product =&gt; {<br>                if (product.querySelector('p.product-list-item__price-content')) {<br>                    addCommaToPrice(product.querySelector('.product-list-item__price-wrapper span'), currency);<br>                    addCommaToPrice(product.querySelector('p.product-list-item__price-content'), currency);<br>                }<br><br>                else {<br>                    addCommaToPrice(product.querySelector('.product-list-item__price-wrapper span'), currency);<br>                }<br>            })<br>        }<br>    }, 500);<br>&lt;\/script&gt; <\/code><\/pre><p class=\"no-margin\">\n<\/p><h1 id=\"h_5f7a99dc5e\">Personalizar el c&oacute;digo<\/h1><p class=\"no-margin\">Realiza las siguientes modificaciones en el c&oacute;digo dependiendo de lo que quieras cambiar &#128071;<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"h_61761e5147\">Moneda <\/h2><p class=\"no-margin\">Copie y pegue el s&iacute;mbolo de moneda de su tienda:<\/p><pre><code>let currency = '$';<\/code><\/pre><p class=\"no-margin\">Es <b>crucial<\/b> que insertes el valor exacto que ves junto al precio de tu producto:<\/p><div class=\"intercom-container\"><img decoding=\"async\" src=\"\/es\/support\/wp-content\/uploads\/sites\/60\/2023\/12\/87ba7268-e96f-4484-beb8-753d8f1e7833.jpg\"><\/div><p class=\"no-margin\">\n<\/p><h2 id=\"h_7367d07459\">Separador de miles<\/h2><p class=\"no-margin\">Para mostrar 20000 $ (miles sin separar)<\/p><pre><code>const thousandsSeparator = ''; <\/code><\/pre><p class=\"no-margin\">Para mostrar $20<b>,<\/b>000 (miles separados por una coma)<\/p><pre><code>const thousandsSeparator = ', ';<\/code><\/pre><p class=\"no-margin\">\n<\/p><h2 id=\"h_d760a1d9c5\">C&eacute;ntimos<\/h2><p class=\"no-margin\">Para mostrar 20000 $ (sin c&eacute;ntimos)<\/p><pre><code>const removeCents = true;<\/code><\/pre><p class=\"no-margin\">Para mostrar $20000<b>.00 <\/b>(centavos)<\/p><pre><code>const removeCents = false;<\/code><\/pre><p class=\"no-margin\">\n<\/p><h2 id=\"h_936d7328f3\">Posici&oacute;n en divisas<\/h2><p class=\"no-margin\">Para mostrar $20000<\/p><pre><code>const currencyInTheEnd = false;<\/code><\/pre><p class=\"no-margin\">Para mostrar 20000$<\/p><pre><code> would show &euro; 20000 const currencyInTheEnd = true; <\/code><\/pre><p class=\"no-margin\">\n<\/p><h1 id=\"h_b4596d2a5f\">Pegue el c&oacute;digo<\/h1><p class=\"no-margin\">Dentro del constructor, ve a <b>Configuraci&oacute;n<\/b> &rarr; <b>Integraciones<\/b> de tu sitio web, y pega el c&oacute;digo en el campo <b><a href=\"\/es\/support\/6445594-website-builder-how-to-add-custom-code-to-the-head-head-part-of-a-website-s-code\" target=\"_blank\" class=\"intercom-content-link\">C&oacute;digo personalizado<\/a><\/b>. A continuaci&oacute;n, <b>guarda los cambios<\/b> y <b>actualiza tu sitio web<\/b>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Aprenda a cambiar el formato de los precios de los productos en su tienda online creada con Hostinger AI Builder<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[262],"tags":[],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-tienda-online"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/8343753-hostinger-website-builder-how-to-change-the-price-format-in-the-online-store\/","default":1},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/support\/8343753-hostinger-creador-de-sitios-web-como-cambiar-el-formato-del-precio-en-la-tienda-online\/","default":0}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/es\/support\/wp-json\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/es\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/es\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/es\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/es\/support\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":1,"href":"https:\/\/www.hostinger.com\/es\/support\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"predecessor-version":[{"id":982,"href":"https:\/\/www.hostinger.com\/es\/support\/wp-json\/wp\/v2\/posts\/58\/revisions\/982"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/es\/support\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/es\/support\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/es\/support\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}