vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.7 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=228)
-   -   Integration with vBulletin - Cafe Press (https://vborg.vbsupport.ru/showthread.php?t=182424)

Dylanblitz 06-13-2008 10:00 PM

Cafe Press
 
At this time this mod is not functioning correctly. Cafepress has redone their free site template and it will take a rewrite of this mod to get it to work again. Not extremely difficult, just time consuming. Unfortunately, 2 jobs, a sick kid and commercial work leaves free time few and far between nowadays. I will try and work on it when I can. If any other coder out there is interested they are free to take what I have and run with it, just like Creed posted on his original code.


This is a reworked version of the abandoned Cafe Press mod done by Creed.

This add-on will allow you to add all the items from any of your Cafe Press store's or multiples if you so choose. If you have multiple stores you are going to use, make sure you separate each store name with a comma.

This add-on works with Cafe Press basic store, as well as with premium stores.

Two files to upload.
One (optional) Template Edit.

Basic Store Demo

Basic Store Single Item Demo

If you have at least 2.0.3 installed then only change needed is to replace the shop.php file. You do not need to reimport the product.

PREMIUM OWNERS PLEASE READ!!
I will not be able to officially support the shops of premium owners. The main problem is that there is no standardization on the templates available to premium users, especially in the css and notes markup which is what I count on for the script, and it's unrealistic to try and code for each one. The shop works for premium shops with the default template and no css added. A lot of the templates mess up the formatting.

I will help with what I can but there is only so much I can do.
When asking for help please include the following:
path to your shop.php file
store id
template used (if possible)


Version History
v2.0.8 - [Tue 22th July 2008]
Removed Call-time pass-by-reference
Modified code to be xhtml valid (Thanks Enclave)

v2.0.7 - [Fri 11th July 2008]
Fixed category links

v2.0.6 - [Fri 27th June 2008]
Fixed link to create your own online shop

v2.0.5 - [Fri 27th June 2008]
Moved View Cart button to get it out of the Add to Cart form
Fixed hard code from store.php to shop.php
Added security for GET variable *Thanks Tim :)

v2.0.4 - [Fri 27th June 2008]
Removed cream background color on item view
Added navbar link to go back to main shop
Fixed mouseover color changes
Fixed Larger Image link

v2.0.3 - [Thur 26th June 2008]
Changed into a VB Product
Moved settings to AdminCP
Added AdSense capabilities
fixed bug with accessing some images on local drive instead of cafepress

v2.0.1 - [Sat 14th June 2008]
Changed qualification to pull in content to deal with multiple page types
(shop.php File Change only, nothing else needed)

v2.0.0 - [Fri 13th June 2008]
Initial Release

Hornstar 06-13-2008 11:13 PM

Looks good, i've been meaning to sell apparel on my site for some time, if im right, this will help with that through cafe press.

dreads 06-13-2008 11:18 PM

Ah I only wished that CafePress did not request a tax id

MikeHolohan 06-14-2008 03:56 AM

Will definitely check this out...

logicuk 06-14-2008 06:31 AM

Quote:

Originally Posted by dreads (Post 1548805)
Ah I only wished that CafePress did not request a tax id

what about http://zazzle.com/ ?

Hornstar 06-14-2008 06:55 AM

Can you create custom shirts from the site, and then sell them through this? and where is the checkout done through?

Dylanblitz 06-14-2008 07:25 AM

Quote:

Originally Posted by hornstar1337 (Post 1548984)
Can you create custom shirts from the site, and then sell them through this? and where is the checkout done through?

No, this is just a way to display your existing cafe press account while staying on your forum. The checkout and shopping cart is done with cafe press.

sdavis2702 06-14-2008 09:22 AM

Oh snap... this is right up my lane. I'm going to try this out definately. If it works the way I'm thinking it will... this will probably be one of my favorite hacks.

Wait something isn't working for me. I followed the directions just fine but my items from my shop aren't displaying on my site. Any clue why this is happening? My shop name is AFCC... which I replaced "you_store_name" with on the PHP. Just not working for some reason. The site is in my sig and the link is in my NavBar. Thanks!

Dylanblitz 06-14-2008 10:09 AM

Quote:

