{"id":35958,"date":"2025-04-30T13:35:46","date_gmt":"2025-04-30T13:35:46","guid":{"rendered":"https:\/\/agrinews.tv\/agrinewscampus\/suscripciones\/"},"modified":"2025-05-13T07:36:56","modified_gmt":"2025-05-13T07:36:56","slug":"suscripciones","status":"publish","type":"page","link":"https:\/\/agrinewscampus.com\/pt-br\/suscripciones\/","title":{"rendered":"Suscripciones"},"content":{"rendered":"    <style>\n        .subscription-category {\n            margin-bottom: 30px;\n            padding: 20px;\n            border: 1px solid #ddd;\n            border-radius: 8px;\n        }\n\n        .subscription-category h3 {\n            color: #40c6ce;\n            margin-bottom: 20px;\n            padding-bottom: 10px;\n            border-bottom: 1px solid #eee;\n        }\n\n        .subscription-category .products-row {\n            display: flex;\n            flex-wrap: wrap;\n            gap: 20px;\n            margin-top: 20px;\n            justify-content: space-evenly;\n        }\n\n        .subscription-item {\n            flex: 0 0 18%;\n            \/* 100% \/ 5 = 20% - 2% para el gap = 18% *\/\n            background: #fff;\n            border: 1px solid #eee;\n            border-radius: 8px;\n            padding: 20px;\n            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n            transition: transform 0.3s;\n            text-align: center;\n            min-height: 400px;\n            justify-content: space-between;\n            display: flex;\n            flex-direction: column;\n            align-items: center;\n        }\n\n        .subscription-item:hover {\n            transform: translateY(-5px);\n        }\n\n        .subscription-item img {\n            \/* width: 40%; *\/\n            height: 150px;\n            object-fit: scale-down;\n            border-radius: 4px;\n        }\n\n        .subscription-item .content {\n            flex: 1;\n            display: flex;\n            flex-direction: column;\n            justify-content: space-between;\n            margin-top: 1rem;\n        }\n\n        .subscription-item h4 {\n            margin: 0 0 10px 0;\n            color: #333;\n            font-size: 21px;\n        }\n\n        .subscription-item p {\n            margin: 0;\n            color: #666;\n        }\n\n        .subscription-item .add-to-cart-button {\n            display: inline-block;\n            padding: 10px 20px;\n            background: #40c6ce;\n            color: white;\n            text-decoration: none;\n            border-radius: 4px;\n            transition: background 0.3s;\n            width: 100%;\n            text-align: center;\n            font-weight: bold;\n\n        }\n\n        .matriculate-button {\n            display: inline-block;\n            padding: 10px 20px;\n            background: #40c6ce;\n            color: white;\n            text-decoration: none;\n            border-radius: 4px;\n            transition: background 0.3s;\n            width: 100%;\n            text-align: center;\n        }\n\n        .subscription-item .add-to-cart-button:hover {\n            background: #2fb2b9;\n        }\n    <\/style>\n\n    <div class=\"subscriptions-container p-4\">\n\n    <\/div>\n\n    <script>\n        document.addEventListener(\"DOMContentLoaded\", function() {\n            const container = document.querySelector(\".subscriptions-container\");\n\n            if (!container) return;\n\n            \/\/ usar IntersectionObserver para lazy-load\n            const observer = new IntersectionObserver(function(entries, observer) {\n                entries.forEach(entry => {\n                    if (entry.isIntersecting) {\n                        \/\/ cuando el contenedor entra en viewport, hacemos el fetch\n                        fetch(\"https:\/\/agrifm.org\/profile\/checkout\/products\/get-products?type=Subscription\")\n                            .then(response => {\n                                if (!response.ok) {\n                                    throw new Error(\"Network response was not ok\");\n                                }\n                                return response.json();\n                            })\n                            .then(data => {\n                                if (Array.isArray(data)) {\n                                    const categories = {\n                                        \"Avicultura\": [],\n                                        \"Nutrici\u00f3n\": [],\n                                        \"Porcino\": []\n                                    };\n\n                                    data.forEach(product => {\n                                        if (product.name.toLowerCase().includes(\"avinews\")) {\n                                            categories[\"Avicultura\"].push(product);\n                                        } else if (product.name.toLowerCase().includes(\"nutrinews\")) {\n                                            categories[\"Nutrici\u00f3n\"].push(product);\n                                        } else if (product.name.toLowerCase().includes(\"porcinews\")) {\n                                            categories[\"Porcino\"].push(product);\n                                        }\n                                    });\n\n                                    container.innerHTML = `\n                                    <div class='p-2 px-4'>\n                                        <h1>Assinaturas<\/h1>\n                                        <h5 style='margin:1rem'>Junte-se \u00e0 nossa comunidade e aproveite pre\u00e7os especiais em cursos e acesso preferencial a c\u00e1psulas de treinamento. <\/br> Como membro, voc\u00ea ter\u00e1 acesso gratuito a mais de 100 c\u00e1psulas de conte\u00fado t\u00e9cnico, uma assinatura da nossa revista impressa e ofertas de emprego no setor. Al\u00e9m disso, voc\u00ea receber\u00e1 descontos exclusivos em eventos e treinamentos especializados.<\/h5>\n                                    <\/div>\n                                `;\n\n                                    Object.entries(categories).forEach(([category, subs]) => {\n                                        if (subs.length > 0) {\n                                            const categoryDiv = document.createElement(\"div\");\n                                            categoryDiv.className = \"subscription-category\";\n\n                                            const h3 = document.createElement(\"h3\");\n                                            h3.textContent = category;\n                                            categoryDiv.appendChild(h3);\n\n                                            const rowDiv = document.createElement(\"div\");\n                                            rowDiv.className = \"products-row\";\n                                            categoryDiv.appendChild(rowDiv);\n\n                                            subs.forEach(sub => {\n                                                const itemDiv = document.createElement(\"div\");\n                                                itemDiv.className = \"subscription-item\";\n\n                                                const img = document.createElement(\"img\");\n                                                img.src = sub.image;\n                                                img.alt = sub.name;\n                                                itemDiv.appendChild(img);\n\n                                                const contentDiv = document.createElement(\"div\");\n                                                contentDiv.className = \"content\";\n\n                                                const name = document.createElement(\"h4\");\n                                                name.textContent = sub.name;\n                                                contentDiv.appendChild(name);\n\n                                                const price = document.createElement(\"p\");\n                                                price.textContent = `Precio: ${sub.price} ${sub.currency}`;\n                                                contentDiv.appendChild(price);\n\n                                                const button = document.createElement(\"a\");\n                                                button.href = \"#\";\n                                                button.className = \"add-to-cart-button\";\n                                                button.textContent = \"A\u00f1adir al Carrito\";\n                                                button.onclick = function(event) {\n                                                    event.preventDefault();\n                                                    addToCartSub(sub.id, sub.image, sub.name, sub.price, sub.currency);\n                                                };\n                                                contentDiv.appendChild(button);\n\n                                                itemDiv.appendChild(contentDiv);\n                                                rowDiv.appendChild(itemDiv);\n                                            });\n\n                                            container.appendChild(categoryDiv);\n                                        }\n                                    });\n                                } else {}\n                            })\n                            .catch(error => {\n                                console.error(\"Error fetching subscription data:\", error);\n                            });\n\n                        observer.unobserve(container); \/\/ solo 1 vez\n                    }\n                });\n            }, {\n                rootMargin: \"0px 0px 200px 0px\", \/\/ empezar a cargar un poco antes\n                threshold: 0\n            });\n\n            observer.observe(container);\n        });\n    <\/script>\n\n    <\/div>\n\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"template-suscripciones.php","meta":{"_acf_changed":false,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-35958","page","type-page","status-publish","hentry"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/agrinewscampus.com\/pt-br\/wp-json\/wp\/v2\/pages\/35958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/agrinewscampus.com\/pt-br\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/agrinewscampus.com\/pt-br\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/agrinewscampus.com\/pt-br\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/agrinewscampus.com\/pt-br\/wp-json\/wp\/v2\/comments?post=35958"}],"version-history":[{"count":1,"href":"https:\/\/agrinewscampus.com\/pt-br\/wp-json\/wp\/v2\/pages\/35958\/revisions"}],"predecessor-version":[{"id":35959,"href":"https:\/\/agrinewscampus.com\/pt-br\/wp-json\/wp\/v2\/pages\/35958\/revisions\/35959"}],"wp:attachment":[{"href":"https:\/\/agrinewscampus.com\/pt-br\/wp-json\/wp\/v2\/media?parent=35958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/agrinewscampus.com\/pt-br\/wp-json\/wp\/v2\/categories?post=35958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/agrinewscampus.com\/pt-br\/wp-json\/wp\/v2\/tags?post=35958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}