Add to Cart button on Swiper JS carousel

New Member
1 0 0

Hi, I'm looking to add a "Add to cart" button for a Swiper JS carousel on my homepage. The carousel has been set up using a loop but the button isn't working. I'm sure it's because I'm not using the correct form but can't get it to work.

Would love your help.

Thanks in advance.

<div class="carousel-container row">
            <div class="col-4">    
                <h2 class="carousel-heading">{{ section.settings.product-carousel-title }} </h2>
                <img alt="" class="carousel-child" src="">
            <div class="swiper-container col-8">
                <div class="swiper-wrapper">

                    {% for block in section.blocks %}
                    {% assign product_item = all_products[block.settings.product] %}
                        <div class="swiper-slide">

                            <div class="row">

                                <div class="col-12">
                                    <a href="{{ product_item.url | within: collection }}">
                                    <img src="{{ product_item.featured_media | img_url: 'medium'}}" alt="">
                                <div class="col-md-10 mx-auto carousel-text-padding">
                                    <span class="carousel-title">{{ product_item.title }}</span>

                                <div class="col-6 carousel-field-1">
                                    <span class="carousel-field-1-text">500ml</span>

                                <div class="col-6 carousel-field-2">
                                    <span class="carousel-field-2-text">UHT</span>

                                <div class="col-4 price-padding">
                                    <span class="carousel-price">{{ product_item.price | money }}</span>

                                <div class="col-4 select-padding">
                                    <select class="select" name="quantity" id="Quantity">
                                        <option type="number" id="Quantity" name="quantity" value="1">1</option>
                                        <option type="number" id="Quantity" name="quantity" value="3">3</option>
                                        <option type="number" id="Quantity" name="quantity" value="6">6</option>

                                <div class="col-4 button-padding">
                                    <button type="button" class="carousel-button">
                                        <span> + </span><a ><img alt="" class="carousel-cart" src=""></a>

                                <div class="col-12">
                                    <p class="carousel-quantity">Sold by 6 minimum</p>
                    {% endfor %}

                <div class="swiper-scrollbar"></div>