Home Forums WoodMart support forum Show number of wishlist pre product

Show number of wishlist pre product

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #635741

    piyumsl97
    Participant

    I need help refactoring or redoing the code to display the number of wishlisted per product.

    Currently, my implementation is not functioning as expected, and I believe your expertise in the theme’s intricacies will be invaluable in resolving this issue.

    I have attached the current code for your reference.

    function woodmart_total_wishlist_count_shortcode() {
        global $product;
    
        if (!$product) {
            return '';
        }
    
        $product_id = $product->get_id();
        global $wpdb;
    
        $wishlist_count = $wpdb->get_var($wpdb->prepare("
            SELECT COUNT(*) FROM {$wpdb->usermeta} 
            WHERE meta_key = 'woodmart_wishlist' 
            AND meta_value LIKE %s
        ", '%"'. $product_id . '"%'));
    
        if (!$wishlist_count) {
            $wishlist_count = 0;
        }
    
        return '<div class="wishlist-count">Wishlisted: ' . $wishlist_count . ' times</div>';
    }
    add_shortcode('wishlist_count', 'woodmart_total_wishlist_count_shortcode');
    #635883

    Luke Nielsen
    Keymaster

    Hello,

    Sorry to say it requires customization and is beyond our support policy. Additional code customizations are out of our theme support scope.

    Hope you can understand!

    Kind Regards.

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)