Technikai póló

SKU technikai-polo-ferfi-terv Categories , Tags , ,

Összes tervezett terméked együtt = nagyobb kedvezmény

Termékszám

Kedvezmény

3db

-5%

5db

-10%

10db

-15%

20db

-20%

50db

-25%

100db

-40%

3 900 Ft

További tervezhető termékek

`); } }); }, /** * Add to cart with image via AJAX */ addToCartWithImage: function($form, imageData, callback) { // Get form data var formData = new FormData($form[0]); // Add our custom image data formData.append('_fpd_custom_highres_image', imageData); formData.append('action', 'fpd_add_to_cart_with_image'); formData.append('nonce', 'cd40498afa'); // AJAX request $.ajax({ url: 'https://polovarazs.hu/wp-admin/admin-ajax.php', type: 'POST', data: formData, processData: false, contentType: false, success: function(response) { //console.log('AJAX response:', response); if (response.success) { // Update cart fragments if (response.data.fragments) { $.each(response.data.fragments, function(key, value) { $(key).replaceWith(value); }); } if (callback) callback(true); } else { console.error('Add to cart failed:', response.data); if (callback) callback(false); } }, error: function(xhr, status, error) { console.error('AJAX error:', error); if (callback) callback(false); } }); }, /** * Main capture function */ capturePreviewImage: function(callback) { var self = this; try { //console.log('Capturing high-res preview image...'); // Method 1: Check for existing preview modal image var previewImg = document.querySelector('.fpd-modal img, .fpd-preview-modal img, .fpd-lightbox img'); if (previewImg && previewImg.src && previewImg.src.startsWith('data:image')) { //console.log('Found preview image in modal'); self.handleFoundImage(previewImg.src, 'modal', callback); return; } // Method 2: Try the getProductDataURL method if (typeof fancyProductDesigner.getProductDataURL === 'function') { //console.log('Trying getProductDataURL method...'); fancyProductDesigner.getProductDataURL(function(combinedDataURL) { if (combinedDataURL) { self.handleFoundImage(combinedDataURL, 'combined', callback); } else { self.generateManualCombinedImage(callback); } }); return; } // Method 3: Generate combined image manually //console.log('Generating combined image manually...'); self.generateManualCombinedImage(callback); } catch (error) { console.error('Error capturing preview:', error); if (callback) callback(null); } }, /** * Generate combined image manually from individual views */ generateManualCombinedImage: function(callback) { var self = this; // Reset zoom on all views if (fancyProductDesigner.viewInstances) { fancyProductDesigner.viewInstances.forEach(function(view) { if (view.fabricCanvas) { view.fabricCanvas.resetZoom(); view.fabricCanvas.calcOffset(); } }); } setTimeout(function() { fancyProductDesigner.getViewsDataURL( function(dataURLArray) { //console.log('Received', dataURLArray.length, 'individual views'); if (dataURLArray.length === 1) { self.handleFoundImage(dataURLArray[0], 'single', callback); } else if (dataURLArray.length > 1) { self.combineImagesVertically(dataURLArray, callback); } }, { format: 'png', quality: 1.0, multiplier: 2.5 } ); }, 100); }, /** * Combine multiple images vertically */ combineImagesVertically: function(imageDataURLs, callback) { //console.log('Combining', imageDataURLs.length, 'images vertically...'); var canvas = document.createElement('canvas'); var ctx = canvas.getContext('2d'); var loadedImages = []; var imagesLoaded = 0; var self = this; // Load all images first imageDataURLs.forEach(function(dataURL, index) { if (!dataURL) return; var img = new Image(); img.onload = function() { loadedImages[index] = this; imagesLoaded++; if (imagesLoaded === imageDataURLs.filter(url => url).length) { // All images loaded, now combine them var maxWidth = Math.max(...loadedImages.filter(img => img).map(img => img.width)); var totalHeight = loadedImages.filter(img => img).reduce((sum, img) => sum + img.height, 0); canvas.width = maxWidth; canvas.height = totalHeight; // Set white background ctx.fillStyle = '#ffffff'; ctx.fillRect(0, 0, maxWidth, totalHeight); var currentY = 0; loadedImages.forEach(function(img) { if (img) { var x = (maxWidth - img.width) / 2; // Center horizontally ctx.drawImage(img, x, currentY); currentY += img.height; } }); var combinedDataURL = canvas.toDataURL('image/png', 1.0); //console.log('Combined image created, length:', combinedDataURL.length); self.handleFoundImage(combinedDataURL, 'manual-combined', callback); } }; img.src = dataURL; }); }, /** * Handle found/generated image */ handleFoundImage: function(imageDataURL, source, callback) { //console.log('High-res image generated from source:', source); //console.log('Image length:', imageDataURL.length); // Store the image this.lastGeneratedImage = imageDataURL; // Execute callback if provided if (callback) { callback(imageDataURL); } // Make download function available globally window.downloadFPDImage = function() { if (FPDHighResGenerator.lastGeneratedImage) { var link = document.createElement('a'); link.download = 'fpd-image-' + Date.now() + '.png'; link.href = FPDHighResGenerator.lastGeneratedImage; document.body.appendChild(link); link.click(); document.body.removeChild(link); } }; //console.log('%c💾 Type downloadFPDImage() to download the image', 'color: #4CAF50; font-size: 12px;'); } }; });
Search
×