Shortcode for custom list
-
Hi, 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;
?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Shortcode for custom list’ is closed to new replies.