Gossamer Forum
Home : Products : DBMan : Customization :

Shopping cart (a reply to JPDeni)

Quote Reply
Shopping cart (a reply to JPDeni)
JPD,
I started a new thread,to avoid confusion.

<<<I have this worked out (I think) in my head, but I need to be sure of what you need.
This is what I envision:
When a user (customer) does a search, the results are displayed in a form, with a text box to fill in the quantity for each item desired. He/she clicks a button and the key values for the items, along with the quantities, are saved to a file which is associated with the user.>>>

Thanks very much for your offer of help on this. The following configuration would suit me best - it's not exactly how you envisaged it:

My merchandise would be displayed in a table, one record per row. Each row of the table displays eight fields:
ItemID, author, publisher, year, description, condition, price, and a final field with a "buy me" clickable link.

Any shopper (no need for him/her to log in) who wants to, can search the database, and bring up a short-list of items in a search-results table. Alongside every record in the database is a clickable "buy me" (gif or words). When a by-me link is clicked, it appends a copy of that particular merchandise record to a separate, temporary, delimited data file (the cart). Each time the user clicks on another 'buy me' button, another merchandise record is appended to the cart file. at any time, the shopper can click on a "view cart" button at the top or bottom of the mercandise-viewing page. On clicking this, he is taken to a table displaying the contents of the cart so far;- i.e., the list of the proposed purchases. Under the price column of this cart table, there's a separate textbox, containing the total of all the prices of the proposed purchases in the cart. The rows in the cart table should ideally have "delete me" buttons beside each item, in case the shopper has accidentally added an incorrect item, or too many instances of an item. The cart table should not be otherwise editable by the shopper.

When the customer is ready to place the order, he fills in his e-mail address (for identification purposes)in a text box just below the cart list and clicks a button which sends data on the cart page to me, by sendmail.

