Thank you for your help:)
Could you send me your "department" file, so i could have a look at it.
I get the error message "This item is unavailable at this time."
Thanks
Tom
----- Original Message -----
From: Marek <[EMAIL PROTECTED]>
To: FreeTrade <[EMAIL PROTECTED]>
Sent: Monday, February 28, 2000 8:06 PM
Subject: Re: [FreeTrade] Buy items from departmentlisting?
> Hi Tom,
>
> This is what you have to do:
>
> Add this line to the end of the "department" SCREEN
>
> include(APPLICATION_ROOT . "modules/screens/item_dep"); file://(This line
> goes inside the last "While" statement on the "department" page.)
>
> Create a new file "item_dep (modified version of "item")
>
> It works with FreeTrade-20000226 - FreeTrade-20000228
>
>
>
> <?php
>
> /*
> ** File: item_dep
> ** Description: show item ADD on the department level
> */
>
> file://get attribute functions
> include(APPLICATION_ROOT . "/modules/include/attribute_functions");
>
> file://get item functions
> require(APPLICATION_ROOT . "/modules/include/item_functions");
>
> file://get item info
> $Item = GetItemInfo($item);
>
> if( !isset($department) )
> {
> file://get the department for this item
> $department = $Item["Department"][0];
>
> }
>
> $department = intval($department);
>
> if(isset($Item["ID"]))
> {
> /*
> ** Output the item name and description.
> */
>
> file://get sku giftwrap-ability
> $Query = "SELECT SKU ";
> $Query .= "FROM sku_variation ";
> $Query .= "WHERE Variation = " . getVariationID(getAttributeID("Gift
> Wrap"), "Available") . " ";
> $Query .= "AND SKU in (0";
> for($index = 0; $index < count($Item["SKU"]["ID"]); $index++)
> {
> $Query .= ", " . $Item["SKU"]["ID"][$index];
> }
> $Query .= ") ";
> $DatabaseResult_ = mysql_query($Query, $DatabaseLink);
> while($DatabaseRow_ = mysql_fetch_row($DatabaseResult_))
> {
> $GiftWrap[($DatabaseRow_[0])] = TRUE;
> }
>
>
>
> file://list SKUs
>
>
> $BackorderedItems = FALSE;
>
> print("<TABLE BORDER=\"0\">\n");
>
> for($index = 0; $index < count($Item["SKU"]["ID"]); $index++)
> {
> print("<TR>\n");
>
> print(StartForm("department", 'post', 'ADD_BASKET', FALSE,
> array("department"=>$department,
> "item"=>$item,
> "sku"=>$Item["SKU"]["ID"][$index])));
>
> file://gift wrap status
> print("<TD VALIGN=\"center\">");
> if( isset($GiftWrap[($Item["SKU"]["ID"][$index])]) )
> {
> print("<FONT SIZE=\"1\">" . L_ITEM_GIFTWRAP . "</FONT>");
> }
> else
> {
> print(" ");
> }
> print("</TD>\n");
>
> print("<TD VALIGN=\"center\">");
> print(prepareText($Item["SKU"]["Name"][$index]));
> print("(" .prepareText($Item["SKU"]["ExternalSKU"][$index]). ")");
> print("</TD>\n");
>
> print("<TD VALIGN=\"center\">");
> if($Item["SKU"]["SalePrice"][$index] > 0)
> {
> print(" " . formatMoney($Item["SKU"]["SalePrice"][$index]));
> }
> else
> {
> print(" " . formatMoney($Item["SKU"]["ListPrice"][$index]));
> }
>
> if($Item["SKU"]["Shipping"][$index] > 0)
> {
> print(" (" . formatMoney($Item["SKU"]["Shipping"][$index]) . ")");
> }
>
> print("</TD>\n");
>
>
>
> /*
> ** get SKU attributes with more than one variation
> */
>
> file://get list of attributes as comma-separated list
> file://this allows us to drop it right into the SQL
> $MultiAttributes = "0"; file://seed with dummy value
>
> $Query = "SELECT v.Attribute, COUNT(v.Attribute) ";
> $Query .= "FROM sku_variation sv, variation v ";
> $Query .= "WHERE sv.Variation = v.ID ";
> $Query .= "AND sv.SKU = " . $Item["SKU"]["ID"][$index] . " ";
> $Query .= "GROUP BY v.Attribute ";
> $Query .= "ORDER BY 2 DESC ";
> $DatabaseResult_ = mysql_query($Query, $DatabaseLink);
> while($DatabaseRow_ = mysql_fetch_row($DatabaseResult_))
> {
> if($DatabaseRow_[1] > 1)
> {
> $MultiAttributes .= ", $DatabaseRow_[0]";
> }
> }
>
>
> file://get full variation info
> $Query = "SELECT a.ID, a.Name, v.ID, v.Name ";
> $Query .= "FROM sku_variation sv, variation v, attribute a ";
> $Query .= "WHERE sv.SKU = " . $Item["SKU"]["ID"][$index] . " ";
> $Query .= "AND sv.Variation = v.ID ";
> $Query .= "AND v.Attribute = a.ID ";
> $Query .= "AND a.ID in ($MultiAttributes) ";
> $Query .= "ORDER BY a.DisplayPrecedence, a.Name ";
> /* Execute query. */
> if ( !($DatabaseResult_ = mysql_query($Query, $DatabaseLink)) )
> {
> print("<!-- " . mysql_errno() . ": " . mysql_error() .
> "Query was $Query -->\n");
> }
> else
> {
> if ( !mysql_num_rows($DatabaseResult_))
> {
> /* No select. */
> }
> else
> {
> $last_attr = 0;
> while($DatabaseRow_ = mysql_fetch_row($DatabaseResult_))
> {
> $tAttributeID = $DatabaseRow_[0];
> $tAttributeName = $DatabaseRow_[1];
> $tVariationID = $DatabaseRow_[2];
> $tVariationName = $DatabaseRow_[3];
>
> if($last_attr != $tAttributeID)
> {
> if($last_attr != 0)
> {
> print("</SELECT>\n");
> print("</TD>\n");
> }
>
> print("<TD VALIGN=\"center\">\n");
> print("<SELECT NAME=\"inputVariation[]\">\n");
> print("<OPTION VALUE=\"$tVariationID\" SELECTED>");
> print(prepareText($tAttributeName));
> print("\n");
>
> $last_attr = $tAttributeID;
> }
>
> print("<OPTION VALUE=\"$tVariationID\">");
> print(prepareText($tVariationName));
> print("\n");
> }
> print("</SELECT>\n");
> print("</TD>\n");
> }
> }
>
>
>
> file://submit button for adding item to basket
> print("<TD VALIGN=\"center\">");
>
> file://check inventory levels
> file://Total items in warehouse = Available + Reserve
> if($Item["SKU"]["Available"][$index] +
> $Item["SKU"]["Reserve"][$index] > 0)
> {
> print("<INPUT TYPE=\"SUBMIT\" NAME=\"basket_button\"
> VALUE=\"Add\">");
> }
> elseif($Item["SKU"]["Backorder"][$index] == 'Y')
> {
> print("<INPUT TYPE=\"SUBMIT\" NAME=\"basket_button\"
> VALUE=\"Backorder *\">");
> $BackorderedItems = TRUE;
> }
> else
> {
> print("<B>Out of Stock</B>");
> }
>
> file://user must be logged in to use wishlist
> if($UserInfo["ID"] > 0)
> {
> print("<INPUT TYPE=\"SUBMIT\" NAME=\"wishlist_button\" VALUE=\"Add
> To Wishlist\">");
> }
>
> print("</TD>\n");
>
> print("</FORM>\n");
>
> print("</TR>\n");
> }
>
> print("</TABLE>\n");
>
> if($BackorderedItems)
> {
> print(L_ITEM_BACKORDERED . "<BR>");
> }
>
> showRelationship($Item, 'Cross-Sell', "Similar Items:");
>
> showRelationship($Item, 'Accessory', "Accessories:");
>
> }
> else
> {
> print(L_ITEM_UNAVAILABLE);
> }
>
> ?>
>
>
>
> Done.
>
>
>
> > Tom Jakobsen wrote:
> >
> > Hi
> >
> > Im a PHP newbie, and are working with Freetrade.
> >
> > I want to let the users be able to buy products directly from the
> > department->itemlisting. How can i add SKU-prices , and the "Add to
> > basket" button to each product ?
> >
> > Thanks
> >
> > Cheers
> >
> > Tom
>
> --
> Marek Stanczyk
> Integration Specialist
> [EMAIL PROTECTED]
>
> Web++ Inc. "Dynamic Internet Solutions"
> 3415 Dixie Road, Suite 512 Mississauga, Ontario L4Y 2B1
> Tel: 905-566-1215 Fax: 905-566-8543
> Internet: www.webplusplus.com
>
>
> ------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Site: http://www.working-dogs.com/freetrade/
> Problems?: [EMAIL PROTECTED]
>
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Site: http://www.working-dogs.com/freetrade/
Problems?: [EMAIL PROTECTED]