Originally Posted by sdavis2702 (Post 1549031)
Oh snap... this is right up my lane. I'm going to try this out definately. If it works the way I'm thinking it will... this will probably be one of my favorite hacks.

Wait something isn't working for me. I followed the directions just fine but my items from my shop aren't displaying on my site. Any clue why this is happening? My shop name is AFCC... which I replaced "you_store_name" with on the PHP. Just not working for some reason. The site is in my sig and the link is in my NavBar. Thanks!

Hmm, do you have a premium site or basic? I just signed up for basic to do testing, looks like some code is different on your site though.

sdavis2702 06-14-2008 10:25 AM

I believe I am in the free trial period of a premium site... could that be the issue?

Dylanblitz 06-14-2008 10:30 AM

Quote:

Originally Posted by sdavis2702 (Post 1549053)
I believe I am in the free trial period of a premium site... could that be the issue?

I sent you a pm with a tester to look at. It might be a difference in how their code works between premium vs free. Let me know if what I sent you will work. I'm not 100% happy with the compromise but it's the best I can do without them having better tags.

sdavis2702 06-14-2008 10:33 AM

Alright thanks a lot I'll check it out now. If we can't get it to work I'll use a basic shop. This hack is worth it!

Dylanblitz 06-14-2008 10:44 AM

Quote:

Originally Posted by sdavis2702 (Post 1549058)
Alright thanks a lot I'll check it out now. If we can't get it to work I'll use a basic shop. This hack is worth it!

You want to give this one a try? I think it'll work a lot better. If it does then I'll change the code.
It's all ready to go with your info. Just upload it to your forums folder.

sdavis2702 06-14-2008 10:56 AM

It's working! Looks like I might have to try and modify some stuff but it's showing :) Thanks a lot bro!!! If I can get this running the way I need it to I'll be sure to shoot you a small donation!

MikeHolohan 06-14-2008 11:03 AM

This is awesome, works really well, thanks, Mike.

Dylanblitz 06-14-2008 11:05 AM

Quote:

Originally Posted by sdavis2702 (Post 1549068)
It's working! Looks like I might have to try and modify some stuff but it's showing :) Thanks a lot bro!!! If I can get this running the way I need it to I'll be sure to shoot you a small donation!

Glad it's working :)
I've got a couple more things to tweak on it then I'll put out a new one.

sdavis2702 06-14-2008 12:22 PM

Hey I downgraded my account to basic so this would work good for me. Now I have a new issue but it shouldn't be much to figure out.

At the top of my shop, there is plain text that says:

"### Items ### -->"

At the bottom, there is plain text that says:

### end of ITEMS ### -->
End Content, Start Footer Include -->

Any clue where I can go to get rid of this? Thanks!

Dylanblitz 06-14-2008 05:00 PM

Quote:

Originally Posted by sdavis2702 (Post 1549119)
Hey I downgraded my account to basic so this would work good for me. Now I have a new issue but it shouldn't be much to figure out.

At the top of my shop, there is plain text that says:

"### Items ### -->"

At the bottom, there is plain text that says:

### end of ITEMS ### -->
End Content, Start Footer Include -->

Any clue where I can go to get rid of this? Thanks!

I'm about to post a new one. For some reason the code that I use to check where to start pulling in the content changes from page to page. I just need to account for them all and switch accordingly. The one I'm going to post now works for your shop.

Calash 06-14-2008 05:32 PM

Quick question.

On my site it is displaying the high level items fine, but when I click on any of them it takes me to the Cafe Press site. Is this how it should work?

Dylanblitz 06-14-2008 07:03 PM

Quote:

Originally Posted by Calash (Post 1549326)
Quick question.

On my site it is displaying the high level items fine, but when I click on any of them it takes me to the Cafe Press site. Is this how it should work?

Correct, that was how it was originally coded. I'm working on making it so that the only time you leave the local page is for adding to the cart and checkout.

iogames 06-14-2008 08:42 PM

Works for 3.6.10 PL1 etc etc???

________________________________

Oh I see that doesn't need to be installed :P [just integrated ;) ]

Hornstar 06-14-2008 10:50 PM

So do we get any commission for anything that we sell coming from our site? is there a page that shows you how much commission you get?

NeitherSparky 06-14-2008 11:07 PM

This is neat, thanks. ;)

