Random product possible presentation

by fake monkey - Member - 11:09AM, Jul 30, 2006

As anybody been able to create a random product zone on the home-page.

While I’ve got the featured pieces selected by hand, I’d like some sort main featured product that was selected by random each time the screen was refreshed.

It would have the medium size image and a snippet of the description and then link through to the product.

I understand the need for the shop owner to choose the products on the home-page but the more dynamic element to promotion would be really useful for creating a site which may be more compelling to the end user by having the content change. It should also allow more products to be promoted by not just focusing on the featured ones.

I also recognise that it could entirely be possible that a featured product may also be the random product.

I suppose in the long run (a long way off) I’d like the ability based on some sort of business rules to create promotion zones within the site that change based on how someone interacts with the site.

Sebastian Gräßl

Member

07:56AM, Jul 31, 2006

i was thinking about a random picker earlier. i think a simple filter that gives you back a new collection from the given collection would be really nice. Something like this:
{% for item in random(collections.frontpage.products) %}
 {{ item.title }}
{% endfor %}

Richard Quick

Shopify Advisor

01:18PM, Jul 31, 2006

I already asked Tobi about this and it doesn’t exist, and never will, because Shopify caches pages .. and having a random function would mean they had to be created on the fly every time – which would slow things down a lot.

I’ve used Javascript on my homepage, http://www.thepasty.com, to generate a random image to use.

The way to modify this to allow people to see a random product(s) would be to put all the possible products on the page, each with a unique ID (eg id=”random12”) but give them a class of “hidden” (eg, display: none) so that none of them show up by default.

Then, when the page loads, Javascript could pick a random number (up to the total number of images you had) and then show the product with that number.

Make sense?


Richard Quick
thePasty.comRichardQuickDesign.com

fake monkey

Member

06:55PM, Jul 31, 2006

Yeah, that makes sense.

I was just hoping to avoiding using client-side scipt and let the server take the strain.

Also you may well end up with having huge home-pages which to the end-suer means more slower downloads.

If there was away of storing this data in some sort of feed which the script could access, that would be great.

The next complexity is how you create the feed. Although i suspect there is some kind of xml extract lurking deep in shopify.

I face the same issue at work and battle with the IS teams who cache absolutly everything and make it very difficult for us to flush these caches.

Oh, the joys of ecommerce.

Richard Quick

Shopify Advisor

07:37PM, Jul 31, 2006

Well, you could do something like that with AJAX.

Although the X in Ajax stands for XML you don’t “need” to request XML, you can request HTML, for example.

What I’d suggest is making a collection called “ajaxrequest” which contains all the products you want in it.

Then, in your collections.liquid file put an “if” right at the begining.

If the collection.title ISN’T equal to to “ajaxrequest” :

{% if collection.title != "ajaxrequest" %}

Then you could show the page as normal.

But if it IS

{% else %}

Then you could create some clean, easy to read (by Ajax) markup


<div class="ajax-product-name">Product</div>
<div class="ajax-product-code">1234</div>
<div class="ajax-product-price">$12.99</div>
etc.
{% endif %} 

Using AJAX you’d read all this information into memory, select one product at random, and render the HTML to display it as you saw fit.

Basically, you’re creating a pseudo-RSS feed – if that makes sense?


Richard Quick
thePasty.comRichardQuickDesign.com

fake monkey

Member

09:12PM, Jul 31, 2006

Richard

While i get the theory, at the moment it’s beyond my tired brain.

If I was doing this in the day time, i’d get there in the end.

But at the mo seem to spending time at work thinking about aquisition, rentention and migration and so my head hurts.

Great concept, and you could be the man to make it work.

I’d help in any way possible but scripting skills are way below par, and they are slipping every day.

I love your book idea by the way.

Claudia

Member

04:03PM, Dec 14, 2006

I would like to put one random product image on my front page that changes when the browser is refreshed, and cannot understand a word Richard said. (Which is not Richard’s fault!)

If I use a javascript, how do I tell it where to find my images and how to size them?

Will this thing written for Ruby on Rails at Hivelogic work? If so, how would it be implemented here?

Thanks!

alexknowshtml

Member

04:53PM, Dec 14, 2006

Richard,
That technique for pseudo-ajax behavior is fantastic. Thanks, this thread is bookmarked for that!

danW

Shopify Advisor

07:00PM, Dec 14, 2006

Take a look at the cycle method. You can create a collection and cycle the product to be displayed. Not random, but would give you a different result every time.

The wiki is down right now or I would post an example.

---

Dan

Andy Ciordia

Member

07:46PM, Jun 21, 2007

I’ve been looking for further info on the cycle method but I’m not mapping how to translate the cycle idea into a rotating image from a group.

How do I turn: {% tablerow product in collections.frontpage.products cols:1 limit:3 %} into something that can cycle the frontpage collection?

-a

---

it’s my island: http://andy.ciordia.info
The Secret Chocolatier: http://thesecretchocolatier.com (shopify)

danW

Shopify Advisor

05:53PM, Jun 26, 2007

What exactly do you mean cycle the frontpage collection? Do you want like a slide show, or display a random image everytime the page is refreshed or viewed?

Check out my commment here for the latter.
http://forums.shopify.com/categories/2/posts/10722#comment-10731

---

Dan

You must login to post a comment!

Don't have an account yet? Sign up for one.