Add a “compare” button (extra) below wishlist

This topic has 3 replies, 3 voices, and was last updated 1 years, 8 months ago ago by Andrew Mitchell

  • Avatar: Kombajn88
    Kombajn88
    Participant
    April 2, 2024 at 16:37

    Hello,

    is it possible to create a code to add a “compare” button in the space next to add to wishlist and quick view

    What I mean by that is to add a “compare” button in the red square

    I tried to create the code myself, but it does not work

    add_action('woocommerce_after_shop_loop_item', 'add_compare_button', 15);
    
    function add_compare_button() {
      global $product;
      $product_id = $product->get_id();
      
      echo '<div class="single-compare">';
      echo '<a href="#" class="compare button" data-product_id="' . esc_attr($product_id) . '">';
      echo '<span class="et-icon et-compare"></span>';
      echo '</a>';
      echo '</div>';
    }
    Please, contact administrator
    for this information.
    Files is visible for topic creator and
    support staff only.
    2 Answers
    Avatar: Justin
    Luca Rossi
    Support staff
    April 3, 2024 at 08:37

    Hi @Kombajn88,

    Please try with this code instead:

    
    add_action('et_after_shop_loop_title', 'add_compare_button', 15);
    
    function add_compare_button() {
      global $product;
      $product_id = $product->get_id();
      
      echo '<div class="single-compare">';
      echo '<a href="#" class="compare button" data-product_id="' . esc_attr($product_id) . '">';
      echo '<span class="et-icon et-compare"></span>';
      echo '</a>';
      echo '</div>';
    }
    

    Hope it helps!

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    April 8, 2024 at 22:18

    Dear Kombajn88,

    Choosing our theme reflects your commitment to quality, and for that, we’re genuinely grateful. As we constantly strive to elevate your experience, your feedback is an invaluable gift. Could you kindly take a moment to rate our product with 5 stars on ThemeForest?

    Click here to share your insights: https://themeforest.net/downloads

    Your support fuels our journey, and we appreciate it more than words can express.

    Best Regards,
    The 8Theme Team

  • Viewing 3 results - 1 through 3 (of 3 total)

The issue related to '‘add a “compare” button (extra) below wishlist’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.