Important Coding

				
					<!-- Font Awesome Icon Library -->
<link data-minify="1" href="https://avontra.pk/wp-content/cache/min/1/ajax/libs/font-awesome/6.5.0/css/all.min.css?ver=1795137860" rel="stylesheet">

<!-- Minimal WhatsApp Buy Option -->
<div class="alt-buy-option">
  <small>Need help? </small>
  <a href="#" id="whatsapp-link" target="_blank" rel="noopener">
    <i class="fab fa-whatsapp"></i> Buy via WhatsApp
  </a>
</div>

<style>
.alt-buy-option {
  margin-top: 10px;
  font-size: 15px;
  font-family: 'Poppins', sans-serif;
  color: #666;
}

.alt-buy-option a {
  color: #25D366;
  font-weight: 600;
  text-decoration: none;
  margin-left: 5px;
  display: inline-flex;
  align-items: center;
}

.alt-buy-option i {
  margin-right: 6px;
  font-size: 16px;
}

.alt-buy-option a:hover {
  color: #128C7E;
  text-decoration: underline;
}
</style>

<script>
  // Your WhatsApp Number
  const number = "923047935283";

  // Get the current page title and URL
  const productTitle = document.title;
  const productURL = window.location.href;

  // Prefilled WhatsApp message
  const message = encodeURIComponent(`Hey! I want to order *${productTitle}*. Can I get more info on this?\n${productURL}`);

  // Apply link
  document.getElementById("whatsapp-link").href = `https://wa.me/${number}?text=${message}`;
</script>

				
			

Short Code :

Javascript past in .php

				
					<?php 
// Show Savings for Simple + Variable Products
add_shortcode('show_savings', 'avontra_show_savings');
function avontra_show_savings() {
    global $product;

    if (!$product || !is_a($product, 'WC_Product')) return '';

    $sale_price = 0;
    $regular_price = 0;

    if ( $product->is_type( 'variable' ) ) {
        $min_reg = $product->get_variation_regular_price('min');
        $min_sale = $product->get_variation_sale_price('min');

        if ( $min_sale && $min_sale < $min_reg ) {
            $regular_price = $min_reg;
            $sale_price = $min_sale;
        }
    } else {
        $regular_price = $product->get_regular_price();
        $sale_price = $product->get_sale_price();
    }

    if ( $sale_price && $regular_price && $sale_price < $regular_price ) {
        $amount_saved = $regular_price - $sale_price;
        return '<div class="avontra-saving">Save <span class="avontra-saving-amount">Rs ' . number_format($amount_saved) . '</span></div>';
    }

    return '';
}
?>

				
			

Css past in Aditton Css ( Theme ) 

				
					.avontra-saving {
  margin-top: 0px;
  font-size: 17px;
  font-weight: 500;
  color: #1346AF;
}

.avontra-saving-amount {
  color: #1346AF;
  font-weight: bold;
}.woocommerce div.product div.images .flex-control-thumbs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
				
			

Button ID : buyNowBtn

				
					<script>
document.addEventListener('DOMContentLoaded', function () {
    const buyNowBtn = document.getElementById('buyNowBtn');

    if (!buyNowBtn) return;

    buyNowBtn.addEventListener('click', function (e) {
        e.preventDefault();

        const form = document.querySelector('form.cart');
        if (!form) {
            alert("Cart form not found.");
            return;
        }

        // For variable products: check if all variations are selected
        const requiredSelects = form.querySelectorAll('select');
        for (let select of requiredSelects) {
            if (!select.value) {
                alert("Please select all required product options before proceeding.");
                return;
            }
        }

        const productID = form.querySelector('input[name="add-to-cart"]').value;
        const qty = form.querySelector('input.qty') ? form.querySelector('input.qty').value : 1;

        // Get all form data (includes variations if selected)
        const formData = new FormData(form);

        fetch(form.action, {
            method: 'POST',
            body: formData,
            credentials: 'same-origin'
        })
        .then(response => {
            // ✅ Now redirect to checkout after successful add to cart
            window.location.href = "/checkout/";
        })
        .catch(error => {
            alert("Something went wrong. Please try again.");
            console.error(error);
        });
    });
});
</script>

				
			

ShortCodes : 20 Nov ,  21 Nov  ,  24 Nov → 25 Nov

				
					<?php 
function avontra_order_dates_shortcode($atts) {
    $atts = shortcode_atts( array(
        'type' => 'order', // order, shipped, delivered
    ), $atts, 'avontra_date' );

    date_default_timezone_set('Asia/Karachi'); // Set your timezone here

    $order_date = date('d M');
    $shipped_date = date('d M', strtotime('+1 day'));
    $delivered_start = date('d M', strtotime('+4 days'));
    $delivered_end = date('d M', strtotime('+5 days'));

    if ($atts['type'] == 'order') {
        return $order_date;
    } elseif ($atts['type'] == 'shipped') {
        return $shipped_date;
    } elseif ($atts['type'] == 'delivered') {
        return $delivered_start . ' → ' . $delivered_end;
    }
}

// 🔥 This line is required to register the shortcode!
add_shortcode('avontra_date', 'avontra_order_dates_shortcode');
?>

				
			

Purpose: Trims long WooCommerce product names to max 25 characters on archive pages.

				
					<?php 
// Trim WooCommerce product titles by character count on shop/home/category pages
add_filter( 'the_title', 'custom_trim_product_title_by_characters', 10, 2 );
function custom_trim_product_title_by_characters( $title, $id ) {
    if ( is_admin() ) return $title;

    // Only apply on product archive pages (shop, home, category)
    if ( is_shop() || is_product_category() || is_front_page() || is_page('shop') ) {
        if ( get_post_type( $id ) === 'product' ) {
            $max_chars = 25; // Set your desired character limit here

            // Trim if title is too long
            if ( strlen( $title ) > $max_chars ) {
                $title = mb_substr( $title, 0, $max_chars ) . '...';
            }
        }
    }

    return $title;
}
?>

				
			

