andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


A little tweak to add a nice feature for premium shops.

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> CafePress Box
View previous topic :: View next topic  
Author Message
jmfpub
Newbie


Joined: 05 Nov 2003
Posts: 3
Location: Illinois

PostPosted: Wed Nov 05, 2003 9:42 pm    Post subject: A little tweak to add a nice feature for premium shops. Reply with quote

Hello. I decided tonight to try your script on my site. It worked great except that any products I wanted to let it access had to be in the main portion of my premium site (not in any category). I use one premium store for several Web sites and I only want relevant products displayed on each site. So I hacked the code just a bit and I thought I'd share what I did with everyone else...

In the PHP that calls the class, I added a second argument to setStore like so...

$cp->setStore('storeID' , '1234567');

The first argument is obviously the store ID. The second is the category from which I want the products pulled.

I then added a few things here and there to the class.php file...

class cafePressBox
{
var $category; //I added this
var $storeID;
...

AND

function cafePressBox($store_id = false , $category = false)
{
$this->setStore($id , $category); //Added the second argument here.

AND

function setStore($id , $category)
{
$this->category = $category; //Added this line
$this->storeID = $id;

AND FINALLY...

I changed this...

$reqheader = "GET /cp/store.aspx?s={$this->storeID} HTTP/1.0\r\nHost: www.cafeshops.com\r\nUser-Agent: RandomProduct\r\n\r\n";

to this..

$reqheader = "GET /cp/store.aspx?s={$this->storeID}.{$this->category} HTTP/1.0\r\nHost: www.cafeshops.com\r\nUser-Agent: RandomProduct\r\n\r\n";

Notice that I just added .{this->category} after {$this->storeID}

I'm pretty sure there's also a way to get it to crawl through categories and subcategories to look for pattern matches (and thereby find products), but I'm not that ambitious tonight.

Anyway, thanks for the great script. The twenty minutes it took me to hack your script sure beat having to do this from scratch.

Regards,

Ed

By the way, if you want to see this (sort of) in action, it's working on my (not yet live, but certainly visible) Web site at www.jmfpub.com. It's actually grabbing the content from my store that I designed for another site right now, but it will do its intended duty soon.
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Thu Nov 06, 2003 3:53 am    Post subject: Reply with quote

Hi Ed,

Welcome to the board! And what a treat you have for your first posting! Very Happy A great update, thanks! It's nice to know that with marginal updating the script can work for premium stores, too. Maybe I'll have to investigate getting a premium store and testing out all the features that it gives you.

I'll be sure to apply your patch when I next update the script.

Thanks also for the link! Smile

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
jmfpub
Newbie


Joined: 05 Nov 2003
Posts: 3
Location: Illinois

PostPosted: Thu Nov 06, 2003 7:49 am    Post subject: Reply with quote

Hi Andy,

Just be careful as the updates I posted will break it for a basic shop. I hard-coded the period between the shopID and the category. You'll want to check for the existence of a category arguement and only insert the period if one exists. I know it's obvious, but it's the obvious little things that give me the most headaches.

Regards,

Ed
Back to top
View user's profile Send private message Visit poster's website
shiola
Newbie


Joined: 08 Nov 2003
Posts: 3

PostPosted: Wed Nov 19, 2003 11:47 pm    Post subject: Reply with quote

amnuts - some great scripts here. I'd be very interested if you could update this script for Premium stores - especially if it could display items in subcategories as jmfpub mentions below.
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Thu Nov 20, 2003 3:55 am    Post subject: Reply with quote

Hey Shiola,

Welcome to the board! I'll try to get around to updating the script as soon as I can.... Hopefully with an additional function or two in there.

Incidently; I came across your website a week or so ago and loved the style - very funky!

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Sat Nov 22, 2003 12:51 pm    Post subject: Reply with quote

Hi,

New version available - see other thread for details!

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
adjamlotfi
Newbie


Joined: 23 Feb 2004
Posts: 8

PostPosted: Mon Feb 23, 2004 2:37 pm    Post subject: Re: A little tweak to add a nice feature for premium shops. Reply with quote

From: adjamlotfi
To: jmfpub
Posted: Mon Feb 23, 2004 2:14 pm
Subject: can you please indicate the meaning of your message
Hello;

I came to this site by chance and find it very interesting.
One of an external developper propose to my compagny something similar to cafepress box but we have too much options to ask such displaying products by categories and from each category we would like to propose one or more items for promotional purposes.
I red your comments but I don't realy understand what you did.
I went to the linked site and I didn't understand either.

Please explain to me in simple words what you added to the original script
(my mother tong is french / suiss) or translate with bublefish / altavista.com

thanks
my email: adjamlotfi@hotmail.com
------------------------------------
jmfpub wrote:
Hello. I decided tonight to try your script on my site. It worked great except that any products I wanted to let it access had to be in the main portion of my premium site (not in any category). I use one premium store for several Web sites and I only want relevant products displayed on each site. So I hacked the code just a bit and I thought I'd share what I did with everyone else...

In the PHP that calls the class, I added a second argument to setStore like so...

$cp->setStore('storeID' , '1234567');

The first argument is obviously the store ID. The second is the category from which I want the products pulled.

I then added a few things here and there to the class.php file...

class cafePressBox
{
var $category; //I added this
var $storeID;
...

AND

function cafePressBox($store_id = false , $category = false)
{
$this->setStore($id , $category); //Added the second argument here.

AND

function setStore($id , $category)
{
$this->category = $category; //Added this line
$this->storeID = $id;

AND FINALLY...

I changed this...

$reqheader = "GET /cp/store.aspx?s={$this->storeID} HTTP/1.0\r\nHost: www.cafeshops.com\r\nUser-Agent: RandomProduct\r\n\r\n";

to this..

$reqheader = "GET /cp/store.aspx?s={$this->storeID}.{$this->category} HTTP/1.0\r\nHost: www.cafeshops.com\r\nUser-Agent: RandomProduct\r\n\r\n";

Notice that I just added .{this->category} after {$this->storeID}

I'm pretty sure there's also a way to get it to crawl through categories and subcategories to look for pattern matches (and thereby find products), but I'm not that ambitious tonight.

Anyway, thanks for the great script. The twenty minutes it took me to hack your script sure beat having to do this from scratch.

Regards,

Ed

By the way, if you want to see this (sort of) in action, it's working on my (not yet live, but certainly visible) Web site at www.jmfpub.com. It's actually grabbing the content from my store that I designed for another site right now, but it will do its intended duty soon.
Back to top
View user's profile Send private message
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Mon Feb 23, 2004 3:28 pm    Post subject: Re: A little tweak to add a nice feature for premium shops. Reply with quote

Hi adjamlotfi, and welcome to the board!

adjamlotfi wrote:
I came to this site by chance and find it very interesting.
One of an external developper propose to my compagny something similar to cafepress box but we have too much options to ask such displaying products by categories and from each category we would like to propose one or more items for promotional purposes.
I red your comments but I don't realy understand what you did.
I went to the linked site and I didn't understand either.

Please explain to me in simple words what you added to the original script
(my mother tong is french / suiss) or translate with bublefish / altavista.com


The minimum change that was significant to using the script for categories was this line:

$reqheader = "GET /cp/store.aspx?s={$this->storeID}.{$this->category} HTTP/1.0\r\nHost: www.cafeshops.com\r\nUser-Agent: RandomProduct\r\n\r\n";

I've put in bold the part that jmfpub suggested. That, when it comes down to it, is all that needed to really change. The rest of the changes were there to help selecting the category easier.

All of the changes are in the current version of the cafepress box class.

What it sounds like you want to know is how to use the class with a certain category, and how you might be able to display specific products for that category.

So to include the class for a category in a store, I would do something like this:

PHP:
<?php

    
include 'class.cafepressbox.php';
    
$cp = new cafePressBox;
    
$cp->setCacheDir('./cache');
    
$cp->setCacheTime(86400);
    
$cp->setCacheImages(true);
    
$cp->setResizeCachedImages(75);

    
$cp->setStore('store-id''category-id');
    
$cp->displayItem(true);

?>


You would replace 'store-id' and 'ctaegory-id' with your own store and category values. That code will display a random item from the category.

Now, if I wanted to display a specific item, I would change the 'setStore' line to pass the item id. So my code would end up looking like:

PHP:
<?php

    
include 'class.cafepressbox.php';
    
$cp = new cafePressBox;
    
$cp->setCacheDir('./cache');
    
$cp->setCacheTime(86400);
    
$cp->setCacheImages(true);
    
$cp->setResizeCachedImages(75);

    
$cp->setStore('store-id''category-id');
    
$cp->displayItem(true'item-id');

?>


and you would change 'item-id' to be whatever your product id is.

Now we know how to display an item from a category, we can set it up to display a random set of items we want to promote. Say we had 3 items we wanted to display. The product id's are '12345', '67890' and '54321'. The store id is 'test', and the category id is '987654321'. So we might do something like this:

PHP:
<?php

    
include 'class.cafepressbox.php';
    
$cp = new cafePressBox;
    
$cp->setCacheDir('./cache');
    
$cp->setCacheTime(86400);
    
$cp->setCacheImages(true);
    
$cp->setResizeCachedImages(75);
    
    
$show_products('12345''67890''54321');

    
$cp->setStore('test''987654321');
    
$cp->displayItem(true$show_products[rand(0count($show_products) - 1)]);

?>


Make sense?

If you have any problems with this, just post up and I'll try to explain further.

Andy

(if you use this for a company and not a personal site, then donations are appreciated! Smile )
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
adjamlotfi
Newbie


Joined: 23 Feb 2004
Posts: 8

PostPosted: Tue Feb 24, 2004 3:00 pm    Post subject: Re: A little tweak to add a nice feature for premium shops. Reply with quote

Hi there;

I had a look to your sites http://php.amnuts.com/ and http://www.cafeshops.com/ and I Like them.
They show a very big professional & serious work.

I would like to know :

First Option:
Is it possible to extract / grab, for the test page, the text as in the Apparel area of the page :
http://www.cafeshops.com/eat_rice (images with prices & descriptions)

or

the following section: Flying cat:..... Women's T-shirts of the page :
http://www.cafeshops.com/flyingcat/237927

with a new extra text + link "for more details click here" right every price ( the Item description is no longer with a link) ?

Second option:
Is it possible to extract / grab, for the test page, the descriptions & prices of all Items, put them one by Line / row ?

This will allow to have multi templates, layouts & ways to display a front page accessing the Cafepress site.

Thanks in advance.

Adjamlotfi
Back to top
View user's profile Send private message
Stripeman
Newbie


Joined: 09 Nov 2005
Posts: 2

PostPosted: Wed Nov 09, 2005 4:52 pm    Post subject: um.... i tried this but i get no results.. please help! Reply with quote

I do have aprem shop...
I tried this:

include 'cafepressbox.php';

$cp = new cafePressBox;
$cp->setCacheDir('./cache');
$cp->setCacheTime(86400);
$cp->setCacheImages(true);
$cp->setResizeCachedImages(75);
$cp->setStore('brotherstrust', '306384');
$cp->displayItem(true, '21507096');
$cp->setTemplate('<div style="width:250px;">[TXT]</div><br>[IMG]');


and this:

include 'cafepressbox.php';
$cp = new cafePressBox;
$cp->setCacheDir('./cache');
$cp->setCacheTime(86400);
$cp->setCacheImages(true);
$cp->setResizeCachedImages(75);

$cp->setStore('brotherstrust', '306384');
$cp->displayItem(true);

says that no products exist Sad

Please help.. thanks so much for your help and this awsome script!!
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Wed Nov 23, 2005 9:02 am    Post subject: Re: um.... i tried this but i get no results.. please help! Reply with quote

Stripeman wrote:
I do have aprem shop...

...

says that no products exist Sad

Please help.. thanks so much for your help and this awsome script!!


I just tried it out and the response from the server says that the items have temporarily moved to cafepress.com, rather than the cafeshops.com domain used in the class. Simply fix; just replace all 'cafeshops.com' with 'cafepress.com' in the class, remove any cache files that might exist and try again.

Regards,

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Stripeman
Newbie


Joined: 09 Nov 2005
Posts: 2

PostPosted: Thu Nov 24, 2005 10:30 am    Post subject: Reply with quote

wow!! Cool! It works!!! great class!! and good job!! just awsome! Thanks so much!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> CafePress Box All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group