Dylanblitz 06-15-2008 02:05 AM

Quote:

Originally Posted by hornstar1337 (Post 1549518)
So do we get any commission for anything that we sell coming from our site? is there a page that shows you how much commission you get?

You get a commission for each item sold on cafe press. I don't know how much, I just coded the interface, don't really use it.

Jeordie015 06-16-2008 04:36 PM

You can choose how much commission you want to make on each individual item when you create them on the site.

iogames 06-16-2008 05:18 PM

Any way to insert the infamous AdSense Code?

R-n-R 06-16-2008 07:08 PM

Quote:

Originally Posted by sdavis2702 (Post 1549068)
It's working! Looks like I might have to try and modify some stuff but it's showing :) Thanks a lot bro!!! If I can get this running the way I need it to I'll be sure to shoot you a small donation!

Hey I just wanted to say, THANKS BRO for serving our Country!

Dylanblitz 06-17-2008 12:55 AM

Quote:

Originally Posted by iogames (Post 1550989)
Any way to insert the infamous AdSense Code?

I'll check it and see

Dylanblitz 06-17-2008 12:56 AM

Quote:

Originally Posted by R-n-R (Post 1551066)
Hey I just wanted to say, THANKS BRO for serving our Country!

I second that :)

sdavis2702 06-17-2008 11:53 AM

No problem at all! I wouldn't trade my job for the world!

DieselMinded 06-17-2008 05:23 PM

installed and uninstalled Didnt work so hot with moded Cafe Press CSS

www.cafepress.com/DieselBombers

Dylanblitz 06-18-2008 01:41 AM

Quote:

Originally Posted by DiesellMinded (Post 1551847)
installed and uninstalled Didnt work so hot with moded Cafe Press CSS

www.cafepress.com/DieselBombers

Yeah, doesn't work so hot OOB. I copy and pasted the css from cafepress though and it worked fine.

Phaedrus 06-18-2008 05:57 AM

Hmmm.... When I click on an item to test out the single item view I get sent directly to cafepress...

Have I done something odd?

Dylanblitz 06-18-2008 06:40 AM

Quote:

Originally Posted by Phaedrus (Post 1552320)
Hmmm.... When I click on an item to test out the single item view I get sent directly to cafepress...

Have I done something odd?

No, right now it sends you to cafe press. I'm reworking it so it'll keep it locally except for adding to the cart and checkout.

dxflw 06-23-2008 07:28 PM

i have uploaded the file in the right pace and edited the navbar template like you and
i get this message when i click to navbar shop

Code:

CafePress.com Product Not Found
We are sorry, but the product you requested could not be found. The page you are looking for may have been renamed, moved, or deleted. You may click on the "reload" button on your browser, or wait and try connecting again later. Please check the URL for spelling, capitalization, and punctuation errors, and click the "reload" button on your browser.

Are you having trouble finding something? Let us personally help you.

Call us. It's toll-free!

US Phone: 1-877-809-1659
Service Hours

Or contact Customer Service via email.

this is the shop.php:
Code:

-------------- SCRIPT BEGINS AFTER THIS LINE -----------------------------------------------*/

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'shop'); // change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(

);

// get special data templates from the datastore
$specialtemplates = array(
   
);