Purpose: When a user fills billing_full_name, it auto-splits into WooCommerce’s first and last name fields.

				
					<?php 
function avontra_set_split_full_name_fields($order, $data) {
    if (!empty($data['billing_full_name'])) {
        $full_name = sanitize_text_field($data['billing_full_name']);
        $name_parts = explode(' ', $full_name, 2);
        $first_name = $name_parts[0];
        $last_name = isset($name_parts[1]) ? $name_parts[1] : '';

        $order->set_billing_first_name($first_name);
        $order->set_billing_last_name($last_name);
    }
}
?>

				
			

Past in Additional Css Theme

				
					/* Horizontal Scroll for Thumbnails */
.woocommerce div.product div.images .flex-control-thumbs {
  display: flex;
  overflow-x: auto;
  gap: 10px;
  scroll-snap-type: x mandatory;
  padding: 10px 0;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar for thumbnail scroll */
.woocommerce div.product div.images .flex-control-thumbs::-webkit-scrollbar {
  display: none;
}

				
			

Past in Additional Css Theme

				
					/* Horizontal Product Tabs on Mobile */
@media (max-width: 767px) {
  .woocommerce div.product .woocommerce-tabs ul.tabs {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-around;
    overflow-x: auto;
    border-bottom: 2px solid #eee;
    margin-bottom: 15px;
  }

  .woocommerce div.product .woocommerce-tabs ul.tabs li {
    display: inline-block !important;
    float: none !important;
    white-space: nowrap;
    margin-right: 10px;
  }

  .woocommerce div.product .woocommerce-tabs ul.tabs li a {
    padding: 10px 14px;
    font-size: 14px;
  }
}

				
			

Also This If need for desktop

				
					@media only screen and (max-width: 768px) {
  .woocommerce div.product .woocommerce-tabs ul.tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    gap: 4px;
    padding: 0 !important;
    border: none !important;
  }

  .woocommerce div.product .woocommerce-tabs ul.tabs li {
    flex: 1 1 0% !important;
    margin: 0 !important;
    text-align: center;
  }

  .woocommerce div.product .woocommerce-tabs ul.tabs li a {
    padding: 8px 5px !important;
    font-size: 13px !important;
    display: block;
    white-space: nowrap;
  }
}

/* Full width bottom border for product tabs on desktop */
.woocommerce div.product .woocommerce-tabs ul.tabs {
  position: relative;
  border-bottom: none !important; /* remove default border */
}

.woocommerce div.product .woocommerce-tabs ul.tabs::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: #e0e0e0; /* ya jo theme color ho */
}

				
			

Past  This code  in HTML weidget 

Than Add this Css Clases in Advance > layout > Css Clases 

Past This : scroll-hover-img

				
					<style>
  .scroll-hover-img {
    height: 500px; /* visible area height */
    overflow: hidden;
    position: relative;
  }

  .scroll-hover-img img {
    display: block;
    margin: 0 auto; /* center horizontally */
    transform: translateY(0); /* default position */
    transition: transform 0.4s ease-out; /* fast return */
    height: auto;
    width: auto;
    max-width: 100%;
    object-position: top center;
    object-fit: contain;
  }

  .scroll-hover-img:hover img {
    transform: translateY(-65%); /* deeper scroll = more bottom visible */
    transition: transform 6s ease-in-out; /* slightly faster scroll */
  }
</style>


				
			

Past  This code  > Dashboard > Appearance > customization > Additional CSS

				
					html {
  scroll-padding-top: 160px; /* Offset equal to sticky header height */
}

				
			

Past this in > Advance > Layout > CSS Clases  : my-carousel


Copy below Code and past this in HTML widget.

				
					<style>
/* 🔁 Smooth Linear Animation for Swiper & Slick */
.my-carousel .swiper-wrapper,
.my-carousel .slick-track {
  transition-timing-function: linear !important;
  -webkit-transition-timing-function: linear !important;
  -moz-transition-timing-function: linear !important;
  -o-transition-timing-function: linear !important;
}

/* 🧱 Block ALL User Interaction on Slider */
.my-carousel {
  pointer-events: none !important;   /* ❌ Block clicks, hover, drag */
  touch-action: none !important;     /* ❌ Disable touch/swipe */
  user-select: none !important;      /* ❌ Prevent selection */
  -webkit-user-drag: none !important;/* ❌ Safari drag fix */
  -webkit-touch-callout: none !important; /* ❌ Disable callouts on long press (iOS) */
}

/* 🧼 Optional: Remove accidental scrollbar if any */
.my-carousel::-webkit-scrollbar {
  display: none;
}
</style>

				
			

Give Button ID  : downloadCV

Note : Replace this [ https://creativebilal.com/wp-content/uploads/2025/06/Creative-Bilal-CV.pdf ] with your actual File URL you want to download

				
					<script>
  document.addEventListener('DOMContentLoaded', function () {
    const btn = document.getElementById('downloadCV');

    if (btn) {
      btn.addEventListener('click', function (e) {
        e.preventDefault(); // 🔥 This prevents page reload
        const link = document.createElement('a');
        link.href = 'https://creativebilal.com/wp-content/uploads/2025/06/Creative-Bilal-CV.pdf';
        link.download = 'CreativeBilal-CV';
        link.style.display = 'none';
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
      });
    }
  });
</script>

				
			
Reset Chat?
Avontra

Avontra Concierge

Online

Hi there! 👋

Welcome to Avontra. How can we assist you with our luxury tech gadgets today?

New Arrivals
Best Sellers
Warranty
Bulk Order
Avontra is typing...