thank you for taking the time to answer my question.
I have been trying to make the recommended products section instead of being displayed as a grid to be displayed in the form of a carousel, this is what I have tried:
<link rel="stylesheet" href="{{ 'component-card.css' | asset_url }}" media="print" onload="this.media='all'">
<link rel="stylesheet" href="{{ 'component-price.css' | asset_url }}" media="print" onload="this.media='all'">
<link rel="stylesheet" href="{{ 'section-product-recommendations.css' | asset_url }}" media="print" onload="this.media='all'">
<link rel="stylesheet" href="{{ 'owl.carousel.min.css' | asset_url }}" media="print">
<noscript>{{ 'component-card.css' | asset_url | stylesheet_tag }}</noscript>
<noscript>{{ 'component-price.css' | asset_url | stylesheet_tag }}</noscript>
<noscript>{{ 'section-product-recommendations.css' | asset_url | stylesheet_tag }}</noscript>
<noscript>{{ 'owl.carousel.min.css' | asset_url | stylesheet_tag }}</noscript>
<script src="{{ 'jquery.min.js' | asset_url }}"></script>
<script src="{{ 'owl.carousel.min.js' | asset_url }}"></script>
<script>
$(document).ready(function(){
$('.owl-carousel').owlCarousel({
loop:true,
margin:10,
responsiveClass:true,0
responsive:{
0:{
items:1,
nav:true
},
600:{
items:3,
nav:false
},
1000:{
items:5,
nav:true,
loop:false
}
}
});
});
</script>
{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}
#media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}
<div class="color-{{ section.settings.color_scheme }} gradient no-js-hidden">
<product-recommendations class="product-recommendations page-width section-{{ section.id }}-padding isolate" data-url="{{ routes.product_recommendations_url }}?section_id={{ section.id }}&product_id={{ product.id }}&limit={{ section.settings.products_to_show }}">
{% if recommendations.performed and recommendations.products_count > 0 %}
<h2 class="product-recommendations__heading {{ section.settings.heading_size }}">{{ section.settings.heading | escape }}</h2>
<ul class="owl-carousel">
{% for recommendation in recommendations.products %}
<li>
{% render 'card-product',
card_product: recommendation,
media_aspect_ratio: section.settings.image_ratio,
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating
%}
</li>
{% endfor %}
</ul>
{% endif %}
</product-recommendations>
</div>
If there is a simpler way to do it, it would also help me, I am avoiding incorporating third-party apps to maintain the speed and efficiency of my website
Related
I Have a custom product grid for one of the brands I am selling that has 4 tabs to hover and the content is changing in every tab. When i try to create another grid, 2 of the tabs are not showing the pictures i've inserted. First tab that's not showing pictures
and 2 of the tabs are showing as needed.
Security section
The code is the same for both sections.
<div class="tab">
<button class="tablinks" onmouseover="openCity(event, 'Switches')" id="defaultOpen">Switches</button>
<button class="tablinks" onmouseover="openCity(event, 'Routers')">Routers</button>
<button class="tablinks" onmouseover="openCity(event, 'Security')">Security</button>
<button class="tablinks" onmouseover="openCity(event, 'Wireless')">Wireless</button>
</div>
<script type="lazyload2">
// Get the element with id="defaultOpen" and click on it
setTimeout(function() { openCity(event, 'Switches'); document.getElementById('defaultOpen').className += " active"});
</script>
<div class="row tabcontent" id="Switches" style="margin-left:-10px;margin-right:-10px;">
<div class="mobile-grid-2 col-md-{{ section.settings.banner_col_1 }} col-sm-{{ section.settings.banner_col_1 }}" style="padding-left:10px;padding-right:0px;padding-bottom:15px;">
{% if section.settings.image_banner_col_1 != blank %}
{% assign img_banner_col_1 = section.settings.image_banner_col_1 | img_url: "master" %}
{% assign img_banner_col_1_alt = section.settings.image_banner_col_1_alt %}
{% else %}
{% assign img_banner_col_1 = 'img566x566.png' | asset_url %}
{% endif %}
<a href="{{ section.settings.banner_link_1 }}">
<div class="banner-inner" style="background: radial-gradient(#Fff 10%, #e8e8e8);height: 598px;">
<div class="grid-image">
<img class="img-responsive lazyloaded lazy2 main" data-src="{{ img_banner_col_1 }}" alt="{{ img_banner_col_1_alt }}">
</div>
<div class="content-banner">
{% if settings.language_enable %}
<span class="lang1">{{ section.settings.content_banner_1 | split: '[lang2]' | first }}</span>
<span class="lang2">{{ section.settings.content_banner_1 | split: '[lang2]' | last }}</span>
{% else %}
<span>{{ section.settings.content_banner_1 | split: '[lang2]' | first }}</span>
{% endif %}
</div>
</div>
</a>
</div>
<div class="col-md-{{section.settings.banner_col_2}} col-sm-{{section.settings.banner_col_2}}" style="padding-left:10px;padding-right:10px;padding-bottom:15px;">
<div class="row">
<div class="mobile-grid banner_item col-md-12 col-sm-12" style="padding-right:10px; padding-bottom: 10px;">
{% if section.settings.image_banner_col_2_1 != blank %}
{% assign img_banner_col_2_1 = section.settings.image_banner_col_2_1 | img_url: "master" %}
{% assign img_banner_col_2_1_alt = section.settings.image_banner_col_2_1_alt %}
{% else %}
{% assign img_banner_col_2_1 = 'img566x273.png' | asset_url %}
{% endif %}
<a href="{{ section.settings.banner_link_2_1 }}">
<div class="banner-inner" style="background: radial-gradient(#Fff 10%, #e0e5e9);height: 294px;">
<div class="grid-image">
<img data-src="{{ img_banner_col_2_1}}" class="img-responsive lazyloaded lazy2 main" alt="{{ img_banner_col_2_1_alt }}">
</div>
<div class="content-banner">
{% if settings.language_enable %}
<span class="lang1">{{ section.settings.content_banner_2_1 | split: '[lang2]' | first }}</span>
<span class="lang2">{{ section.settings.content_banner_2_1 | split: '[lang2]' | last }}</span>
{% else %}
<span>{{ section.settings.content_banner_2_1 | split: '[lang2]' | first }}</span>
{% endif %}
</div>
</div>
</a>
</div>
</div>
<div class="row">
<div class="mobile-grid banner_item col-md-6 col-sm-6" style="padding-right:10px;">
{% if section.settings.image_banner_col_2_2 != blank %}
{% assign img_banner_col_2_2 = section.settings.image_banner_col_2_2 | img_url: "master" %}
{% assign img_banner_col_2_2_alt = section.settings.image_banner_col_2_2_alt %}
{% else %}
{% assign img_banner_col_2_2 = 'img566x273.png' | asset_url %}
{% endif %}
<a href="{{ section.settings.banner_link_2_2 }}">
<div class="banner-inner" style="background: radial-gradient(#Fff 10%, #eeecea); height: 294px;">
<div class="grid-image">
<img data-src="{{ img_banner_col_2_2}}" class="img-responsive lazyloaded lazy2 main" alt="{{ img_banner_col_2_2_alt }}">
</div>
<div class="content-banner">
{% if settings.language_enable %}
<span class="lang1">{{ section.settings.content_banner_2_2 | split: '[lang2]' | first }}</span>
<span class="lang2">{{ section.settings.content_banner_2_2 | split: '[lang2]' | last }}</span>
{% else %}
<span>{{ section.settings.content_banner_2_2 | split: '[lang2]' | first }}</span>
{% endif %}
</div>
</div>
</a>
</div>
<div class="mobile-grid banner_item col-md-6 col-sm-6" style="padding-left:0px;">
{% if section.settings.image_banner_col_3 != blank %}
{% assign img_banner_col_3 = section.settings.image_banner_col_3 | img_url: "master" %}
{% assign img_banner_col_3_alt = section.settings.image_banner_col_3_alt %}
{% else %}
{% assign img_banner_col_3 = 'img566x273.png' | asset_url %}
{% endif %}
<a href="{{ section.settings.banner_link_3 }}">
<div class="banner-inner" style="background: radial-gradient(#Fff 10%, #dbe2e4); height: 294px;">
<div class="grid-image">
<img data-src="{{ img_banner_col_3}}" class="img-responsive lazyloaded lazy2 main" alt="{{ img_banner_col_3_alt }}">
</div>
<div class="content-banner">
{% if settings.language_enable %}
<span class="lang1">{{ section.settings.content_banner_3 | split: '[lang2]' | first }}</span>
<span class="lang2">{{ section.settings.content_banner_3 | split: '[lang2]' | last }}</span>
{% else %}
<span>{{ section.settings.content_banner_3 | split: '[lang2]' | first }}</span>
{% endif %}
</div>
</div>
</a>
</div>
</div>
</div>
</div>
And this is the code i am using for other sections
<div class="row tabcontent" id="Security" style="margin-left:-10px;margin-right:-10px;">
<div class="mobile-grid-2 col-md-{{ section.settings.banner_col_7 }} col-sm-{{ section.settings.banner_col_7 }}" style="padding-left:10px;padding-right:0px;padding-bottom:15px;">
{% if section.settings.image_banner_col_7 != blank %}
{% assign img_banner_col_7 = section.settings.image_banner_col_7 | img_url: "master" %}
{% assign img_banner_col_7_alt = section.settings.image_banner_col_7_alt %}
{% else %}
{% assign img_banner_col_7 = 'img566x566.png' | asset_url %}
{% endif %}
<a href="{{ section.settings.banner_link_7 }}">
<div class="banner-inner" style="background: radial-gradient(#Fff 10%, #e8e8e8);height: 598px;">
<div class="grid-image">
<img class="img-responsive lazyloaded lazy2 main" data-src="{{ img_banner_col_7 }}" alt="{{ img_banner_col_7_alt }}">
</div>
<div class="content-banner">
{% if settings.language_enable %}
<span class="lang1">{{ section.settings.content_banner_7 | split: '[lang2]' | first }}</span>
<span class="lang2">{{ section.settings.content_banner_7 | split: '[lang2]' | last }}</span>
{% else %}
<span>{{ section.settings.content_banner_7 | split: '[lang2]' | first }}</span>
{% endif %}
</div>
</div>
</a>
</div>
<div class="col-md-{{section.settings.banner_col_8}} col-sm-{{section.settings.banner_col_8}}" style="padding-left:10px;padding-right:10px;padding-bottom:15px;">
<div class="row">
<div class="mobile-grid banner_item col-md-12 col-sm-12" style="padding-right:10px; padding-bottom: 10px;">
{% if section.settings.image_banner_col_8 != blank %}
{% assign img_banner_col_8 = section.settings.image_banner_col_8 | img_url: "master" %}
{% assign img_banner_col_8_alt = section.settings.image_banner_col_8_alt %}
{% else %}
{% assign img_banner_col_8 = 'img566x273.png' | asset_url %}
{% endif %}
<a href="{{ section.settings.banner_link_8 }}">
<div class="banner-inner" style="background: radial-gradient(#Fff 10%, #e0e5e9);height: 294px;">
<div class="grid-image">
<img data-src="{{ img_banner_col_8}}" class="img-responsive lazyloaded lazy2 main" alt="{{ img_banner_col_8_alt }}">
</div>
<div class="content-banner">
{% if settings.language_enable %}
<span class="lang1">{{ section.settings.content_banner_8 | split: '[lang2]' | first }}</span>
<span class="lang2">{{ section.settings.content_banner_8 | split: '[lang2]' | last }}</span>
{% else %}
<span>{{ section.settings.content_banner_8 | split: '[lang2]' | first }}</span>
{% endif %}
</div>
</div>
</a>
</div>
</div>
<div class="row">
<div class="mobile-grid banner_item col-md-6 col-sm-6" style="padding-right:0px;">
{% if section.settings.image_banner_col_9 != blank %}
{% assign img_banner_col_9 = section.settings.image_banner_col_9 | img_url: "master" %}
{% assign img_banner_col_9_alt = section.settings.image_banner_col_9_alt %}
{% else %}
{% assign img_banner_col_9 = 'img566x273.png' | asset_url %}
{% endif %}
<a href="{{ section.settings.banner_link_9 }}">
<div class="banner-inner" style="background: radial-gradient(#Fff 10%, #e0e5e9);height: 294px;">
<div class="grid-image">
<img data-src="{{ img_banner_col_9}}" class="img-responsive lazyloaded lazy2 main" alt="{{ img_banner_col_9_alt }}">
</div>
<div class="content-banner">
{% if settings.language_enable %}
<span class="lang1">{{ section.settings.content_banner_9 | split: '[lang2]' | first }}</span>
<span class="lang2">{{ section.settings.content_banner_9 | split: '[lang2]' | last }}</span>
{% else %}
<span>{{ section.settings.content_banner_9 | split: '[lang2]' | first }}</span>
{% endif %}
</div>
</div>
</a>
</div>
<div class="mobile-grid banner_item col-md-6 col-sm-6" style="padding-right:10px;">
{% if section.settings.image_banner_col_10 != blank %}
{% assign img_banner_col_10 = section.settings.image_banner_col_10 | img_url: "master" %}
{% assign img_banner_col_10_alt = section.settings.image_banner_col_10_alt %}
{% else %}
{% assign img_banner_col_10 = 'img566x273.png' | asset_url %}
{% endif %}
<a href="{{ section.settings.banner_link_10 }}">
<div class="banner-inner" style="background: radial-gradient(#Fff 10%, #eeecea); height: 294px;">
<div class="grid-image">
<img data-src="{{ img_banner_col_10}}" class="img-responsive lazyloaded lazy2 main" alt="{{ img_banner_col_10_alt }}">
</div>
<div class="content-banner">
{% if settings.language_enable %}
<span class="lang1">{{ section.settings.content_banner_10 | split: '[lang2]' | first }}</span>
<span class="lang2">{{ section.settings.content_banner_10 | split: '[lang2]' | last }}</span>
{% else %}
<span>{{ section.settings.content_banner_10 | split: '[lang2]' | first }}</span>
{% endif %}
</div>
</div>
</a>
</div>
</div>
</div>
</div>
What is the mistake i am making here?
I've tried copying the working grids code and edited from there. Still the same. Can't see banner parts.
it shows only even image in slider odd images are hidden
0
I've assigned a variable in liquid and made odd and even classes I need one even and one odd in the image block class
was looking for the syntax on Google/Shopify cheatsheet/liquid Github wiki and can't seem to find anything that works
is this possible?
i was trying
{% for media in product.media %}
{% assign mod = forloop.index | modulo: 2 %}
<div class="image-block">
{%if mod == 0 %}
<div class="even">
<a href="{{ media.preview_image | img_url: product_image_zoom_size, scale: product_image_scale }}"
class=" product-single__thumbnail--{{ section.id }} even count-{{forloop.index}}"
data-thumbnail-id="{{ section.id }}-{{ media.id }}"> <img class="product-single__thumbnail-image" src="{{ media.preview_image | img_url: 'large', scale: 2 }}" alt="{{ thumbnailAlt }}"></a>
</div>
{%endif%}
{% for media in product.media %}
{% assign mod2 = forloop.index | modulo: 2 %}
{%if mod2 != 0 %}
<div class="odd">
<a href="{{ media.preview_image | img_url: product_image_zoom_size, scale: product_image_scale }}"
class=" product-single__thumbnail--{{ section.id }} odd count-{{forloop.index}}"
data-thumbnail-id="{{ section.id }}-{{ media.id }}"> <img class="product-single__thumbnail-image" src="{{ media.preview_image | img_url: 'large', scale: 2 }}" alt="{{ thumbnailAlt }}"></a>
</div>
{% break %}
{%endif%}
{% endfor %}
</div>
{% endfor %}
</div>[enter image description here][1]
Simply use the same as into snapshot on the desired element where you want to apply the class using cycle.
<div class="col px-2 px-lg-3 pb-3 pb-lg-4 {% cycle 'even','odd' %}">
and add the class on the front end like it.
Let me know if the same clears your doubts regarding it?
update in to your code:
{% for media in product.media %}
<div class="image-block">
<div class="{% cycle 'even','odd' %}">
<a href="{{ media.preview_image | img_url: product_image_zoom_size, scale: product_image_scale }}"
class=" product-single__thumbnail--{{ section.id }} even count-{{forloop.index}}"
data-thumbnail-id="{{ section.id }}-{{ media.id }}"> <img class="product-single__thumbnail-image" src="{{ media.preview_image | img_url: 'large', scale: 2 }}" alt="{{ thumbnailAlt }}">
</a>
</div>
</div>
{% endfor %}
I can programmatically add it to my page homepage by adding {% section 'header-text' %}, but I want to add it through the "add section" GUI. I looked similar questions and I have {{ content_for_index }} in my index.liquid and {% schema %} and {% endschema %}
Here is my code theme.liquid
<!DOCTYPE html>
<html>
<head>
<title>{{ page_title }}</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="{{ page_description | escape }}" />
<link rel="canonical" href="{{ canonical_url }}" />
<meta
name="viewport"
content="width=device-width,initial-scale=1,shrink-to-fit=no"
/>
{{ content_for_header }}
<!-- Header hook for plugins -->
{{
"application.scss" | asset_url | stylesheet_tag
}}
</head>
<body>
<header class="container-fluid">
<nav class="nav-holder">
<h1>Dreamy Cream</h1>
<div class="nav__button" id="burger">{% include 'icon-navicon' %}</div>
<div class="nav-links" id="menu">
<ul class="nav-items">
{% for link in linklists.main-menu.links %} {% assign
child_list_handle = link.title | handleize %}
<li>
{{ link.title }}
</li>
{% endfor %}
</ul>
{% include 'icon-cart' %}
</div>
</nav>
{% section 'header-text' %}
</header>
<main role="main">
{{ content_for_layout }}
</main>
{{ "application.js" | asset_url | script_tag }}
</body>
</html>
header-text.liquid
<div class="nav__title main" id="{{section.settings.id}}">
<h1>{{section.settings.title}}</h1>
</div>
{% schema %}
{
"name": "opening text",
"class": "opeaning-text-section",
"settings": [
{
"id": "title",
"type": "text",
"label": "Section Title ",
"default": "Taste the intensity"
}
] ,
"presets": [
{
"name": "Title Text",
"category":"Store information"
}
]
}
{% endschema %}
So, I needed a section that was programmed in the theme.liquid {% section 'header-text' %}
I found the solution https://github.com/Shopify/themekit/issues/842
I'm currently new to shopify and using a free theme call saleshunter.
On the product page itself, the thumbnail images on the slider are duplicating. Can you help me solve this?
Here's the code I found for the product images.
<div class="{{ product_image_width }}">
<div class="product-single__images">
<div class="product-single__photos slick-slider manual-init" id="ProductPhoto">
{% for image in product.images %}
<div class="product-single__photos__item">
{% assign featured_image = current_variant.featured_image | default: product.featured_image %}
<img src="{{ image.src | img_url: product_image_size }}" alt="{{ image.alt | escape }}">
</div>
{% endfor %}
</div>
{% if product.images.size > 1 %}
<div class="product-single__thumbnails slick-slider manual-init" id="ProductThumbs">
{% for image in product.images %}
{% for variant in image.variants %}
<div class="product-single__thumbnails__item" {% if image.attached_to_variant? %} data-variant="{{ variant.id }}" {% endif %}
data-index="{{ image.position }}">
<img src="{{ image.src | img_url: product_thumb_size }}"
alt="{{ image.alt | escape }}">
</div>
{% else %}
<div class="product-single__thumbnails__item">
<img src="{{ image.src | img_url: product_thumb_size }}"
alt="{{ image.alt | escape }}">
</div>
{% endfor %}
{% endfor %}
</div>
{% endif %}
</div>
</div>
For whatever reason, the image thumbnails duplicate based on the variants you have (i.e. small, medium, large for a red shirt, blue shirt, and black shirt). Meaning you will have 3 duplicates of one color shirt. To prevent this from happening, remove this code:
{% for variant in image.variants %}
<div class="product-single__thumbnails__item" {% if image.attached_to_variant? %} data-variant="{{ variant.id }}" {% endif %}
data-index="{{ image.position }}">
<img src="{{ image.src | img_url: product_thumb_size }}"
alt="{{ image.alt | escape }}">
</div>
{% else %}
as well as one of the {% endfor %} after this code:
<div class="product-single__thumbnails__item">
<img src="{{ image.src | img_url: product_thumb_size }}"
alt="{{ image.alt | escape }}">
</div>
I am using Brooklyn Shopify theme in mobile the main featured image is in single slide and all the thumbs in one slide, butnow I want each thumb images as single slideshow images just like featured image.
You can do this using some CSS tricks and duplicating fetching of images.
In Product.liquid file duplicate the code images fetched as you said you are using Brooklyn theme I will help you with the same.
Find for this code
<div class="grid product-single">
<div class="grid__item large--seven-twelfths medium--seven-twelfths text-center">
<div class="product-single__photos">
{% assign featured_image = current_variant.featured_image | default: product.featured_image %}
{% comment %}
Display current variant image, or default first
{% endcomment %}
<div class="feature_image top_feature_image">
<div class="product-single__photo-wrapper">
<img class="product-single__photo" id="ProductPhotoImg" src="{{ featured_image | img_url: 'grande' }}" {% if settings.product_zoom_enable %}data-mfp-src="{{ featured_image | img_url: 'grande' }}"{% endif %} alt="{{ featured_image.alt | escape }}" data-image-id="{{ featured_image.id }}">
</div>
</div>
{% comment %}
Display rest of product images, not repeating the featured one
{% endcomment %}
<div class="thumb_images">
{% for image in product.images | limit:4 %}
<div class="product-single__photo-wrapper">
<img class="product-single__photo" src="{{ image.src | img_url: 'grande' }}" {% if settings.product_zoom_enable %}data-mfp-src="{{ image.src | img_url: '1024x1024' }}"{% endif %} alt="{{ image.alt | escape }}" data-image-id="{{ image.id }}">
</div>
{% endfor %}
</div>
</div>
</div>
then Replace with
<div class="grid product-single">
<div class="grid__item large--seven-twelfths medium--seven-twelfths text-center">
<div class="product-single__photos">
{% assign featured_image = current_variant.featured_image | default: product.featured_image %}
{% comment %}
Display current variant image, or default first
{% endcomment %}
<div class="feature_image top_feature_image">
<div class="product-single__photo-wrapper">
<img class="product-single__photo" id="ProductPhotoImg" src="{{ featured_image | img_url: 'grande' }}" {% if settings.product_zoom_enable %}data-mfp-src="{{ featured_image | img_url: 'grande' }}"{% endif %} alt="{{ featured_image.alt | escape }}" data-image-id="{{ featured_image.id }}">
</div>
</div>
{% comment %}
Display rest of product images, not repeating the featured one
{% endcomment %}
{% for image in product.images | limit:3 %}
<div class="product-single__photo-wrapper desk">
<img class="product-single__photo" src="{{ image.src | img_url: 'grande' }}" {% if settings.product_zoom_enable %}data-mfp-src="{{ image.src | img_url: '1024x1024' }}"{% endif %} alt="{{ image.alt | escape }}" data-image-id="{{ image.id }}">
</div>
{% endfor %}
<div class="thumb_images">
{% for image in product.images | limit:4 %}
<div class="product-single__photo-wrapper">
<img class="product-single__photo" src="{{ image.src | img_url: 'grande' }}" {% if settings.product_zoom_enable %}data-mfp-src="{{ image.src | img_url: '1024x1024' }}"{% endif %} alt="{{ image.alt | escape }}" data-image-id="{{ image.id }}">
</div>
{% endfor %}
</div>
</div>
</div>
Now open theme.scss.liquid file and for desktop add this
.desk {
display: none;
}
.desk is the custom class taken by me
and in mobile style ie 767px add this.
.product-single__photo-wrapper.desk {
display: block;
}
.thumb_images {
display: none !important;
}
.slick-dots > li:last-child, .slick-dots > li:nth-last-child(2) {
display: none;
}
This will solve your requirement.