define([
'jquery',
'Magento_Ui/js/modal/modal',
'mage/url',
'mage/translate'
], function($, modal, urlBuilder, $t) {
'use strict';
return function(config, element) {
var quickViewModal;
var currentProductUrl = '';
// Initialize modal
var modalOptions = {
type: 'popup',
responsive: true,
innerScroll: true,
title: $t('Product Quick View'),
buttons: [{
text: $t('Close'),
class: 'action secondary',
click: function() {
this.closeModal();
history.replaceState(null, '', window.location.pathname + window.location.search);
}
}],
closed: function() {
history.replaceState(null, '', window.location.pathname + window.location.search);
}
};
quickViewModal = modal(modalOptions, $('#product-quickview-modal'));
// Handle quick view clicks
$(document).on('click', '.quickview-trigger', function(e) {
e.preventDefault();
var productId = $(this).data('product-id');
var productUrl = $(this).data('product-url');
var productName = $(this).data('product-name');
currentProductUrl = productUrl;
// Update URL in address bar without reloading page
var newUrl = productUrl;
history.pushState({productId: productId}, productName, newUrl);
// Update modal title
$('.modal-title').text(productName);
// Show loading message
$('#product-quickview-content').html('');
// Open modal
$('#product-quickview-modal').modal('openModal');
// Load product content via AJAX
$.ajax({
url: urlBuilder.build('catalog/product/quickview'),
type: 'GET',
data: {
id: productId,
_: new Date().getTime()
},
showLoader: true,
success: function(response) {
if (response.success) {
$('#product-quickview-content').html(response.html);
} else {
$('#product-quickview-content').html('');
}
},
error: function() {
$('#product-quickview-content').html('');
}
});
});
// Close modal handlers
$(document).on('click', '.close-modal', function() {
$('#product-quickview-modal').modal('closeModal');
history.replaceState(null, '', window.location.pathname + window.location.search);
});
// Handle browser back button
window.onpopstate = function(event) {
if (event.state && event.state.productId) {
// If coming back to a product, keep modal open
return;
}
// Close modal if going back from product view
if ($('#product-quickview-modal').is(':visible')) {
$('#product-quickview-modal').modal('closeModal');
}
};
// Close modal on ESC key
$(document).keyup(function(e) {
if (e.keyCode === 27 && $('#product-quickview-modal').is(':visible')) {
$('#product-quickview-modal').modal('closeModal');
history.replaceState(null, '', window.location.pathname + window.location.search);
}
});
};
});
Sign In
Registered Customers
Create New Account
Sign In With OTP
Enter phone number.
We will send an otp on this number via SMS
Sign In with OTP
Enter OTP
Sign In With Otp
Sign In For Product Restock Notification
Enter phone number.
We will send an otp on this number via SMS
Verify Otp
Create New Account