Untitled
unknown
plain_text
2 years ago
2.5 kB
6
Indexable
function custom_text_change_script() {
if ( is_cart() || is_checkout() ) { ?>
<style>
.woocommerce-cart-form .product-name {
opacity: 0;
transition: opacity 1s ease-in-out;
}
.loader2-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.9);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
.loader2 {
border: 6px solid #f3f3f3;
border-top: 6px solid #3498db;
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 0.5s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
<?php if ( is_cart() ) { ?>
<div class="loader2-container">
<div class="loader2"></div>
</div>
<?php } ?>
<script type="text/javascript">
// Hide the product name field initially
jQuery(document).ready(function($) {
if ( is_cart() ) {
$('.woocommerce-cart-form .product-name').css('visibility', 'hidden');
// Wait for 0.5 seconds and then smoothly reveal the product name field with a transition effect
setTimeout(function() {
$('.woocommerce-cart-form .product-name').css('visibility', 'visible').css('opacity', '1');
$('.loader2-container').remove();
}, 500);
}
// Replace the text inside <strong> tags in the cart and checkout page
$('.woocommerce-cart-form .product-name strong:contains("Inserisci la larghezza (m):"), .woocommerce-checkout-review-order-table .cart_item .product-name strong:contains("Inserisci la larghezza (m):")').each(function() {
$(this).text($(this).text().replace('Inserisci la larghezza (m):', 'Largezza:'));
});
});
</script>
<?php }
}
add_action('wp_head', 'custom_text_change_script');
Editor is loading...