John King wrote:

> Hi JJ
> 
> Thanks for your assistance with the code. I didn't realize it would be so
> difficult, but I have to say I was surprised  that FT didn't allow you
> to access
> a product from your cart. This is pretty much a standard feature with
> every other
> cart I've ever seen and hopefully Leon will consider doing it with
> version two.

Yes, I've added this to Restoration Hardware's Web site.  I'll explain
below why it isn't imperative to put this into Freetrade.

> I think FreeTrade's strongest feature is the way you are NOT sent to
> the checkout
> queue every time you purchase a product. From my observation EVERY
> cart other
> than FreeTrade takes you to a full screen display of your basket (like
> walking to
> the checkout), which actually disrupts your concentration cycle. The way
> FreeTrade just drops an item into your basket and then allows you to keep
> shopping is a huge bonus. However, when thinking like a true shopper,
> it would be
> lovely to remove something from the basket and replace it with
> something better
> just as easily. The way the "out of the box"  FreeTrade asks you to
> (a) remove
> and item or (b) increase the quantity is very disruptive. Hopefully
> you can
> discuss this with Leon, but the way I see it, the "ex box" version of
> FreeTrade
> should allow you to (a) choose quantity when selecting a product and,
> (b) delete
> an item, and (c) go back to the item from the mini basket.

Okay, now for the big explanation (I've given this lecture a few times).
Freetrade is a toolkit.  It's also a methodology.  Hence, it is expected
that you, the developer, tweak the system to fit your particular
needs/desires.  Really, the most important part of Freetrade is that it
allows experienced PHP programmers to make little tweaks like this
easily.

> Okay, having said all that, my PHP experience of less than one week has me
> guessing on a lot of things. I'm a "Clarion" programmer from way back, and
> although we used includes, it was never like it seems to be with PHP.
> I really am
> still trying to figure out what runs what, but I was way off track
> trying to get
> the basket to show links back to the ordered product. I was using HREF
> with no
> success at all. I was very intrested in your code, but have to admit I
> had never
> heard of "htmlentities". I looked them up the PHP manual and
> understand what
> they're meant to do, but I still can't figure out the correct syntax
> for them.

The purpose of htmlentities is to prevent the imfamous "purple
dinosaur".  I.e., it will take the following:

"><script>alert("You suck!");</script><p align="center

and replace it with something like:

&quot;&gt;&lt;script&gt;alert(&quot;You
such!&quot;);&lt;/script&gt;&lt;p align=&quot;center

Thereby rendering the string harmless.  I had forgotten that in
Freetrade, we use a the prepareText function, defined in
include/standard_library instead htmlentities due to localization
issues, if I remember right.  Hence, you should use prepartText on any
user influenced variable before outputing that variable to the screen.

> If you can help me out just a little more, I'll write something for
> the BBS so
> that everyone else can use this cool feature.
> 
> What I have at present is the standard basket code. I've simply
> deleted the print
> code to remove all but the sku_name from the basket. thus my actual
> printout code
> looks like this:
> 
> print("<TD><FONT SIZE=\"1\"face=\"Verdana, Arial, Helvetica,
> sans-serif\">$sku_Name</FONT></TD>\n");
> 
> and that works fine.
> 
> The code that gets the data from mysql hasn't been changed much so I
> still have
> this to play with:
> 
> /*
> ** Retrieve all of the items in the user's cart.
> */
> $Query = "SELECT s.ID, s.Name ";
> $Query .= "FROM session_sku ss, sku s ";
> $Query .= "WHERE ss.SKU = s.ID ";
> $Query .= "AND ss.Session = '$sid' ";
> 
> //------------changed from the code below to restrict variable usage
> to what I
> need:
> 
> // $Query = "SELECT ss.Quantity, s.ID, s.Name, s.ListPrice, s.SalePrice ";
> // $Query .= "FROM session_sku ss, sku s ";
> // $Query .= "WHERE ss.SKU = s.ID ";
> // $Query .= "AND ss.Session = '$sid' ";'
> 
> $DatabaseResult = mysql_query($Query, $DatabaseLink);
> if (!mysql_num_rows($DatabaseResult))
> {
> /* Continue line from above: "Your basket<BR>is empty." */
> print(L_NAV_BASKET_EMPTY);
> }
> else
> {
> /* List the items in a table. */
> // $order_Total = 0.00;
> print("<TABLE>\n");
> while ($row = mysql_fetch_row($DatabaseResult))
> {
> /* Parse the row. */
> 
> list($sku_ID, $sku_Name,) = $row;    //---------------------- my
> reduced version
> from the code below
> 
> //  list($sku_Quantity, $sku_ID, $sku_Name, $sku_Price,
> $sku_SalePrice) = $row;
> // $sku_Price = ($sku_SalePrice > 0) ? $sku_SalePrice : $sku_Price;
> // $sku_Price *= $sku_Quantity;
> //  $order_Total += $sku_Price;
> 
> /* Output the row. */
> 
> I've tried your code with several permutations, but it refuses to
> work.  I'm sure
> I still don't fully understand the use of htmlentities and the array
> above.
> 
> I hope this won't take long to answer, but I can see myself taking far
> too long
> to figure it out.
Okay, the problem is that you don't have the item ID available for use
in this chunk of code, and you need the item ID in order to transfer the
user to the item screen.  Remember, items (like living-room set) contain
SKUs (like chair and ottoman).  Hence, since you have the skuID, you can
get the corresponding item via:

$query = "SELECT Item FROM sku WHERE ID = " . intval($skuID);
....
list($itemID) = mysql_fetch_row($records);

Then you may use this itemID to link to the appropriate screen via

print("<a href=\"" . ScreenURL("item", FALSE,
array("item"=>intval($itemID)) . "\">" . htmlentities($itemName) .
"</a>");

Note, the "array" in the above code is passing an array of variable name
/ variable value pairs that you want appended to the URL as GET
variables.

Now, I really must leave it to you at this point to fill in all the
details.  Afterall, Freetrade is meant for developers, and you'll
probably feel more "enabled" if you fill in some of the details.

> 
> Best wishes,
> 
> John
Cheers,
-jj


------------------------------------------------------------
To subscribe:    [EMAIL PROTECTED]
To unsubscribe:  [EMAIL PROTECTED]
Site:            http://www.working-dogs.com/freetrade/
Problems?:       [EMAIL PROTECTED]

Reply via email to