Hi Guys,
Any assistance anyone can help with would be greatly appreciated.
I am working on a clients shopify site, and thanks to a few online forums throughout the shopify community pages, I was able to make the "New Arrivals" page for the client.
However they use a pre-order system, alot of their products tend to get restocked. And as such I think this is affecting the "New Arrivals" page as it may be defining the products as "republished", hence showing these republished products on said page as a "New Arrivals".
In saying that does anyone have a rough idea on a way to define code that if a product was once 0 but was then restocked or has a stock level now that is greater than 0 to not show?
This is all being displayed in a collection (code below for reference):
{% comment %} The contents of the collection.liquid template can be found in /sections/collection-template.liquid {% endcomment %} {% section 'collection-template-30days' %} {% if collection.title == 'Whats New At Hearns Hobbies' %} {% assign date_published = product.published_at | date:'%s' %} {% assign date_now = 'now' | date:'%s' %} {% assign date_difference = date_now | minus: date_published %} {% if date_difference > 2592000 %} <style> .pagination, #pagination { display:none;} </style> {% break %} {% endif %} {% endif %} <style> span.page-title { color: black; } .breadcrumb { margin-bottom: 0; margin-top: 0; position: relative; margin-bottom: 15px; } {% if settings.collection_breadcrumb %} {% else %} nav.breadcrumb { display: none; } {% endif %} </style> {% comment %} <div class="grid__item large--one-quarter"> {% include 'collection-sidebar' %} </div> {% endcomment %}
Solved! Go to the solution
Hello MattC2020,
when product will restocked you will update quantity only right?
So if you want to display new arrival product you can get product creation date.
And then display recently created product.
Refer this link to get product creation date:
https://community.shopify.com/c/Shopify-Design/Retrieve-product-creation-date/td-p/127116
Hi @oscprofessional I did what you suggested but it seems that it is still paginating way more products than the page should be.
If you wish to see the page in question I am working on a clients page is: https://www.hearnshobbies.com/collections/new-arrivals
If you see around paginated page 791 you can see that some products (which are old ones) are showing that they are on sale that tells me that these are in fact still old products (and confirming with the staff) in which case the code doesn't seem to be working or I have done something wrong.
I am only partial to liquid so I tried following a few tutorials and trying my own hacked togehether way to get it running, but the main idea is to get only new products within the past month from the current date to display. By my understanding the code you suggested and what I had already implemented should work.
Updated code for reference:
{% comment %} The contents of the collection.liquid template can be found in /sections/collection-template-30days.liquid {% endcomment %} {% section 'collection-template-30days' %} {% if collection.title == 'Whats New At Hearns Hobbies' %} {% assign date_published = product.published_at | date: "%a, %b %d, %y" %}} {% assign date_now = 'now' | date:'%s' %} {% assign date_difference = date_now | minus: date_published %} {% if date_difference > 2592000 %} <style> .pagination, #pagination { } </style> {% break %} {% endif %} {% endif %} <style> span.page-title { color: black; } .breadcrumb { margin-bottom: 0; margin-top: 0; position: relative; margin-bottom: 15px; } {% if settings.collection_breadcrumb %} {% else %} nav.breadcrumb { display: none; } {% endif %} </style> {% comment %} <div class="grid__item large--one-quarter"> {% include 'collection-sidebar' %} </div> {% endcomment %}
This is an accepted solution.
I have further googled around and found some other supporting codes from others attempting the same thing.
I beleive a general work around is to simply hide or not show more than a certain amount of products in saying that, adding a limit to the collection would be ideal.
I adapted my own references and codes, but it seems the limit is still not working.
I am following this community board but it doesnt seem to work.
{% comment %} The contents of the collection.liquid template can be found in /sections/collection-template-30days.liquid {% endcomment %} {% section 'collection-template-30days' %} <!-- Published at {{product.created_at}} --> {% for product in collection.products | limit: 150 %} {% if collection.title == 'Whats New At Hearns Hobbies' %} {% assign date_created = product.created_at | date:'%s' %} {% assign date_now = 'now' | date:'%s' %} {% assign date_difference = date_now | minus: date_created %} {% if date_difference > 2592000 %} <style> .pagination, #pagination { } </style> {% break %} {% endif %} {% endif %} {% endfor %} <style> span.page-title { color: black; } .breadcrumb { margin-bottom: 0; margin-top: 0; position: relative; margin-bottom: 15px; } {% if settings.collection_breadcrumb %} {% else %} nav.breadcrumb { display: none; } {% endif %} </style> {% comment %} <div class="grid__item large--one-quarter"> {% include 'collection-sidebar' %} </div> {% endcomment %}
That's a hack rather thaт фa solution. Any theme/liquid-based solution is not good. What if the number of products is more than 150 in your collection? The date is also cached by Shopify and 'now' doesn't contain the correct value, so the time difference won't be correct as well.
The better option is to create an automatic tag-based collection. Then you can tag your products with whatever tag you chose. This will allow you to use the same collection template and keep pagination working normally.
Then if you prefer to automate the process you can use a New Arrivals app to assign/remove the chosen tag from products based on the creation date.
Unfortunately this solution wouldnt work in our use case, as we use an external inventory management system which cross checks with shopify to keep product inventory descriptions etc up to date. The pre-order app doesnt affect this so our in house program works as intended. However if we add additional tags using such an app it will cause our system with shopify to fall out of sync. I appreciate the answer, however this fix I am running seems to be working fine for the time being.
Whether its a hack or not, it is working~
Hi Matt,
Thanks for your reply. Is your external inventory management system updates Shopify product tags as well, is that the reason why it won't work? As a developer of that app, I'm trying to understand any pitfalls customer may face when they install the app, so I would really appreciate if you clarify that.
That's good that your current solution in place works on your store, it's better to not touch things that work well
User | Count |
---|---|
417 | |
209 | |
101 | |
89 | |
73 |