// pre-cache templates used by all actions
$globaltemplates = array(
    'CAFEPRESS',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits = array();
$navbits[$parent] = 'Cafe Press Shop';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');

echo $stylevar[htmldoctype];

echo "<html dir=\"" . $stylevar[textdirection] . "\" lang=\"" . $stylevar[languagecode] . "\">\n";
echo "<head>\n";
echo "<title>" . $vboptions[bbtitle] . " Cafe Press Shop</title>\n";
echo $headinclude;
echo "</head>\n";
echo "<body>\n";
echo $header;

echo $navbar;

echo "<style type=\"text/css\">\n";
echo ".head {font-weight: bold; font-size: 1.5em}\n";
echo "</style>\n";

// SET VARIABLES //

$test = '<!-- SHOP CATEGORIES -->';
$test1 = '<!-- Start Main Content -->';

$stores = 'AbsolutGr_shop'; //EDIT THIS VARIABLE TO BE A LIST OF YOUR STORES
$url = 'http://www.cafepress.com/';
$item = $_GET['item'];

// WRITE CAFEPRESS JAVASCRIPT TO PAGE //
echo '<script language="JavaScript1.1" src="http://www.cafepress.com/commonscripts.js"></script>';

if ($item) { // Script has been called with a specific item, bring up detail page.
        $detail = $url . $item;

        $fp = fsockopen ("www.cafepress.com", 80, $errno, $errstr, 30);
        if (!$fp) {
            echo "$errstr ($errno)<br>\n";
        } else {
            fputs ($fp, "GET /$item HTTP/1.0\r\nHost: www.cafepress.com\r\nUser-Agent: MS Internet Explorer\r\n\r\n");
            while (!feof($fp)) {
                $content .= fgets($fp,1024);
            }
            fclose ($fp);
        }

$start = '<!-- Start Main Content -->';
$end = '<!-- End Content, Start Footer Include -->';

        $null = eregi("$start(.*)$end", $content, $cparray);

        $pattern = "/\/cp/";
        $replacement = "http://www.cafepress.com/cp";
        $itemdetail = preg_replace($pattern, $replacement, $cparray[1]);

        $largeImgPattern = "/<a href=\"\//";
        $largeImgReplacement = "<a href=\"store.php?item=";
        $itemdetail = preg_replace($largeImgPattern, $largeImgReplacement, $itemdetail);

        // The next four lines aren't truly necessary. They 1)make the add to cart button pop up //
        // in its own window with the keep shopping button returning you to your custom store //
        // 2)add a view cart button (vey handy) and 3) change the link to the CP legal questions page //


        $itemdetail = preg_replace("/src=\"\/content/", "src=\"http://www.cafepress.com/content", $itemdetail);

        $itemdetail = preg_replace("/<form method=\"post\" name=\"prod_detail_form\" action=\"http:\/\/www.cafepress.com\/cp\/addtocart.aspx\">/i", "<form method=\"post\" name=cart action=\"http://www.cafepress.com/cp/addtocart.aspx?keepshopping=javascript:self.close()\" target=\"cartWin\">", $itemdetail);
        $itemdetail = preg_replace("/<input type=\"submit\"/", "<input type=submit onClick=\"cartWin = window.open ('','cartWin','toolbar=yes,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=500'); cartWin.focus(); return true;\"", $itemdetail); 
        $itemdetail = preg_replace("/alt=\"Add to Cart\">/", "alt\"Add to Cart\" >&nbsp;&nbsp;&nbsp;<input type=image src=\"images/misc/btn_viewcart.gif\" onClick=\"cartWin = window.open ('http://www.cafepress.com/cp/viewcart.aspx','cartWin','toolbar=yes,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=500'); cartWin.focus(); return true;\">", $itemdetail); 
        $itemdetail = preg_replace("/<a href=\"http:\/\/www.cafepress.comhttp:\/\/www.cafepress.com/" , "<a href=\"http://www.cafepress.com", $itemdetail);


        echo "<script>";
        echo "function e (z, h, w, b, g) {";
        echo "document.write('<div style=\"width:'+w+';height:'+h+';background:white url(http://zoom.cafepress.com/'+(z%10)+'/'+z+'_zoom.jpg) no-repeat center center;\"><img border=\"'+b+'\" class=\"imageborder\" src=\"http://www.cafepress.com/cp/img/'+(g?'zoom':'spacer')+'.gif\" width=\"'+w+'\" height=\"'+h+'\"></div>')";
        echo "}";
        echo "</script>";

        echo $itemdetail;
}
else { // No item was requested when script was called, show items from all stores in the $stores variable.
        $allitems = $url . $stores;

        // connect to CP
        $reqheader = "GET /$stores HTTP/1.0\r\nHost: www.cafepress.com\r\nUser-Agent: MS Internet Explorer\r\n\r\n";
        $socket = @fsockopen("www.cafepress.com", 80, &$errno, &$errstr);
        if ($socket)
        {
                fputs($socket, $reqheader);
                while (!feof($socket))
                {
                        $content .= fgets($socket, 4096);
                }
        }
        fclose($socket);

if (eregi($test, $content))
{

$start = '<!-- SHOP CATEGORIES -->';
$end = '<!-- End Content, Start Footer Include -->';

        $null = eregi("$start(.*)$end", $content, $cparray);

        $pattern = "/<a href=\"\//";
        $replacement = "<a href=\"http://www.cafepress.com/";
        $storeitems = preg_replace($pattern, $replacement, $cparray[1]);
        $storeitems = preg_replace("/\/cp\//", "http://www.cafepress.com/cp/", $storeitems);
        $storeitems = preg_replace("/src=\"\/content/", "src=\"http://www.cafepress.com/content", $storeitems);

echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td VALIGN=\"TOP\">\n";

echo $storeitems;

echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";

} elseif (eregi($test1, $content)) {

$start = '<!-- Start Main Content -->';
$end = '<!-- End Content, Start Footer Include -->';

        $null = eregi("$start(.*)$end", $content, $cparray);

        $pattern = "/<a href=\"\//";
        $replacement = "<a href=\"http://www.cafepress.com/";
        $storeitems = preg_replace($pattern, $replacement, $cparray[1]);
        $storeitems = preg_replace("/\/cp\//", "http://www.cafepress.com/cp/", $storeitems);
        $storeitems = preg_replace("/src=\"\/content/", "src=\"http://www.cafepress.com/content", $storeitems);

echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td VALIGN=\"TOP\">\n";

echo "        <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "        <tr>\n";
echo "        <td VALIGN=\"TOP\">\n";

echo "                <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "                <tr>\n";
echo "                <td VALIGN=\"TOP\">\n";

echo $storeitems;

} else {
$start = '<!-- basic shop coupon goes here \(max width 600px\)-->';
$end = '<!-- End Body Table -->';

        $null = eregi("$start(.*)$end", $content, $cparray);

        $pattern = "/<a href=\"\//";
        $replacement = "<a href=\"http://www.cafepress.com/";
        $storeitems = preg_replace($pattern, $replacement, $cparray[1]);
        $storeitems = preg_replace("/\/cp\//", "http://www.cafepress.com/cp/", $storeitems);
        $storeitems = preg_replace("/src=\"\/content/", "src=\"http://www.cafepress.com/content", $storeitems);

echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td VALIGN=\"TOP\">\n";

echo "        <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "        <tr>\n";
echo "        <td VALIGN=\"TOP\">\n";

echo "                <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "                <tr>\n";
echo "                <td VALIGN=\"TOP\">\n";

echo $storeitems;

}





}




echo $footer;
echo "</body>\n";
echo "</html>";
?>


SuperGLS 06-23-2008 08:12 PM

Great! I'm glad to have this finally working again. Wonderful job.

One question, if you have an item in your shop that is available in more colors they put an image beneath the product that says "More Colors Available." For some reason those images aren't being shown when viewing the shop.php, but once I'm at the Cafepress site they work fine (obviously). Any idea on a way to make this work?

http://www.elantraxd.com/forums/shop.php

Dylanblitz 06-23-2008 10:26 PM

The part in shop.php where you set the $stores variable is wrong. If you go to your shop it's pretty much

http://www.cafepress.com/your_store_name

That is what you need to put there. I went to yours

http://www.cafepress.com/AbsolutGr_shop

and got the same error.

Quote:

Originally Posted by dxflw (Post 1557122)
i have uploaded the file in the right pace and edited the navbar template like you and
i get this message when i click to navbar shop

Code:

CafePress.com Product Not Found
We are sorry, but the product you requested could not be found. The page you are looking for may have been renamed, moved, or deleted. You may click on the "reload" button on your browser, or wait and try connecting again later. Please check the URL for spelling, capitalization, and punctuation errors, and click the "reload" button on your browser.

Are you having trouble finding something? Let us personally help you.

Call us. It's toll-free!

US Phone: 1-877-809-1659
Service Hours

Or contact Customer Service via email.

this is the shop.php:
Code:

-------------- SCRIPT BEGINS AFTER THIS LINE -----------------------------------------------*/

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'shop'); // change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(

);

