Go to theme and add custom liquid block where you want to show related products and also mention meta field value that you want to show instead of product title
{% assign related_products = product.metafields.custom.related_products.value %}
{% if related_products and related_products != blank %}
<div class="related-products">
<h3>Related Products</h3>
<div class="related-products-list">
{% for recommended in related_products %}
<div class="related-product">
<a href="{{ recommended.url }}" class="related-product-link">
<div class="related-product-image">
{% if recommended.featured_image %}
<img src="{{ recommended.featured_image.src | img_url: 'medium' }}" alt="{{ recommended.title }}">
{% else %}
<img src="{{ 'no-image.png' | asset_url }}" alt="No image available">
{% endif %}
</div>
<div class="related-product-details">
<!-- Displaying the color_name metafield as the title -->
<h4 class="related-product-title">
{% if recommended.metafields.custom.color_name %}
{{ recommended.metafields.custom.color_name.value }}
{% else %}
{{ recommended.title }}
{% endif %}
</h4>
</div>
</a>
</div>
{% endfor %}
</div>
</div>
{% endif %}
css to beautify the section
.related-products {
margin-top: 20px;
}
.related-products h3 {
font-size: 1.5em;
margin-bottom: 10px;
}
.related-products-list {
display: flex;
flex-wrap: wrap;
gap: 20px; /* Adjust spacing between related products */
}
.related-product {
width: calc(50% - 20px);
padding: 10px;
border: 1px solid #ddd;
}
.related-product-link {
display: flex;
flex-direction: column;
text-align: center;
text-decoration: none;
color: #333;
}
.related-product-image img {
width: 100%;
height: auto;
max-height: 200px; /* Adjust image height as needed */
object-fit: cover;
border-radius: 5px;
}
.related-product-details {
padding: 10px 0;
}
.related-product-title {
color: var(--g-color-heading);
font-weight: var(--g-p-font-weight);
line-height: var(--g-p-font-lineheight);
font-size: var(--g-p-font-size);
font-family: var(--g-p-font_family);
letter-spacing: var(--g-p-font-spacing);
text-transform: var(--g-p-font-transform);
display: block;
}
.related-product-price {
font-weight: bold;
color: #f00; /* Adjust price color */
}
Convert website to android and ios application using react native expo webview If you want to check you can check on github by using below link also dont forget to give star ;) Source Code: https://github.com/shubham715/react-native-expo-webview-convert-website-to-app React native is the best choice to create multi platform mobile application , but sometimes we dont want to write a complete application because we already have a web application or a website and its complicated to manage both . So we have a solution for this problem. React native supports webView that makes easy to run any website url like an app natively. What is webview in react native? In React native, WebView helps to show web content in a native view. For this tutorial we will use EXPO. What is EXPO ? EXPO a set of tools to help you quickly start an app. Expo have many inbuilt components that helps to simplify the development and testing of React Native app. So please follow the below steps to c...
Comments
Post a Comment