Jump to content

Help with a simple cart please?


wmguk

Recommended Posts

hey guys,

 

I'm creating a VERY basic cart from scratch, basically as a person comes to the page, php generates a unique code and sets a session variable for that visitor

 

so, I've got the unique code creation ready

<?PHP
// random key generator 
function getrand() { 
// random key paramters 
$keyset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 
$length = 4; // first 14 chars of transaction_id are date, last 4 random 

// Random Key Generator 
$randkey = ""; 
$max = strlen($keyset)-1; 

for ($i=0; $i<$length; $i++) { 
$randkey .= substr($keyset, rand(0,$max), 1); 
} 
return $randkey; 
} 
// end function getrand() 

$date = date("YmdHis"); //puts in format YYYYMMDDhhmmss 
$rand_str = getrand(); 
$transactionID = $date . $rand_str;
?>

 

now i need to enter this code as orderid in a session variable.

 

its for a photography site, and basically, there could be up to 500 pics per album, each picture is available in up to 6 sizes (these sizes are pulled from a MySQL database) and so i could order image 1, 5x6, 6x8 etc etc, I would need the image name, then each size required and the cost of each item placed in to a basket...

 

I dont know if ive tried to explain this very well, but say the customer orders each picture in each size, could be 3000 items in a basket. and this can be passed about... however also I would like a drop down to select quantity for each picture, so someone ordering 10 of each picture in each size, makes 30,000 images on order (wont EVER happen, but you never know lol)

 

also each order needs to visable on a screen for me to view... so im guessing the whole thing will be in MySQL database...

 

can anyone give me any pointers?

 

Link to comment
Share on other sites

A couple of things spring to mind.

 

Are you going to create the image size options when you upload the original image (hungry on disk space) or do you intend to resize dynamically from the original when ordered (hungry on server resources). As always, it's a tradeoff.

 

If you offer 5x6 and 6x8 there is going to some distortion of the image, as the aspect ratios are different unless there is some cropping involved (therefore the crop areas will need to be defined for various sizes)

Link to comment
Share on other sites

A couple of things spring to mind.

 

Are you going to create the image size options when you upload the original image (hungry on disk space) or do you intend to resize dynamically from the original when ordered (hungry on server resources). As always, it's a tradeoff.

 

If you offer 5x6 and 6x8 there is going to some distortion of the image, as the aspect ratios are different unless there is some cropping involved (therefore the crop areas will need to be defined for various sizes)

 

sorry the sizes I listed up were just a idea lol..

the images are uploaded then a script runs and counts the images and displays them as thumbnails, then they are viewable on the site.

 

basically all im trying to work out is how to retain info of images ordered. and process that info...

 

it sounds so easy, bit it cant be...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.