// get special data templates from the datastore
$specialtemplates = array(
   
);

// pre-cache templates used by all actions
$globaltemplates = array(
    'CAFEPRESS',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits = array();
$navbits[$parent] = 'Cafe Press Shop';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');

echo $stylevar[htmldoctype];

echo "<html dir=\"" . $stylevar[textdirection] . "\" lang=\"" . $stylevar[languagecode] . "\">\n";
echo "<head>\n";
echo "<title>" . $vboptions[bbtitle] . " Cafe Press Shop</title>\n";
echo $headinclude;
echo "</head>\n";
echo "<body>\n";
echo $header;

echo $navbar;

echo "<style type=\"text/css\">\n";
echo ".head {font-weight: bold; font-size: 1.5em}\n";
echo "</style>\n";

// SET VARIABLES //

$test = '<!-- SHOP CATEGORIES -->';
$test1 = '<!-- Start Main Content -->';

$stores = 'AbsolutGr_shop'; //EDIT THIS VARIABLE TO BE A LIST OF YOUR STORES
$url = 'http://www.cafepress.com/';
$item = $_GET['item'];

// WRITE CAFEPRESS JAVASCRIPT TO PAGE //
echo '<script language="JavaScript1.1" src="http://www.cafepress.com/commonscripts.js"></script>';

if ($item) { // Script has been called with a specific item, bring up detail page.
        $detail = $url . $item;

        $fp = fsockopen ("www.cafepress.com", 80, $errno, $errstr, 30);
        if (!$fp) {
            echo "$errstr ($errno)<br>\n";
        } else {
            fputs ($fp, "GET /$item HTTP/1.0\r\nHost: www.cafepress.com\r\nUser-Agent: MS Internet Explorer\r\n\r\n");
            while (!feof($fp)) {
                $content .= fgets($fp,1024);
            }
            fclose ($fp);
        }

$start = '<!-- Start Main Content -->';
$end = '<!-- End Content, Start Footer Include -->';

        $null = eregi("$start(.*)$end", $content, $cparray);

        $pattern = "/\/cp/";
        $replacement = "http://www.cafepress.com/cp";
        $itemdetail = preg_replace($pattern, $replacement, $cparray[1]);

        $largeImgPattern = "/<a href=\"\//";
        $largeImgReplacement = "<a href=\"store.php?item=";
        $itemdetail = preg_replace($largeImgPattern, $largeImgReplacement, $itemdetail);

        // The next four lines aren't truly necessary. They 1)make the add to cart button pop up //
        // in its own window with the keep shopping button returning you to your custom store //
        // 2)add a view cart button (vey handy) and 3) change the link to the CP legal questions page //


        $itemdetail = preg_replace("/src=\"\/content/", "src=\"http://www.cafepress.com/content", $itemdetail);

        $itemdetail = preg_replace("/<form method=\"post\" name=\"prod_detail_form\" action=\"http:\/\/www.cafepress.com\/cp\/addtocart.aspx\">/i", "<form method=\"post\" name=cart action=\"http://www.cafepress.com/cp/addtocart.aspx?keepshopping=javascript:self.close()\" target=\"cartWin\">", $itemdetail);
        $itemdetail = preg_replace("/<input type=\"submit\"/", "<input type=submit onClick=\"cartWin = window.open ('','cartWin','toolbar=yes,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=500'); cartWin.focus(); return true;\"", $itemdetail); 
        $itemdetail = preg_replace("/alt=\"Add to Cart\">/", "alt\"Add to Cart\" >&nbsp;&nbsp;&nbsp;<input type=image src=\"images/misc/btn_viewcart.gif\" onClick=\"cartWin = window.open ('http://www.cafepress.com/cp/viewcart.aspx','cartWin','toolbar=yes,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=500'); cartWin.focus(); return true;\">", $itemdetail); 
        $itemdetail = preg_replace("/<a href=\"http:\/\/www.cafepress.comhttp:\/\/www.cafepress.com/" , "<a href=\"http://www.cafepress.com", $itemdetail);


        echo "<script>";
        echo "function e (z, h, w, b, g) {";
        echo "document.write('<div style=\"width:'+w+';height:'+h+';background:white url(http://zoom.cafepress.com/'+(z%10)+'/'+z+'_zoom.jpg) no-repeat center center;\"><img border=\"'+b+'\" class=\"imageborder\" src=\"http://www.cafepress.com/cp/img/'+(g?'zoom':'spacer')+'.gif\" width=\"'+w+'\" height=\"'+h+'\"></div>')";
        echo "}";
        echo "</script>";

        echo $itemdetail;
}
else { // No item was requested when script was called, show items from all stores in the $stores variable.
        $allitems = $url . $stores;

        // connect to CP
        $reqheader = "GET /$stores HTTP/1.0\r\nHost: www.cafepress.com\r\nUser-Agent: MS Internet Explorer\r\n\r\n";
        $socket = @fsockopen("www.cafepress.com", 80, &$errno, &$errstr);
        if ($socket)
        {
                fputs($socket, $reqheader);
                while (!feof($socket))
                {
                        $content .= fgets($socket, 4096);
                }
        }
        fclose($socket);

if (eregi($test, $content))
{

$start = '<!-- SHOP CATEGORIES -->';
$end = '<!-- End Content, Start Footer Include -->';

        $null = eregi("$start(.*)$end", $content, $cparray);

        $pattern = "/<a href=\"\//";
        $replacement = "<a href=\"http://www.cafepress.com/";
        $storeitems = preg_replace($pattern, $replacement, $cparray[1]);
        $storeitems = preg_replace("/\/cp\//", "http://www.cafepress.com/cp/", $storeitems);
        $storeitems = preg_replace("/src=\"\/content/", "src=\"http://www.cafepress.com/content", $storeitems);

echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td VALIGN=\"TOP\">\n";

echo $storeitems;

echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";

} elseif (eregi($test1, $content)) {

$start = '<!-- Start Main Content -->';
$end = '<!-- End Content, Start Footer Include -->';

        $null = eregi("$start(.*)$end", $content, $cparray);

        $pattern = "/<a href=\"\//";
        $replacement = "<a href=\"http://www.cafepress.com/";
        $storeitems = preg_replace($pattern, $replacement, $cparray[1]);
        $storeitems = preg_replace("/\/cp\//", "http://www.cafepress.com/cp/", $storeitems);
        $storeitems = preg_replace("/src=\"\/content/", "src=\"http://www.cafepress.com/content", $storeitems);

echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td VALIGN=\"TOP\">\n";

echo "        <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "        <tr>\n";
echo "        <td VALIGN=\"TOP\">\n";

echo "                <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "                <tr>\n";
echo "                <td VALIGN=\"TOP\">\n";

echo $storeitems;

} else {
$start = '<!-- basic shop coupon goes here \(max width 600px\)-->';
$end = '<!-- End Body Table -->';

        $null = eregi("$start(.*)$end", $content, $cparray);

        $pattern = "/<a href=\"\//";
        $replacement = "<a href=\"http://www.cafepress.com/";
        $storeitems = preg_replace($pattern, $replacement, $cparray[1]);
        $storeitems = preg_replace("/\/cp\//", "http://www.cafepress.com/cp/", $storeitems);
        $storeitems = preg_replace("/src=\"\/content/", "src=\"http://www.cafepress.com/content", $storeitems);

echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td VALIGN=\"TOP\">\n";

echo "        <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "        <tr>\n";
echo "        <td VALIGN=\"TOP\">\n";

echo "                <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "                <tr>\n";
echo "                <td VALIGN=\"TOP\">\n";

echo $storeitems;

}





}




echo $footer;
echo "</body>\n";
echo "</html>";
?>



Dylanblitz 06-23-2008 10:26 PM

Quote:

Originally Posted by SuperGLS (Post 1557169)
Great! I'm glad to have this finally working again. Wonderful job.

One question, if you have an item in your shop that is available in more colors they put an image beneath the product that says "More Colors Available." For some reason those images aren't being shown when viewing the shop.php, but once I'm at the Cafepress site they work fine (obviously). Any idea on a way to make this work?

http://www.elantraxd.com/forums/shop.php

Yeah, I haven't been able to get the script for the image switch on the color options to work. It's something I'm working on though.

SuperGLS 06-24-2008 11:19 PM

Good stuff.

Digital Jedi 06-25-2008 03:31 AM

I notice the more colors image is trying to load directly from my site, rather then CafePress: http://www.cafepress.com/content/mar...morecolors.gif Any way to fix that?


All times are GMT. The time now is 05:50 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01877 seconds
  • Memory Usage 1,934KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (16)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete