Add connect product + title

main-product.liquid
     {% when 'connect' %}
              {% comment %} Variant Title  {% endcomment %}
                {% if product.metafields.custom.connect_title %}
                    <div class="conntect-title"> 
                        {% if product.metafields.custom.variant_title %}
                           <h3>{{product.metafields.custom.variant_title}}</h3>  
                        {% else %}
                           <h3>Variante </h3>  
                        {% endif %}  
                        <span class="custom_text_farbe">{{ product.metafields.custom.connect_title  }}</span>
                    </div>
                {% endif %}
                {% if product.metafields.custom.connect_products != blank %}
                     <div class="connected-products">
                    {% assign related_products = product.metafields.custom.connect_products.value %}
                    {% for related_product in related_products %}
                          {% assign is_active = false %}
                          {% if related_product.handle == product.handle %}
                            {% assign is_active = true %}
                            {% assign has_active = true %}  
                          {% endif %}
                          {% assign display_title = related_product.metafields.custom.connect_title | default: related_product.title %}
                          <a href="{{ related_product.url }}"
                            class="{% if is_active %}active{% endif %} connected-product-item"
                            data-url="{{ related_product.handle }}"
                            data-title="{{ display_title }}">
                            {% if related_product.featured_image %}
                              <img src="{{ related_product.featured_image | image_url }}" alt="{{ display_title }}">
                            {% endif %}
                          </a>
                        {% endfor %}
                        {% unless has_active %}  
                          {% assign display_title =  product.title %}
                          <a href="{{ product.url }}"
                            class="active connected-product-item"
                            data-url="{{ product.handle }}"
                            data-title="{{ display_title }}">
                            {% if product.featured_image %}
                              <img src="{{ product.featured_image | image_url }}" alt="{{ display_title }}">
                            {% endif %}
                          </a>
                        {% endunless %}
                      </div>
                {% endif %}
              {% comment %} Variant Title  {% endcomment %}

   {
      "type":"connect",
      "name":"Connect",
      "settings":[
        {
          "type": "inline_richtext",
          "id":"head",
          "label":"Heading"
        },
      
      ]
    },
style.css
* connected-product */
.connected-products-select.product-form__input {
    margin-top: 0.4rem !important;
}
select#connectedSelect {
    cursor: pointer;
    line-height: 2.5rem;
    padding: 0 1rem;
    margin: var(--inputs-border-width);
    min-height: 2.5rem;
    border: .5px solid #959595 !important;
    font-size: .938rem;
    color: #959595;
    font-weight: 400;
    height: 2.5rem;
    box-shadow: none;
    background-color: transparent !important;
    width: 100%;
}

.connected-products {
    display: flex
;
    gap: 10px;
    width: 100%;
    margin-top: .5rem;
    flex-flow: row wrap;
    overflow: hidden;
}
.conntect-title {
    display: flex
;
    align-items: center;
    margin-bottom: 0 !important;
}
.connected-product-item {
    border: .5px solid #C6C6C6 !important;
    padding: 4px;
    border-radius: .3125rem;
    display: inline-block;
    width: 5rem;
    height: 5rem;
    transition: border .3s ease;
    padding-left: .8rem;
    padding-right: .8rem;
    color: #000;
    text-decoration: none;
}
.connected-product-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
span.custom_text_farbe {
    margin-left: 0.5rem;
}
.conntect-title h3 {
    margin-bottom: 0;
    margin-top: 0;
    font-size: .938rem;
    color: #000;
    font-family: var(--heading-font-semibbold);
    letter-spacing: .0019rem;
}
span.custom_text_farbe {
    font-family: var(--text-semibold);
    font-size: 0.75rem;
}
.connected-product-item.active {
    border: 1px solid var(--primary-color) !important;
    color: #fff;
}
/* connected-product */

Leave a Reply

Your email address will not be published. Required fields are marked *