Shopify Where to Setup Returns Texts - shopify

Where in the admin panel can I setup some kind of product returns text and then call it in the product.liquid template?
I've setup a new tab for the product description now I need to find a way to setup and pull the returns text information.
<div class="tabs">
{% if product.description.size > 0 %}
<div class="tab" id="product-description-tab">
<div class="tab-title">Description</div>
<div class="tab-content">
{{ product.description }}
</div>
</div>
{% endif %}
</div>

So to answer question, if content is always the same for all products:
First solution, you may use a page content :
Create a page with needed content
Add theme option allowing theme user to choose the page content to display
Retrieve settings to display page content wherever you need in your product template - To do it clean, add a condition to display nothing if settings value is empty.
Second solution:
Create theme setting with textarea type
Retrieve setting to display content wherever you want in your product template
Add a condition to display nothing if setting value is blank.
Documentation about settings_schema.json is available here: https://help.shopify.com/themes/development/theme-editor/settings-schema
HTH

Related

Loading Shopify Product Metafields in snippets

I am trying to edit the default "Dawn" theme in my shopify store. My aim is to output product meta fields through a snippet. To do that, I have created a snippet called "color-swatches.liquid" which has the following code:
<div class="sw-external-links modification">
{%- if product.metafields.my_fields.current_product_color -%}
</div>
When calling this snippet from product-card.liquid, I use the following liquid code:
{% render 'color-swatches', product: product_card_product %}
But I am not able to output the value of current_product_color metafield inside product.
If I paste the snipped code directly in product-card.liquid like this, it works:
{{ product_card_product.metafields.my_fields.current_product_color }}
Can you please tell me what am I doing wrong? I just want the snippet code to output the current_product_color metafield when I pass the product_card_product variable to it.
Although there is not enough information in your question, I will try to help you the best I can.
In the snippet file (color-swatches.liquid), check if you're using the correct variable when accessing the product's metafield.
If you render your snippet (in 'product-card.liquid') like this:
{% render 'color-swatches', MY_PRODUCT: product_card_product %},
Then you should access the metafield (in 'color-swatches.liquid') like this:
{{ MY_PRODUCT.metafields.my_fields.current_product_color }}
Check that if statement.
In liquid, prefer the != blank syntax:
{%- if product.metafields.my_fields.current_product_color != blank -%}
Check if the if statement even works.
For that try to render the snippet outside the if.
If nothing is working double check yourself everywhere.
Do this using <script>console.log({{ YOUR_LIQUID_CODE | json }})</script> and check the browser's console to see the logs.
In both files, check the metafield, and the product.

How do i check product page template in shopify

I need to add some text in product page add to cart button, how to check that its product page template.
i have already tried like :: {% if template contains 'product' %}
Check with
{{ template }}
Returns product if your on a product page. Returns product.alternate if that's the template for a specific product

Shopify - Order Products By Custom Field

we have a simple Shopify store using the free "Meta Fields Editor" to add a simple custom field integer value to each of the products. Some products will have a meta value of 3, others 2 or 1. Many will have no meta value at all. We would like to be able to display the products in search results, by the meta field value entered for each product in descending order (weighted ordering). However, despite the ability to set meta values and display them in search results and collections pages, Shopify does not make it easy to Order or Sort products by a custom meta field. In the search results page I am able to call the custom meta value using
{{item.metafields.important.important}}
So far I have tried to order the products using this method
{% assign products = collection.products | sort:
'item.metafields.important.important' %}
{% for product in products %}
{{ product.title }}
{% endfor %}
But this results in null results.
Any insight anyone can give me in how to display products in order of a custom field would be much appreciated!
After attempting to find a Liquid solution I was finally able to solve this problem using custom metafields and jQuery. In the Shopify collection template, I added a data attribute to be included with each product like so:
<div id="product_list">
<div data-imp="{{product.metafields.important.important}}" class="product_block" /> PRODUCT #1 </div>
<div data-imp="{{product.metafields.important.important}}" class="product_block" /> PRODUCT #2 </div>
</div>
Then I used a simple jQuery function to sort the nodes by data attribute in descending order
var $wrapper = $('#product_list');
$wrapper.find('.product_block').sort(function (a, b) {
return +b.dataset.imp - +a.dataset.imp;
})
.appendTo( $wrapper );
}
Hope this helps somebody!
Nope. Doesn't work. Only fixed filters affect the sorting order. You can manually sort the products from the collection page in admin panel.

Hide the catalog page on Shopify

Is there a way to hide the catalog page in Shopify? Here is more detail about the Shopify catalog page.
You might add an automatic javascript redirection to home when collection URL contains 'all'.
So this could be something like this in collection template in your theme :
{% if collection.handle == 'all' %}
<script>window.location.href = '{{ shop.url }}';</script>
{% else %}
Usual code for collection template display if this is not the 'all' collection.
{% endif %}
Please note that is NOT RECOMMENDED practice.
For example, if your customer has disabled Javascript, the page content will be blank as redirection won't work.
A better practice would be to not index page in search engines, so if there is no internal link and if search engines do not index it, no one will see it.
To do that, open the 'theme.liquid' template, and then, add this in <head> section :
{% if collection.handle == 'all' %}
<meta name="robots" content="noindex">
{% endif %}
HTH
Can you please give us a little more details about what you want ? If you want to remove the catalog from main menu , you need to go to Online store > navigation > find the main menu and remove catalog from there. That will remove the menu named catalog from your theme.
https://help.shopify.com/manual/sell-online/online-store/menus-and-links
If you donot want to show any product in the catalog page, you need to go to Online store > themes > edit html/css of the active theme and modify the collection.liquid to remove the section that displays the products.
Give us more details so that we can help you properly.
From the link you provided:
All Shopify stores have a page at the URL your-store.com/collections/all that lists all of the visible products in the store. This is the store's catalog page. By default, products on the catalog page are shown in alphabetic order. You can create a collection to control the order in which your products are shown on this page.
If you want to hide / remove that page altogether, you need to do a few things:
Create a collection to control your catalog page, as described via that same link,
Redirect it so that anyone that visits the page gets taken somewhere else e.g. your homepage. You can use the snippet below, based on this excellent answer for "Redirect[ing] from an HTML page" [or, in this case, a Liquid template:]
{%- layout none -%}
{%- assign title = "Nothing to See Here!" -%}
{%- assign url = shop.url -%}
<!DOCTYPE HTML>
<html lang="en-US">
<head>
{%- include 'head-meta' -%}
<meta http-equiv="refresh" content="1;url={{ url }}">
<script type="text/javascript">
window.top.location.href = "{{ url }}"
</script>
</head>
<body>
<h1>{{ page_title }}</h1>
<p>If you are not redirected automatically, follow the link.</p>
</body>
</html>
Remove it from the sitemap. You can do that (for this Collection or any Shopify resource) using my answer here — tl;dr add a metafield.seo.hidden with value 1.

Shopify - Template check within product-loop

Does anybody know that is possible to check the template within product-loop? So, if one of the listed product's template is different, somehow I need to know.
Any idea?
You can use the global template variable to access the name of the template used to render the current page. For example:
{% if template contains 'product' %}
This is a product page...
{% endif %}
Or you might want product.template_suffix:
Returns the name of the custom product template assigned to the product, without the product. prefix nor the .liquid suffix. Returns nil if a custom template is not assigned to the product.
Input
<!-- on product.wholesale.liquid -->
{{ product.template_suffix }}
Output
wholesale