CafePress.comShop, sell or create what's on your mind.

Community ForumsChats & WorkshopsEventsNewslettersCP VoiceLearning CenterCafePress Blog
If you're new to the CafePress Community Forums, be sure to read our Forum Guidelines before you post anything.

    Community Forums: Home    CafePress Community Forums  Hop To Forum Categories  General Help & Sharing  Hop To Forums  Premium Shops & Shop Customization    Javascript to redirect incoming MP links
Page 1 2 3 4 
Go
New
Find
Notify
Tools
Reply
  
  Login/Join 
Moderator
Picture of Teesed
Posted
After being inspired by wolfstad's post in the Likewise script thread, I came up with some easy javascript that will take an incoming link from the Marketplace product page and redirect it to take you right to that product on your page. (currently the MP link takes you to the storefront, not the product page. So the customer has to look around to find what they were looking for.) It's not quite as good as snagging the section number and redirecting them there, but with this javascript and the likewise script together, it works pretty well.

Example:
Marketplace product page
Click on the shop link there. Ding!

What it doesn't do is deal with the marketplace page that shows the design, one level above this one. That url has the design number, and with the api, there's no way (that I know of) to pull in the section numbers for that design, so...here's the code. Change the shop id and put this in the "<HEAD> tag contents" area of your custom html.



<script language="Javascript">
<!-- 

// this script redirects marketplace product page incoming links 
// to the actual product page
// one variable to set - your shop id

var shopid = "teesed";

// that's it. No touchy!

if (document.referrer&&document.referrer!="")
{
  var referrer = document.referrer;

  if (referrer.indexOf("/item/") >= 0)
  {
    urlArray = referrer.split("/");
   var prodNumber = urlArray[urlArray.length -1];
    window.location = "http://www.cafepress.com/" + shopid + "." + prodNumber;
  }

}


//-->
</script>


Updated 6/21/2008 to reflect new marketplace url structure. You MUST update your code in order for it to work.

This message has been edited. Last edited by: Teesed,


 
Reply With QuoteEdit or Delete MessageReport This Post
CP Voice Shop Mgmt Team Member
Picture of scarebaby
Posted Hide Post
Holy crap, if this works I'll give you my firstborn! Smiler




 
Reply With QuoteEdit or Delete MessageReport This Post
Moderator
Picture of Teesed
Posted Hide Post
quote:
Originally posted by scarebaby:
Holy crap, if this works I'll give you my firstborn! Smiler

I've got one of my own and he's all I can handle. How about if it works, you'll take my firstborn for a couple of weeks so I can get some work done around the house!


 
Reply With QuoteEdit or Delete MessageReport This Post
CP Voice Shop Mgmt Team Member
Picture of scarebaby
Posted Hide Post
Nah, instead I'll make a donation to Cafewish and urge others to do so as well!




 
Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
It's not working for me at the moment.
 
Reply With QuoteEdit or Delete MessageReport This Post
Moderator
Picture of Teesed
Posted Hide Post
Strange.. it looks right.
Do me a favor.

right above where it has the window.location line, put this:

document.write(referrer);

and then see what that does when you click from an MP page.


 
Reply With QuoteEdit or Delete MessageReport This Post
Moderator
Picture of RowdyJRT
Posted Hide Post
Thanks Teesed!!! Both scripts are a SK's dream Smiler
 
Reply With QuoteEdit or Delete MessageReport This Post
Picture of jyackley01
Posted Hide Post
Thanks Teesed!

When I copied and pasted from this post, it wouldn't work for me, but I took the liberty of copying and pasting the script from your source code on the page you posted, and now it works perfectly! Thank you!

Jen
 
Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
quote:
Originally posted by Teesed:
Strange.. it looks right.
Do me a favor.

right above where it has the window.location line, put this:

document.write(referrer);

and then see what that does when you click from an MP page.


Nothing. I've tried IE and Firefox.
 
Reply With QuoteEdit or Delete MessageReport This Post
CPV Quality Rep
Picture of Lekker Jen
Posted Hide Post
It also didn't work for me when I copied from the post, but after copying from your source, it works like a dream. I am in love!

It also works with shops that have the CP Shop re-direct on their storefront, FYI.
 
Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
OK, I've now copied it from your source and it works fine.
 
Reply With QuoteEdit or Delete MessageReport This Post
CP Voice Shop Mgmt Team Member
Picture of scarebaby
Posted Hide Post
Not working for me, can someone post the source code or tell me where to see it? Im stupid.




 
Reply With QuoteEdit or Delete MessageReport This Post
Picture of mrshernandez
Posted Hide Post
Scare - click on his example, then click on his store link. Once you get to the page you want to see, right click and you can see all the html for that page. (This is how to see source code for any webpage.)

Here is the actual script from his source code:
(removed since it had the old code in it. Just reference the OP - Teesed)

Just change the store ID from "teesed" to your store name.

I just did 5 stores in 5 minutes. It's a beautiful thing.

Thanks so much Teesed!

This message has been edited. Last edited by: Teesed,
 
Reply With QuoteEdit or Delete MessageReport This Post
CP Voice Shop Mgmt Team Member
Picture of scarebaby
Posted Hide Post
Oh thank you!!! Big Hug




 
Reply With QuoteEdit or Delete MessageReport This Post
CP Voice Shop Mgmt Team Member
Picture of scarebaby
Posted Hide Post
That worked a treat!! Smiler

And i wasn't kidding about making a donation. Hope you received it, Teesed! Smiler




 
Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community Page 1 2 3 4  
 

    Community Forums: Home    CafePress Community Forums  Hop To Forum Categories  General Help & Sharing  Hop To Forums  Premium Shops & Shop Customization    Javascript to redirect incoming MP links

All Content Copyright © 1999-2008 CafePress.com.
All rights reserved. Use of this web site constitutes acceptance of the Terms of Service.
Privacy Policy | Intellectual Property Policy | Content Disclaimer
Always On Top 100 Award Winner
Webby Award Winner 2005
HACKER SAFE certified sites prevent over 99.9% of hacker crime.