MMCT TEAM
Server IP : 217.21.85.138  /  Your IP : 216.73.216.103
Web Server : LiteSpeed
System : Linux in-mum-web906.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64
User : u915722082 ( 915722082)
PHP Version : 7.4.33
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u915722082/.nvm/../public_html/lohri/user/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u915722082/.nvm/../public_html/lohri/user/get_wishlist_items.php
<?php
// user/get_wishlist_items.php
header('Content-Type: application/json');

require_once 'wishlist_handler.php';

$wishlistItems = getWishlistItems($con);
$wishlistCount = getWishlistCount();

$imageUrl = '../Images/Product';

// Generate HTML for wishlist items
$html = '';
if (!empty($wishlistItems)) {
    $html .= '
    <div class="bulk-actions-header" id="bulkActionsHeader" style="display: none; margin-bottom: 20px; padding: 15px; background-color: #f8f9fa; border-radius: 6px; border: 1px solid #e5e5e5;">
        <div class="d-flex justify-content-between align-items-center">
            <span class="selected-count">0 items selected</span>
            <div class="bulk-action-buttons">
                <button class="btn btn-dark btn-sm me-2" onclick="bulkAddToCart()">
                    <i class="fas fa-shopping-cart me-1"></i> Add Selected to Cart
                </button>
                <button class="btn btn-outline-danger btn-sm" onclick="bulkRemoveFromWishlist()">
                    <i class="fas fa-trash me-1"></i> Remove Selected
                </button>
            </div>
        </div>
    </div>
    
    <table class="wishlist-table">
        <thead>
            <tr>
                <th style="width: 50px;">
                    <input type="checkbox" id="selectAll" onchange="toggleSelectAll()" style="cursor: pointer;">
                </th>
                <th>Product</th>
                <th>Price</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>';
    
    foreach ($wishlistItems as $item) {
        $attributesText = '';
        if (!empty($item['attributes'])) {
            $attrArray = [];
            foreach ($item['attributes'] as $key => $value) {
                $attrArray[] = ucfirst($key) . ': ' . $value;
            }
            $attributesText = ' (' . implode(', ', $attrArray) . ')';
        }
        
        // ✅ Check if item has offer price
        $hasOfferPrice = !empty($item['offer_price']) && $item['offer_price'] > 0;
        $displayPrice = $hasOfferPrice ? $item['offer_price'] : $item['price'];
        $originalPrice = $item['price'];
        
        $html .= '
        <tr>
            <td>
                <input type="checkbox" class="item-checkbox" value="' . htmlspecialchars($item['wishlist_key']) . '" onchange="updateBulkActions()" style="cursor: pointer;">
            </td>
            <td>
                <div class="product-info-cell">
                    <img src="' . $imageUrl . '/' . htmlspecialchars($item['image']) . '" 
                         alt="' . htmlspecialchars($item['pname']) . '" 
                         class="product-image">
                    <div class="product-details">
                        <div class="product-title">' . htmlspecialchars($item['pname']) . '</div>
                        <div class="product-variant">' . htmlspecialchars($item['vname']) . $attributesText . '</div>';
        
        // ✅ Show offer badge if offer price exists
        if ($hasOfferPrice) {
            $html .= '<span class="wishlist-offer-badge">Offer Product</span>';
        }
        
        $html .= '
                    </div>
                </div>
            </td>
            <td>
                <div class="product-price-cell">';
        
        // ✅ Display offer price with strikethrough original price
        if ($hasOfferPrice) {
            $html .= '
                    <div class="offer-price-display">
                        <span class="current-price offer-price">₹' . number_format($displayPrice, 2) . '</span>
                        <span class="original-price-wishlist">₹' . number_format($originalPrice, 2) . '</span>
                    </div>';
        } else {
            $html .= '<div class="product-price">₹' . number_format($displayPrice, 2) . '</div>';
        }
        
        $html .= '
                </div>
            </td>
            <td>
                <div class="action-buttons">
                    <button class="icon-btn add-to-cart-icon" onclick="addToCartFromWishlist(\'' . $item['wishlist_key'] . '\')" title="Add to Cart">
                        <i class="fas fa-shopping-cart" style="font-size: 16px;"></i>
                    </button>
                    <button class="icon-btn remove-icon" onclick="removeFromWishlist(\'' . $item['wishlist_key'] . '\')" title="Remove from Wishlist">
                        <i class="fas fa-trash" style="font-size: 16px;"></i>
                    </button>
                </div>
            </td>
        </tr>';
    }
    
    $html .= '</tbody></table>';
} else {
    $html = '
    <div class="empty-wishlist">
        <i class="fas fa-heart" style="font-size: 48px; color: #ddd; margin-bottom: 20px;"></i>
        <h5>Your wishlist is empty</h5>
        <p>Save your favorite items to your wishlist</p>
        <a href="shop.php" class="btn btn-dark">Continue Shopping</a>
    </div>';
}

echo json_encode([
    'success' => true,
    'count' => $wishlistCount,
    'html' => $html,
    'items' => $wishlistItems
]);
?>

MMCT - 2023