✏️ 正在编辑: wishlist.php
路径:
/home/h359620/public_html/wp-content/themes/datis/woocommerce/myaccount/wishlist.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php /** * My Account - Wishlist * * Displays the current user's favorite products using WooCommerce product cards * and the theme pagination component (Datis_Pagination). * * Data source: * - user meta key: datis_wishlist_product_ids (array of product IDs) * * Pagination: * - 6 products per page * - Uses Datis_Pagination if available */ defined('ABSPATH') || exit; $user_id = get_current_user_id(); if ($user_id <= 0) { echo '<p>' . esc_html_x('Please log in to view your wishlist.', 'Wishlist', 'datis') . '</p>'; return; } $mgr = class_exists('Datis_WC_MyAccount_Manager') ? Datis_WC_MyAccount_Manager::get_instance() : null; // Read ids from manager if available (recommended), otherwise fallback to user meta. if ($mgr && method_exists($mgr, 'get_user_wishlist_ids')) { $wishlist_ids = (array) $mgr->get_user_wishlist_ids($user_id); } else { $wishlist_ids = (array) get_user_meta($user_id, 'datis_wishlist_product_ids', true); } $wishlist_ids = array_values(array_unique(array_filter(array_map('absint', $wishlist_ids)))); $current_page = max(1, absint(get_query_var('paged'))); $per_page = (int) apply_filters('datis_myaccount_wishlist_per_page', 6, $user_id); $total_items = count($wishlist_ids); $total_pages = (int) ceil($total_items / max(1, $per_page)); $offset = ($current_page - 1) * $per_page; $paged_ids = array_slice($wishlist_ids, $offset, $per_page); // Query products for this page (keep the order of IDs) $q = new WP_Query(array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => $per_page, 'post__in' => $paged_ids, 'orderby' => 'post__in', 'ignore_sticky_posts' => true, 'no_found_rows' => true, )); $demo = get_option('datis_active_demo'); ?> <div class="orders-shell"> <div class="orders-card"> <?php if (!empty($wishlist_ids) && $q->have_posts()) : ?> <div class="orders-titlebar"> <h2 class="orders-title"><?php echo esc_html_x('My wishlist', 'Wishlist title', 'datis'); ?></h2> </div> <?php // Use Woo card markup. Ensure product loop context exists. if (function_exists('wc_set_loop_prop')) { wc_set_loop_prop('columns', 3); } ?> <div class="products columns-3"> <div class="wishlist"> <?php while ($q->have_posts()) : $q->the_post(); /** * Renders the standard Woo product card (content-product.php) * Your theme likely overrides it already. */ wc_get_template_part('content', 'product'); endwhile; ?> </div> </div> <?php wp_reset_postdata(); ?> <?php if ($total_pages > 1 && class_exists('Datis_Pagination')) : ?> <div class="orders-pagination mt-4"> <?php echo Datis_Pagination::get_instance()->render(null, array( 'total' => $total_pages, 'current' => $current_page, 'base_url' => wc_get_account_endpoint_url('wishlist'), 'format' => 'page/%#%/', 'wrap_class' => 'datis-pagination-list', 'item_class' => 'datis-pagination-item', 'current_class' => 'is-current', )); ?> </div> <?php endif; ?> <?php else : ?> <div class="empty-orders d-flex flex-column align-items-center justify-content-center gap-3 w-100"> <svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"> <rect width="100" height="100" rx="20" fill="currentColor" fill-opacity="0.06" /> <path d="M50 73C36.5 61.5 28 54 28 43.5C28 35.5 34.5 29 42.5 29C46.9 29 50.9 31 53.5 34.2C56.1 31 60.1 29 64.5 29C72.5 29 79 35.5 79 43.5C79 54 70.5 61.5 57 73C54.9 74.8 52.1 74.8 50 73Z" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" /> </svg> <p><?php echo esc_html_x('Your wishlist is empty.', 'Wishlist empty', 'datis'); ?></p> <a href="<?php echo esc_url(function_exists('wc_get_page_permalink') ? wc_get_page_permalink('shop') : home_url('/')); ?>"> <?php if ($demo == 'industry') : ?> <svg width="14" height="13" viewBox="0 0 14 13" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M12.7701 11.8579L10.8921 10.2077M0.750669 1.29699L9.2183 0.750029M0.750669 1.29699L1.29763 9.76463M0.750669 1.29699L8.63844 8.22758" stroke="#F5F5F5" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </svg> <?php elseif ($demo == 'business'): ?> <svg width="44" height="40" viewBox="0 0 44 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M10 40C4.47715 40 -1.95703e-07 35.5228 -4.37114e-07 30L-1.31134e-06 10C-1.55275e-06 4.47715 4.47715 -1.95703e-07 10 -4.37114e-07L33.1922 -1.45088e-06C39.6979 -1.73525e-06 44.4715 6.11389 42.8937 12.4254L37.8937 32.4254C36.7807 36.877 32.7809 40 28.1922 40L10 40Z" fill="#F9E65C" /> <path d="M15.3433 15.3139H22.3286M15.3433 15.3139V22.2992M15.3433 15.3139L21.4554 21.4261M24.657 24.6276L23.2017 23.1724" stroke="#0A2647" stroke-width="1.23483" stroke-linecap="round" stroke-linejoin="round" /> </svg> <?php else : ?> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M6 6H15M6 6V15M6 6L12.5 12.5M18 18L15.5 15.5" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> </svg> <?php endif; ?> <?php if ($demo == 'industry' || $demo == 'business') : echo esc_html_x('Shop', 'Wishlist empty action', 'datis'); else : ?> <span><?php echo esc_html_x('Shop', 'Wishlist empty action', 'datis'); ?></span> <?php endif; ?> </a> </div> <?php endif; ?> </div> </div>
💾 保存文件
← 返回文件管理器