• mikempdev

    (@mikempdev)


    I have this code currently:

    <? global $product; ?>
    
    <div class="yith-wcwl-add-to-wishlist add-to-wishlist-<?php echo esc_attr($product->get_id()); ?>  wishlist-fragment on-first-load" style="margin-top: 0;">
        <a 
           href="?page&pagename=e-shop&add_to_wishlist=<?php echo esc_attr($product->get_id()); ?>"
           class='add_to_wishlist single_add_to_wishlist'
           ref="nofollow"
           data-product-id="<?php echo get_the_ID(); ?>"
           data-product-type="simple"
           title="Προσθ?κη στα αγαπημ?να"
           >
          <i class="fa-solid fa-heart fa-lg" style="color: #8c7ead;"></i>
        </a>
    </div>

    I just want to remove the heart icon if product already exists.

    • This topic was modified 11 months ago by mikempdev.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mikempdev

    (@mikempdev)

    I asked in discord and this is the answer.

    <?php // Specify the product ID you want to check $wpdudecom_product_id = 1111; // Check if the product is in the user's default wishlist if ( YITH_WCWL()->is_product_in_wishlist( $wpdudecom_product_id ) ) { echo 'Product ' . $wpdudecom_product_id . ' is in the user\'s default wishlist.'; } else { echo 'Product ' . $wpdudecom_product_id . ' is not in the user\'s default wishlist.'; } // Check if the product is in a specific wishlist $wpdudecom_wishlist_id = 123; if ( YITH_WCWL()->is_product_in_wishlist( $wpdudecom_product_id, $wpdudecom_wishlist_id ) ) { echo 'Product ' . $wpdudecom_product_id . ' is in the wishlist with ID ' . $wpdudecom_wishlist_id; } else { echo 'Product ' . $wpdudecom_product_id . ' is not in the wishlist with ID ' . $wpdudecom_wishlist_id; }
    Plugin Support Juan Coronel

    (@juaancmendez)

    Hello there,
    we hope you’re doing well!

    You can simply hide it by adding this CSS in Appearance > Customize > Additional CSS:

    .yith-wcwl-add-to-wishlist.exists {
      display: none !important;
    }

    Anyway, if you want to check if a product exists in the wishlist using PHP, you can use this:

    YITH_WCWL()->is_product_in_wishlist( $current_product_id );

    Check it out and tell us any doubt, please.

    Best regards.

    Thread Starter mikempdev

    (@mikempdev)

    Thank you. I just edited the css because I didn’t find a way to correctly update the header wishlist counter.

    • This reply was modified 10 months, 3 weeks ago by mikempdev.
    • This reply was modified 10 months, 3 weeks ago by mikempdev.
    Plugin Support Pablo Pérez

    (@pperez001)

    Hi,

    You are welcome!

    Please let us know if you have any other question about our plugin.

    Have a great day.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to check if current product in the loop is already in the wishlist?’ is closed to new replies.