Conversation
supportHi, is there any shortcode to display Wishlist button in custom list? For example, I have ACF Post Object and I want to add Wishlist button after Add to cart. <?php $items = get_field('items'); if( $items ): echo '<ul class="products products-slide-mobile c-100">'; foreach( $items as $product_id ): $product = wc_get_product( $product_id ); if( $product ): echo '<li class="product" data-aos="fade-up" data-aos-duration="1100">'; echo '<a href="' . get_permalink( $product->get_id() ) . '">'; echo wp_get_attachment_image( $product->get_image_id(), 'medium_large' ); echo '</a>'; if ($product->is_on_sale()) { echo '<span class="onsale">' . __('Sale!', 'woocommerce') . '</span>'; } echo '<h2 class="woocommerce-loop-product__title"><a href="' . get_permalink( $product->get_id() ) . '">' . $product->get_name() . '</a></h2>'; echo '<span class="price">' . $product->get_price_html() . '</span>'; echo woocommerce_template_loop_add_to_cart(); HOW TO ADD HERE WISHLIST BUTTON? echo '</li>'; endif; endforeach; echo '</ul>'; endif; ?>
Hi matppp Thank you for feedback. This could work. You would need to have the same HTML in the code as there is for the button. You can check in templates/shop-loop/add-to-cart-left.php but the minimum HTML for such a button to work is: <a href="#add-to-wishlist" class="fw-button fw-button--before fw-button--active" data-product-id="echo esc_attr( $product->get_id() ); ?>"><span class="fw-button-icon></span></a> If you apply this code, it should work. Feel free to contact me if you have more questions.
Hi matppp As we haven’t got any replies, I’m marking this topic as resolved for now.
Hi matppp Thank you for feedback. This could work. You would need to have the same HTML in the code as there is for the button. You can check in templates/shop-loop/add-to-cart-left.php but the minimum HTML for such a button to work is: <a href="#add-to-wishlist" class="fw-button fw-button--before fw-button--active" data-product-id="echo esc_attr( $product->get_id() ); ?>"><span class="fw-button-icon></span></a> If you apply this code, it should work. Feel free to contact me if you have more questions.
Hi matppp As we haven’t got any replies, I’m marking this topic as resolved for now.