get_id(); $enable_try_on = get_post_meta($product_id, '_aitoa_enable_try_on', true); // Only process if explicitly enabled if ($enable_try_on !== 'yes') { return; } $try_on_type = get_post_meta($product_id, '_aitoa_try_on_type', true); $tryable_images = get_post_meta($product_id, '_aitoa_tryable_images', true); // Must have images array with content if (empty($tryable_images) || !is_array($tryable_images)) { return; } // Check if any valid images exist $valid_images = array(); foreach ($tryable_images as $image_id) { $image_id = intval($image_id); if ($image_id > 0 && wp_get_attachment_url($image_id)) { $valid_images[] = $image_id; } } if (empty($valid_images)) { return; } // Use default type if not set if (empty($try_on_type)) { $try_on_type = 'clothes'; } // Generate JavaScript to add buttons to each tryable image $this->output_image_button_script($product_id, $try_on_type, $valid_images); // Output the modal HTML (only once per page) $this->output_try_on_modal(); } private function output_image_button_script($product_id, $try_on_type, $valid_images) { // Try-on button script is now handled by the enqueue system in class-aitoa-main.php // This method is kept for compatibility but functionality moved to proper enqueue } private function output_try_on_modal() { static $modal_output = false; if ($modal_output) { return; // Only output once per page } $modal_output = true; ?>

<?php esc_attr_e('My Photo', 'ai-try-on-assistant'); ?>
✓
📷

⚠

/>

$max_size) { wc_add_notice(esc_html__('Image size cannot exceed 5MB', 'ai-try-on-assistant'), 'error'); return; } require_once(ABSPATH . 'wp-admin/includes/image.php'); require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/media.php'); $attachment_id = media_handle_upload('aitoa_profile_photo', 0); if (is_wp_error($attachment_id)) { wc_add_notice($attachment_id->get_error_message(), 'error'); return; } // Delete old photo $old_photo_id = get_user_meta($user_id, 'aitoa_profile_photo_id', true); if ($old_photo_id) { wp_delete_attachment($old_photo_id, true); } // Save new photo update_user_meta($user_id, 'aitoa_profile_photo_id', $attachment_id); wc_add_notice(esc_html__('Photo updated successfully!', 'ai-try-on-assistant'), 'success'); // phpcs:enable WordPress.Security.NonceVerification.Missing } public function debug_test() { // Debug function - currently disabled } }