On doing that, he is taken to another URL: my "credit card details entry form" located on a secure server. (He fills that form and submits it, and that's the end of the purchase-procedure.)

I hope that explains it clearly enough - but if you have any questions, please fire away. I'll be listening.

Thanks again, Carol, for any input you can offer on this one. It may call for an extra
pot of Earl Grey.

Alan



[This message has been edited by Alan33 (edited May 06, 2000).]

[This message has been edited by Alan33 (edited May 06, 2000).]
Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
I think this would be fine.

I would suggest that you have the "Buy Me" link on the left side of the page. That way, if someone's resolution is lower than you had expected, the link won't scroll off the right side of the page.

First you need to set up your database with the fields.

Then you need to get the display the way you want it.

I would do it like this:

In sub html_view_success, change

Code:
# Go through each hit and convert the array to hash and send to
# html_record for printing.
for (0 .. $numhits - 1) {
print "<P>";
&html_record (&array_to_hash($_, @hits));
}

to

Code:
# Go through each hit and convert the array to hash and send to
# html_record for printing.
print qq|
<table>
<tr><td>&nbsp;</td>
<td>ItemID</td>
<td>Author</td>
<td>Publisher</td>
<td>Year</td>
<td>Description</td>
<td>Condition</td>
<td>Price</td></tr>
|;
for (0 .. $numhits - 1) {
print "<tr>";
&html_record (&array_to_hash($_, @hits));
print "</tr>";
}
print "</table>";

In sub html_record, use

Code:
my (%rec) = @_;

print qq|
<td>Buy Me!</td>
<td>$rec{'ItemID'}</td>
<td>$rec{'author'}</td>
<td>$rec{'publisher'}</td>
<td>$rec{'year'}</td>
<td>$rec{'description'}</td>
<td>$rec{'condition'}</td>
<td>$rec{'price'}</td>
|;

You may need to change the fieldnames above to match the names as they are in your .cfg file. The names must match *exactly*, including case.

For the moment, there's no link for "Buy Me," but we'll get to that in a bit.

Let me know if you have any problems with setting this up.


------------------
JPD






Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
Carol,
Thanks a million for this assistance. This is an important project for me, and I am excited at the prospect of being able to complete it, thanks to your help.

If I don't respond immediately, it's not because I've been stumped or have lost interest; it's just that I am under pressure to finish another, more pressing Perl project first! It may be a day or three before I can continue with the cart.

Alan
Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
No problem. Whenever you're ready to go to the next step, just respond to this message and it'll bring it to the top where I can see it. Smile


------------------
JPD






Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
JPD,
OK - I'm back onto this project, and will be working on it intermittently, whenever I get the chance. Could you kindly cast your eye back over the above thread so far, just to refresh your memory? Ok, I expect you don't need me to suggest that.<G>

Firstly, a question about the fields. Do I need a field for the "BuyMe" link/button? or did you have a way of doing it without using a field?

As I suggested earlier, I was thinking of having a field to contain a search character so I can set the first 250approx records as 'A', then the next 250approx records as 'B' and the next 250approx as 'C' and so on. Then the user can click something to display the first 250 records - then click something else to display the next 250 records. Okay, I know the script has a built-in feature to let you specify the number of records to display per page. However, I need to make sure that certain pairs of records are kept together for viewing - because some records will contain record-group-titles as opposed to records. It would be bad if a title ended up at the bottom row of one of the 250-approx-long recordsets.

Does my search-character field sound a sensible solution?

Also, do I need to have a field to contain a unique record ID? I'm wondering if this is necessary. All my records will be pre-sorted according to my needs while they are in Excel, before I save the data to tab-delimited format.

Thanks...
Alan
Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
I will have to do a little searching through my brain archives to remember what I had in mind. Smile I think I have it.

Quote:
Do I need a field for the "BuyMe" link/button? or did you have a way of doing it without using a field?

No. No field needed. This is a "command" link, sorta like "List All."

Quote:
It would be bad if a title ended up at the bottom row of one of the 250-approx-long recordsets.

Can you give me a concrete example of what you mean? I don't get a picture of this. But I may be able to suggest a more efficient way of doing things.

Quote:
Also, do I need to have a field to contain a unique record ID?

Yes. Absolutely. The key value for the record will be vital to what I have in mind.




------------------
JPD


Oh. I thought of something else when I was looking over what I wrote previously.

You might want to add another table cell to your rows at the right side, with a second "Buy Me!" link. That way, the user can buy the item no matter which way he has scrolled the page, without having to scroll back.





[This message has been edited by JPDeni (edited May 05, 2000).]
Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
JPD,
<<And still I don't see how it would work. It would be terribly complicated to make sure that the "country" record was on the same page as the ones to which it applies.>>

Did you understand my proposed easy method of dealing with this? (3rd paragraph of my 3rd posting in this thread.) Provided the records stay in the same order as they were before the database is exported from Excel, then my method should work, don't you think?

BTW, it just occurred to me that I could have a 'country' field for each record which is not visible. That way people could also search for items from a specific country.

Alan



[This message has been edited by Alan33 (edited May 06, 2000).]

[This message has been edited by Alan33 (edited May 06, 2000).]

[This message has been edited by Alan33 (edited May 06, 2000).]
Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
JPD
Before I go any further, I'll just mention that I'm initially going to be using this shopping cart to sell old collectable banknotes - not books as I originally said.

Re.Concrete example you requested...

Till now, I've been displaying my merchandise in html tables. The 4th field in each record is a longish one, called 'description'
(about 32 characters). This holds a description of the item, but some records are empty except for that field when I use that field to hold a title for the group of records immediately below. I'll illustrate this with an example using records with only 4 fields, the 3rd field being 'description' and the 1st field being hidden recordID field:

1| |USA| |
2|s44|An old 1864 CSA $20 bill|$44.00|
3|s88|1914 Silver certificate|$23.00|
4|p99|$5 bill with printing error|$50.00|
5| |Uzbekestan| |
6|s3|Old hand-printed banknote of 1918|$26|
7|p98|First banknote of the new republic|$5.00|

Unfortunately, I have to do it that way. The other way would be to repeat the country name in each record, as follows:

2|USA|s44|An old 1864 CSA $20 bill|$44.00|
3|USA|s88|1914 Silver certificate|$23.00|
4|USA|p99|$5 bill with printing error|$50.00|
5|Uzbekestan| r5|Old hand-printed banknote of 1918| |
6|Uzbekestan|s3|Old hand-printed banknote of 1918|$26|
7|Uzbekestan|p98|First banknote of the new republic|$5.00|

but if I did that, I wouldn't be able to fit each record on one line, and it'd look clumsy too.

I just thought of something... Remember we discussed having a BuyMe link to the left of each merchandise item? Well it just occurred to me that I somehow have to avoid having a BuyMe link for records that only contain titles... Could we insert some code that makes the BuyMe link only appear if the second field in that record contains data?

I had assumed that the first field in each record would be used for the BuyMe link, but it sounds like you've thought of another way of doing it...
Alan


[This message has been edited by Alan33 (edited May 06, 2000).]
Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
Well, yes. The first field is used for the "Buy Me" link -- that is, the "Buy Me" link uses the key value of the record. I thought you were asking about something else.

One of the first rules of database design is that the order of the records within the database is unimportant. It must be that way. Otherwise searches won't work correctly.

For example, if I was looking for banknotes from any country that were from 1918, I would want to search for that date. And your "country" record would not be returned. Unless you are not going to allow searches at all.

Also, if you ever modify a record, it will be out of order. All modification would have to be done outside of DBMan.

And still I don't see how it would work. It would be terribly complicated to make sure that the "country" record was on the same page as the ones to which it applies.

(BTW, thank you very much for the concrete example. It's very clear now what you're talking about. Smile )

It would be a duplication of information to have "USA" or "Uzbekestan" or whatever in each record, but I think that's the only way to do it.

However, just because it's in the record does not mean that it has to print out every time. I have helped several people who wanted their records to print out in Categories, which would be the same thing as this.


------------------
JPD






Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
I don't mean to interrupt this thread, but was wondering if Alan noticed the mod that O grain provided for a shopping cart mod?

I tested this out on his site and really like the way it works.

It was presented in this thread:
http://www.gossamer-threads.com/scripts/forum/resources/Forum12/HTML/002725.html
Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
 
Quote:
BTW, it just occurred to me that I could have a 'country' field for each record which is not visible. That way people could also search for items from a specific country.

Yes!! That's exactly right. This is another reason that you should have the field.

Yes, I did understand what you meant in your 3rd post, but I don't think it's feasible.


------------------
JPD






Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
<<Yes, I did understand what you meant in your 3rd post, but I don't think it's feasible.>>

JPD,
May I ask why?
Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
Let me count the ways. Smile

Your users would never be able to do a search. They would have to only list all of the items in your database. If I were a user, I would be annoyed with this.

If you had different numbers of items from each country, you would have to have a lot of empty fields to fill out the 250 records. And, if you ever had 251 items for any one country, you would have to add an extra empty record for every one of your other countries, in addition to changing the $db_max_hits value in the .cfg file.

Having 250 hits on one page is a lot and the page will take a long time to be created.

You would not be able to do any editing of the records within DBMan -- no adding, no modifying, no deleting of records. If you did that even once, the whole thing would fall apart.

These are the problems that occur to me just off the top of my head. I'm sure there are others.

At the top of the list, though, for me, is that this breaks the first rule of database design. Sorta like making a pot of tea and taking the kettle to the pot. It's just wrong! Smile


------------------
JPD






Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
You could set up your search form with a select box with all the countries in the world. There's one already made in the recent "Country Codes" thread. Or you could set up a select box that would only list the countries from which you currently have banknotes in your database. That's a very easy thing to set up. The advantage of the second one is that users will be able to tell right away if you have the country they're looking for, instead of getting a "no matching records" message if there isn't anything from that country.

But you can do it either way.

You can also set up your database so that search results would look something like this. (This isn't really code, but it keeps the formatting if I use the code tags. I hope. Smile)

Code:
USA
An old 1864 CSA $20 bill $44.00
1914 Silver certificate $23.00
$5 bill with printing error $50.00

Uzbekestan
Old hand-printed banknote of 1918 $26.00
First banknote of the new republic $ 5.00



------------------
JPD






Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
Thank you for the views. Your got me thinking hard about doing it in a more traditional way. I guess it would be ok. For search purposes, I'd need:
1) a <select> box with all the countries in the world, to search for all items from a specific country.

2) another box for searching for strings within the description field

