<?php /** * Plugin Name: TIFOSO Cart Conversion UX * Description: Mobile cart checkout shortcut and safer floating WhatsApp placement on purchase pages. * Version: 1.0.1 */ if (! defined('ABSPATH')) { exit; } add_action('wp_head', 'tifoso_cart_conversion_ux_css', 60); add_action('wp_footer', 'tifoso_cart_mobile_checkout_bar', 35); add_action('woocommerce_after_cart_item_name', 'tifoso_cart_conversion_edit_link', 20, 2); /** * Recupera solo la edicion de talla/detalles dentro del dueno del carrito. * No carga el modulo movil legado que colisiona con el encabezado. */ function tifoso_cart_conversion_edit_link($cart_item, $cart_item_key) { if (empty($cart_item['data']) || ! is_a($cart_item['data'], 'WC_Product')) { return; } $product = $cart_item['data']; $url = $product->is_visible() ? $product->get_permalink($cart_item) : ''; if (! $url) { return; } $is_es = isset($_SERVER['REQUEST_URI']) && 0 === strpos((string) $_SERVER['REQUEST_URI'], '/es/'); ?> <a class="tf-cart-edit" href="<?php echo esc_url($url); ?>"><?php echo esc_html($is_es ? 'Modificar' : 'Modifica'); ?></a> <?php } function tifoso_cart_conversion_ux_css() { if (! function_exists('is_cart') && ! function_exists('is_checkout')) { return; } ?> <style id="tifoso-cart-conversion-ux-css"> @media (max-width: 782px) { body.woocommerce-cart, body.woocommerce-checkout { padding-bottom: 86px; } body.woocommerce-cart .tifoso-wa-float, body.woocommerce-checkout .tifoso-wa-float { display: none !important; } body.woocommerce-cart td.product-name { display: flex !important; flex-wrap: wrap !important; align-content: flex-start !important; column-gap: 10px !important; } body.woocommerce-cart td.product-name > a:not(.tf-cart-edit) { flex: 1 0 100% !important; } body.woocommerce-cart td.product-name .variation { flex: 0 1 auto !important; } body.woocommerce-cart .tf-cart-edit { display: inline-flex !important; flex: 0 0 auto !important; align-items: center !important; min-height: 28px !important; margin: 2px 0 0 !important; color: #f0ce6d !important; font-size: 12px !important; font-weight: 700 !important; line-height: 1.25 !important; text-decoration: underline !important; text-underline-offset: 3px !important; } body.woocommerce-cart .tifoso-cart-sticky-checkout { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 99990; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid rgba(245, 194, 66, .72); border-radius: 18px; background: rgba(12, 13, 16, .96); box-shadow: 0 18px 45px rgba(0, 0, 0, .45); backdrop-filter: blur(10px); transition: opacity .18s ease, transform .18s ease; } body.woocommerce-cart .tifoso-cart-sticky-checkout.is-native-total-visible { opacity: 0; pointer-events: none; transform: translateY(calc(100% + 20px)); } body.woocommerce-cart .tifoso-cart-sticky-checkout__label { display: block; color: rgba(255, 255, 255, .62); font-size: 11px; font-weight: 800; line-height: 1.1; text-transform: uppercase; } body.woocommerce-cart .tifoso-cart-sticky-checkout__total { display: block; color: #ffffff; font-size: 17px; font-weight: 950; line-height: 1.2; } body.woocommerce-cart .tifoso-cart-sticky-checkout__button { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; padding: 0 18px; border-radius: 14px; background: linear-gradient(135deg, #ffe16a 0%, #c7961e 100%); color: #0a0b0d !important; font-size: 13px; font-weight: 950; line-height: 1.1; text-align: center; text-decoration: none !important; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .38), 0 10px 22px rgba(224, 171, 42, .2); } body.woocommerce-cart .tifoso-cart-sticky-checkout__button:active { transform: translateY(1px); } /* P1-A: cupon + Aggiorna carrello apilados en movil (sin overflow a ~387px) */ html body.woocommerce-cart { overflow-x: hidden !important; } body.woocommerce-cart .shop_table.cart td.actions { display: block !important; width: 100% !important; max-width: 100% !important; box-sizing: border-box !important; padding-left: 0 !important; padding-right: 0 !important; } body.woocommerce-cart .shop_table.cart .actions .coupon { float: none !important; width: 100% !important; max-width: 100% !important; display: grid !important; grid-template-columns: minmax(0, 1fr) !important; gap: 10px !important; } body.woocommerce-cart .shop_table.cart .actions .coupon .input-text { min-width: 0 !important; width: 100% !important; max-width: 100% !important; box-sizing: border-box !important; } body.woocommerce-cart .shop_table.cart .actions .coupon .button, body.woocommerce-cart .shop_table.cart .actions > .button[name="update_cart"] { float: none !important; clear: both !important; width: 100% !important; max-width: 100% !important; margin-top: 0 !important; white-space: normal !important; box-sizing: border-box !important; } body.woocommerce-cart .shop_table.cart .actions > .button[name="update_cart"] { margin-top: 10px !important; } } @media (min-width: 783px) { body.woocommerce-cart .tifoso-cart-sticky-checkout { display: none !important; } } </style> <?php } function tifoso_cart_mobile_checkout_bar() { if (! function_exists('is_cart') || ! is_cart() || ! function_exists('WC') || ! WC()->cart || WC()->cart->is_empty()) { return; } $total = WC()->cart->get_total(); ?> <div class="tifoso-cart-sticky-checkout" role="region" aria-label="<?php echo esc_attr__('Riepilogo rapido carrello', 'tifoso-premium'); ?>"> <div> <span class="tifoso-cart-sticky-checkout__label"><?php echo esc_html__('Totale carrello', 'tifoso-premium'); ?></span> <span class="tifoso-cart-sticky-checkout__total"><?php echo wp_kses_post($total); ?></span> </div> <a class="tifoso-cart-sticky-checkout__button" data-tifoso-cart-checkout="sticky" href="<?php echo esc_url(wc_get_checkout_url()); ?>"> <?php echo esc_html__("Procedi con l'ordine", 'tifoso-premium'); ?> </a> </div> <script id="tifoso-cart-sticky-checkout-visibility"> (function () { /* 17-08: en /es/ esta barra salia 100% en italiano (aria-label, 'Totale carrello' y 'Procedi al pagamento'). TranslatePress no la habia traducido todavia. Mismo patron ya probado en el boton sticky de producto (tifoso-mobile-commerce-ux.php): deciding por idioma en JS. */ var TF_ES = location.pathname.indexOf('/es/') === 0; if (TF_ES) { var stickyBar = document.querySelector('.tifoso-cart-sticky-checkout'); if (stickyBar) { stickyBar.setAttribute('aria-label', 'Resumen rßpido del carrito'); var stickyLabel = stickyBar.querySelector('.tifoso-cart-sticky-checkout__label'); if (stickyLabel) { stickyLabel.textContent = 'Total del carrito'; } var stickyButton = stickyBar.querySelector('.tifoso-cart-sticky-checkout__button'); /* 26-ago: texto igualado al boton principal del carrito ("Finalizar compra", traduccion TRP del nucleo de WooCommerce) -- antes decia "Ir a pagar", dos textos distintos para la misma accion visibles a la vez. */ if (stickyButton) { stickyButton.textContent = 'Finalizar compra'; } } } var observer; function sync() { var bar = document.querySelector('.tifoso-cart-sticky-checkout'); var totals = document.querySelector('.cart_totals'); /* 26-ago-2026: en un carrito corto (1 articulo), el input de cantidad +/- puede caer, YA en la carga inicial sin hacer scroll, justo en la franja de pantalla que ocupa esta barra fija -- tapandolo por completo (medido con elementFromPoint real: los 3 controles +/- devolvian la barra, nunca el input). Antes solo se ocultaba la barra cuando .cart_totals entraba en vista; ahora tambien se oculta si CUALQUIER input de cantidad esta en vista, que es exactamente donde estaba pasando el tapado. */ var qtyInputs = document.querySelectorAll('.woocommerce-cart-form input.qty'); if (!bar || (!totals && !qtyInputs.length) || !window.matchMedia('(max-width: 782px)').matches) { return; } if (observer) { observer.disconnect(); } var targets = []; if (totals) { targets.push(totals); } for (var qi = 0; qi < qtyInputs.length; qi++) { targets.push(qtyInputs[qi]); } if ('IntersectionObserver' in window) { var visibility = new Map(); observer = new IntersectionObserver(function (entries) { for (var i = 0; i < entries.length; i++) { visibility.set(entries[i].target, entries[i].isIntersecting); } var anyVisible = false; visibility.forEach(function (v) { if (v) { anyVisible = true; } }); bar.classList.toggle('is-native-total-visible', anyVisible); }, { threshold: 0.01 }); targets.forEach(function (t) { observer.observe(t); }); return; } function fallback() { var visible = false; for (var i = 0; i < targets.length; i++) { var rect = targets[i].getBoundingClientRect(); if (rect.top < window.innerHeight && rect.bottom > 0) { visible = true; break; } } bar.classList.toggle('is-native-total-visible', visible); } fallback(); window.addEventListener('scroll', fallback, { passive: true }); } sync(); window.addEventListener('load', sync); window.addEventListener('resize', sync); if (window.jQuery) { window.jQuery(document.body).on('updated_cart_totals', sync); } document.addEventListener('click', function(event) { var link = event.target && event.target.closest ? event.target.closest('a.checkout-button, .wc-proceed-to-checkout a, [data-tifoso-cart-checkout]') : null; if (!link) return; var params = { location: link.getAttribute('data-tifoso-cart-checkout') || 'cart_totals', destination: link.href || '' }; if (typeof window.tifosoTrack === 'function') { window.tifosoTrack('cart_checkout_clicked', params); } else { window.dataLayer = window.dataLayer || []; window.dataLayer.push(Object.assign({event: 'cart_checkout_clicked'}, params)); } }, true); })(); </script> <?php } [saved] C:\Proyectos\agente-de-wordprese\tifoso_ops\data\srv-audit-20260723-pull-cart2.txt https://tifosostore.com/post-sitemap.xml 2026-08-27T21:58:09+00:00 https://tifosostore.com/page-sitemap.xml 2026-08-31T23:57:35+00:00 https://tifosostore.com/product-sitemap1.xml 2026-09-01T05:19:01+00:00 https://tifosostore.com/product-sitemap2.xml 2026-09-01T05:14:46+00:00 https://tifosostore.com/product-sitemap3.xml 2026-09-01T05:14:46+00:00 https://tifosostore.com/product-sitemap4.xml 2026-09-01T05:14:46+00:00 https://tifosostore.com/product-sitemap5.xml 2026-09-01T05:14:46+00:00 https://tifosostore.com/product-sitemap6.xml 2026-09-01T05:14:46+00:00 https://tifosostore.com/product-sitemap7.xml 2026-09-01T05:14:46+00:00 https://tifosostore.com/product_cat-sitemap1.xml 2026-09-01T05:19:01+00:00 https://tifosostore.com/product_cat-sitemap2.xml 2026-08-24T22:23:36+00:00 https://tifosostore.com/sitemap-es.xml 2026-09-01T23:04:42+00:00