{"id":8,"date":"2026-05-22T05:01:45","date_gmt":"2026-05-22T05:01:45","guid":{"rendered":"https:\/\/meli.weblab.md\/?page_id=8"},"modified":"2026-05-22T05:01:45","modified_gmt":"2026-05-22T05:01:45","slug":"cos","status":"publish","type":"page","link":"https:\/\/meli.weblab.md\/?page_id=8","title":{"rendered":"Co\u0219"},"content":{"rendered":"    <div class=\"veronai-cart\" id=\"veronai-cart-container\">\n        <h2>Co\u0219ul meu<\/h2>\n        <div id=\"veronai-cart-items\"><p>Se \u00eencarc\u0103\u2026<\/p><\/div>\n        <div class=\"veronai-cart-summary\" id=\"veronai-cart-summary\" style=\"display:none\">\n            <div class=\"veronai-cart-row\"><span>Subtotal<\/span><span id=\"vc-subtotal\"><\/span><\/div>\n            <div class=\"veronai-cart-row\"><span>TVA (0%)<\/span><span id=\"vc-tax\"><\/span><\/div>\n            <div class=\"veronai-cart-row\"><span>Livrare<\/span><span id=\"vc-delivery\"><\/span><\/div>\n            <div class=\"veronai-cart-row veronai-cart-total\"><span>Total<\/span><span id=\"vc-total\"><\/span><\/div>\n\n            <!-- Coupon form -->\n            <div class=\"veronai-cart-coupon\">\n                    <div class=\"veronai-coupon-form\">\n        <h3>Ai un cod promo\u021bional?<\/h3>\n        <div class=\"veronai-coupon-row\">\n            <input type=\"text\" id=\"veronai-coupon-code\" placeholder=\"Cod cupon\" \/>\n            <button id=\"veronai-coupon-apply\" class=\"veronai-btn\" data-nonce=\"9f5ce255f5\">\n                Aplic\u0103            <\/button>\n        <\/div>\n        <p class=\"veronai-coupon-msg\"><\/p>\n    <\/div>\n    <script>\n    (function(){\n        var applyBtn = document.getElementById('veronai-coupon-apply');\n        if (!applyBtn) return;\n        applyBtn.addEventListener('click', function(){\n            var code = document.getElementById('veronai-coupon-code').value.trim().toUpperCase();\n            var msg  = document.querySelector('.veronai-coupon-msg');\n            if (!code) { msg.textContent = ''; msg.style.color = 'red'; return; }\n            \/\/ Ob\u021bine totalul co\u0219ului\n            var cartTotal = 0;\n            if (typeof VeronAiConfig !== 'undefined' && VeronAiConfig.cartTotal) {\n                cartTotal = VeronAiConfig.cartTotal;\n            } else {\n                var totalEl = document.querySelector('#vc-summary-total, #vc-total, .veronai-cart-total span:last-child');\n                if (totalEl) cartTotal = parseFloat(totalEl.textContent.replace(\/[^0-9.-]\/g, '')) || 0;\n            }\n            fetch('https:\/\/meli.weblab.md\/wp-admin\/admin-ajax.php', {\n                method: 'POST',\n                headers: { 'Content-Type': 'application\/x-www-form-urlencoded' },\n                body: 'action=veronai_validate_coupon&nonce=' + encodeURIComponent(applyBtn.dataset.nonce) + '&code=' + encodeURIComponent(code) + '&cart_total=' + cartTotal\n            })\n            .then(r => r.json())\n            .then(d => {\n                msg.textContent = d.data?.message || d.data || '';\n                msg.style.color = d.success ? 'green' : 'red';\n                if (d.success) {\n                    localStorage.setItem('veronai_applied_coupon', code);\n                    localStorage.setItem('veronai_applied_discount', d.data.discount);\n                                        if (typeof window.dispatchEvent === 'function') {\n                        window.dispatchEvent(new CustomEvent('veronai_coupon_applied', { detail: { code: code, discount: d.data.discount } }));\n                    }\n                                    }\n            });\n        });\n    })();\n    <\/script>\n                <\/div>\n\n            <a href=\"https:\/\/meli.weblab.md\/?page_id=9\"\n               class=\"veronai-btn veronai-checkout-link\"\n               style=\"background:#1E3A5F;display:block;text-align:center;text-decoration:none;margin-top:16px;padding:14px\">\n                Finalizeaz\u0103 comanda            <\/a>\n        <\/div>\n    <\/div>\n    <script>\n    (function(){\n        var nonce = '2f4f4ba87e';\n        var currency = 'RON';\n        var deliveryFeeDefault = 0;\n        var freeAbove = 0;\n\n        loadCart();\n\n        function loadCart() {\n            fetch('https:\/\/meli.weblab.md\/wp-admin\/admin-ajax.php', {\n                method: 'POST',\n                headers: { 'Content-Type': 'application\/x-www-form-urlencoded' },\n                body: 'action=veronai_cart_get&nonce=' + nonce\n            })\n            .then( r => r.json() )\n            .then( d => {\n                if ( ! d.success ) return;\n                renderCart( d.data );\n            });\n        }\n\n        function renderCart( data ) {\n            var items = data.items || [];\n            var el    = document.getElementById( 'veronai-cart-items' );\n            var sum   = document.getElementById( 'veronai-cart-summary' );\n\n            if ( ! items.length ) {\n                el.innerHTML = '<p> <a href=\"https:\/\/meli.weblab.md\/?page_id=7\"><\/a><\/p>';\n                sum.style.display = 'none';\n                return;\n            }\n\n            el.innerHTML = items.map( function( item ) {\n                return '<div class=\"veronai-cart-item\" data-key=\"' + item.product_id + '\">'\n                    + ( item.image ? '<img decoding=\"async\" src=\"' + item.image + '\" loading=\"lazy\">' : '' )\n                    + '<div class=\"veronai-ci-info\"><strong>' + item.name + '<\/strong><span>' + parseFloat( item.price ).toFixed(2) + ' ' + currency + '<\/span><\/div>'\n                    + '<div class=\"veronai-ci-qty\">'\n                    + '<button class=\"veronai-qty-btn\" data-id=\"' + item.product_id + '\" data-delta=\"-1\">-<\/button>'\n                    + '<span>' + item.quantity + '<\/span>'\n                    + '<button class=\"veronai-qty-btn\" data-id=\"' + item.product_id + '\" data-delta=\"1\">+<\/button>'\n                    + '<\/div><\/div>';\n            }).join('');\n\n            \/\/ Delivery fee logic (free above threshold)\n            var deliveryFee = deliveryFeeDefault;\n            if ( freeAbove > 0 && data.subtotal >= freeAbove ) {\n                deliveryFee = 0;\n            }\n\n            document.getElementById( 'vc-subtotal' ).textContent = data.subtotal.toFixed(2) + ' ' + currency;\n            document.getElementById( 'vc-tax' ).textContent      = data.tax.toFixed(2) + ' ' + currency;\n            document.getElementById( 'vc-delivery' ).textContent = deliveryFee.toFixed(2) + ' ' + currency;\n            var total = data.subtotal + data.tax + deliveryFee;\n            document.getElementById( 'vc-total' ).textContent    = total.toFixed(2) + ' ' + currency;\n            sum.style.display = 'block';\n\n            \/\/ Attach quantity buttons events\n            document.querySelectorAll( '.veronai-qty-btn' ).forEach( btn => {\n                btn.removeEventListener( 'click', quantityHandler );\n                btn.addEventListener( 'click', quantityHandler );\n            } );\n        }\n\n        function quantityHandler( e ) {\n            var btn = e.currentTarget;\n            var productId = btn.dataset.id;\n            var delta = parseInt( btn.dataset.delta );\n            var itemDiv = btn.closest( '.veronai-cart-item' );\n            var qtySpan = itemDiv.querySelector( '.veronai-ci-qty span' );\n            var newQty = parseInt( qtySpan.innerText ) + delta;\n            if ( newQty < 1 ) newQty = 1;\n            updateQuantity( productId, newQty );\n        }\n\n        function updateQuantity( productId, quantity ) {\n            fetch( 'https:\/\/meli.weblab.md\/wp-admin\/admin-ajax.php', {\n                method: 'POST',\n                headers: { 'Content-Type': 'application\/x-www-form-urlencoded' },\n                body: 'action=veronai_cart_update&nonce=' + nonce + '&product_id=' + productId + '&quantity=' + quantity\n            })\n            .then( r => r.json() )\n            .then( d => {\n                if ( d.success ) renderCart( d.data );\n            });\n        }\n    })();\n    <\/script>\n    \n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-8","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/meli.weblab.md\/index.php?rest_route=\/wp\/v2\/pages\/8","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meli.weblab.md\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/meli.weblab.md\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/meli.weblab.md\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/meli.weblab.md\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8"}],"version-history":[{"count":0,"href":"https:\/\/meli.weblab.md\/index.php?rest_route=\/wp\/v2\/pages\/8\/revisions"}],"wp:attachment":[{"href":"https:\/\/meli.weblab.md\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}