Is that easy to set up in DBman?

I'll need to have the country field visible after all then, I guess. Then, if someone does a search for "1983", the search results will contain banknotes from several countries, and the country of each banknote must be apparent in the search results.

Alan
Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
JPD,
That country list-box idea of yours sounds perfect. Thanks!
That last listing option you illustrated looks like the one I need, if I understand you correctly: If the above banknotes all had the word "specimen" somwhere in the "description" field, and someone searched for the word "specimen", the results list would look as follows (assuming these were the only banknotes in the database with "specimen" in their description:


Code:
USA
An old 1864 Specimen CSA $20 bill $44.00
1914 Specimen Silver certificate $23.00
Specimen $5 bill with printing error $50.00
Uzbekestan
Old Specimen hand-printed banknote of 1918 $26.00
First banknote of the new republic (Specimen) $ 5.00

If that's correct, how do you achieve that listing format, with the country name appearing only once, at the top of each group of records?

Alan33


[This message has been edited by Alan33 (edited May 10, 2000).]

[This message has been edited by Alan33 (edited May 10, 2000).]

[This message has been edited by Alan33 (edited May 10, 2000).]

[This message has been edited by Alan33 (edited May 10, 2000).]
Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
Check out this thread for Group Short Display by Category:

http://www.gossamer-threads.com/scripts/forum/resources/Forum12/HTML/000505.html
Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
It's so nice to be able to count on Lois to know where these things are. I wish I was that organized! Smile

Regarding the select list that only lists the countries that are in the database:

You'll probably want to make a separate search form -- different from sub html_record_form. If you need help doing that, let me know.

In the search form, use

Code:
|;
print &build_select_field_from_db("Country","$rec{'Country'});
print qq|

The subroutine you'll need is already in your db.cgi file.


------------------
JPD






Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
JPD,

To create the new search form, shall I simply duplicate the sub html_record_form
and rename it something else, like, say, sub html_setcountries_form - or what?

Second question, I have set up fields for my banknote merchandise as follows. Does everything look ok to you? Note I have a field for the BuyMe link. Is this corrct? Do I need a UserID field - even though I'll be the only user who can modify the data?

Code:
ID => [0, 'numer', 5, 8, 1, '', ''],
BuyMe => [1, 'Buyme', 6, 6, 1, '', ''],
Country => [2, 'alpha', 40, 40, 0, '', ''],
ListRef => [3, 'alpha', 14, 14, 0, '', ''],
Denom => [4, 'alpha', 14, 14, 0, '', ''],
Descrip => [5, 'alpha', 66, 66, 0, '', ''],
Grade => [6, 'alpha', 5, 5, 0, '', ''],
Price => [7, 'numer', 7, 7, 0, '', ''],
Userid => [8, 'alpha', -2, 15, 1, '', '']

Thanks,
Alan



[This message has been edited by Alan33 (edited May 12, 2000).]

[This message has been edited by Alan33 (edited May 12, 2000).]
Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
To make a separate search form, copy sub html_record_form and paste it just below the current one. Rename the newly-pasted subroutine to sub html_search_form. Delete any fields that you don't want users to search by. In the place of the 'Country' field, use

Code:
|;
print &build_select_field_from_db("Country",$rec{'Country'});
print qq|

In sub html_view_search, change

&html_record_form();

to

&html_search_form();

and in sub html_view_failure, change

&html_record_form(%in);

to

&html_search_form(%in);

There are a few errors in your configuration and you don't need a separate "BuyMe" field. That will be taken care of by the ID field.

Here's what your .cfg should look like:

Code:
ID => [0, 'numer', 5, 8, 1, '', ''],
DateEntry => [1, 'date', 12, 15, 1, &get_date, ''],
Country => [2, 'alpha', 40, 40, 0, '', ''],
ListRef => [3, 'alpha', 14, 14, 0, '', ''],
Denom => [4, 'alpha', 14, 14, 0, '', ''],
Descrip => [5, 'alpha', 66, 66, 0, '', ''],
Grade => [6, 'alpha', 5, 5, 0, '', ''],
Price => [7, 'numer', 7, 7, 0, '', ''],
Userid => [8, 'alpha', -2, 15, 0, '', '']

I'm not sure you need a userid field. Who will be adding records to your database? If it's only you, you don't need the field.

If you delete the field, be sure to set

$auth_user_field = -1;

If you keep the field, set it to

$auth_user_field = 8;

since I just deleted one of your fields, moving the Userid field up one.

------------------
JPD






Quote Reply
Re: Shopping cart (a reply to JPDeni) In reply to
JPD,
Thanks so much! I'm now ready (with your help) to get the
cart feature operational.
Alan