I have a few questions:
(1) Where you have the "home" button/link I would like a "back" and a "forward" link to give my users an alternative to the browser buttons. The problem I have is that I want to use iframes for valid reasons and want my users to tab back in the iframe. Is this possible?
(2) Where do you edit the "Merchant" "Category" "Brand" links? I would probably want to rename "Merchant" to "shops" etc...
(3) I desire to show two prices... "product price without shipping" plus a "product price which includes shipping"...
how do I modify the code to allow users to perform low to high queries for both price alternatives?
{link saved}
I just logged in to phpMyAdmin for the first time and I can see that the value is added.
Therefore I just need to edit the table to show shipping price.
Any suggestions or code how to do this properly.
Ill experiment as I wait for reply.
Do you have a customer service skype account?
Peter from hagoole
Hi Peter,
I see from the link in your previous post (I have deleted as requested) that you now have the price including shipping being displayed so I think you've solved the problem - let me know if you still need any help with this...
Cheers,
David.
I have some Merchants who only sell in store and others who will post.
I am using three fields: price, shipping, total
I have modified the total to be the sum of price and shipping to a new field named "total".
I have also modified the sort low to high relative to the "total' field.
The reason I have the extra field not in the above code is so that I can display "No Shipping" if the shipping field is "No".
The problem I am having is how to exclude none shipping items from the sort by price inc. shipping sort.
I also noticed there is a problem with the shipping value because the shipping field is set to be DECIMAL(10,2) so it ignores the text when the field displays "does not ship or no etc".
Any ideas how I can accommodate for both type of Merchants... one who ships and another who doesn't?
I think I am close but can seem to go further...
Location of site: http://www.hagoole.com.au/bargains/
Hello Peter,
Two steps to resolving this I think - first of all, I would modify the table structure to allow "shipping" to be NULL, which will distinguish between free shipping (NULL) and does not ship (0.00). You should be able to do this with the following SQL:
ALTER TABLE products MODIFY shipping DECIMAL(10,2)
(fields are nullable by default, so leaving off NOT NULL does the job)
With that in place; PHP's is_numeric() function can be used to determine whether the shipping field in the feed contains an amount (even if 0.00), so within the import record handler function at the point at which you are currently calculating total, you would have something like this:
if (is_numeric($importRecord["shipping"]))
{
$importRecord["total"] = $importRecord["price"]+$importRecord["shipping"];
}
else
{
$importRecord["total"] = $importRecord["price"];
}
The next step would be to insert an additional WHERE clause into the search SQL when sorting by priceAsc or priceDesc. To do this, in search.php, look for the following code beginning at line 204:
if (isset($orderBySelection[$sort]))
{
$sql .= " ORDER BY ".$orderBySelection[$sort];
}
...and REPLACE with:
if (isset($orderBySelection[$sort]))
{
if ($sort=="priceAsc" || $sort=="priceDesc")
{
$sql .= " AND shipping NOT NULL ";
}
$sql .= " ORDER BY ".$orderBySelection[$sort];
}
Hope this helps!
Cheers,
David.
I think we are very close but I do get an error on the database.php file.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /data/home/prowler777/websites/hagoole.com.au/docs/bargains/includes/database.php on line 27
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /data/home/prowler777/websites/hagoole.com.au/docs/bargains/includes/database.php on line 32
I also modified this line to total...
if (isset($orderBySelection[$sort]))
{
if ($sort=="totalAsc" || $sort=="totalDesc")
{
$sql .= " AND shipping NOT NULL ";
}
$sql .= " ORDER BY ".$orderBySelection[$sort];
}
Hi John,
Can you enable database debug mode (config.advanced.php, line 6) then view the page again - the SQL causing the error should then be displayed; if you could let me know what that is...
Cheers,
David.
I seems like the NULL function doesn't work.
Perhaps it needs to be included in the import admin area below?
/* decimalise price */
$importRecord["price"] = tapestry_decimalise($importRecord["price"]);
$importRecord["shipping"] = tapestry_decimalise($importRecord["shipping"]);
$importRecord["total"] = $importRecord["price"] + $importRecord["shipping"];
When I look look with phpMyAdmin even NULL values are written as 0.00
I think this is the problem why the results only change in price but those that do not ship are not removed from results.
Hi Jim,
It will be that code that is setting shipping to 0.00 - includes/admin.php needs to be modified so that if shipping is empty then $importRecord["shipping"] isn't touched, so that it is included in the SQL as '', for example:
if (is_numeric($importRecord["shipping"]))
{
$importRecord["total"] = $importRecord["price"]+$importRecord["shipping"];
}
else
{
$importRecord["shipping"] = "";
$importRecord["total"] = $importRecord["price"];
}
I've added $importRecord["shipping"] = "";
to the code posted earlier to ensure that if the shipping value is text then it is still reset to "" so that it can be imported as NULL.
If you're not sure, if you could email me your includes/admin.php I'll check it out for you...
Cheers,
David.
Hi,
Re (2):
To change the merchant/category/brand links, you'll find these links created on the home page in index.php on lines 18-22, so you could change text there to whatever you wanted. For a more comprehensive change throughout the site, I would suggest using the translate feature, as this will change the word displayed on the home page and merchant index. To do this, replace the example translation in includes/translate.php with:
$translate["Merchant"] = "Shops";
Re (3):
The first stage in accomplishing this would be to add the shipping price as a new field on your site. To do this, follow the instructions in this thread to add a new "shipping" field, but instead of the suggest data type of VARCHAR(255), use DECIMAL(10,2). The dbmod.php script to add the new fields required for this would be as follows:
<?php
require("includes/common.php");
$sql = "ALTER TABLE `".$config_databaseTablePrefix."feeds`
ADD `field_shipping` VARCHAR(255) NOT NULL";
database_queryModify($sql,$result);
$sql = "ALTER TABLE `".$config_databaseTablePrefix."products`
ADD `shipping` DECIMAL(10,2) NOT NULL";
database_queryModify($sql,$result);
print "Done.";
?>
With a shipping field in place, the next stage would be to modify the import record handler to add the price to shipping, to make the shipping field become (price+shipping) instead of just shipping. To do this look for the following code beginning at line 274 of includes/admin.php:
/* decimalise price */
$importRecord["price"] = tapestry_decimalise($importRecord["price"]);
...and REPLACE this with:
/* decimalise price */
$importRecord["price"] = tapestry_decimalise($importRecord["price"]);
$importRecord["shipping"] = tapestry_decimalise($importRecord["shipping"]);
$importRecord["shipping"] = $importRecord["price"] + $importRecord["shipping"];
Next, several changes would be required to search.php to offer the Price+Shipping as a sort option. To do this, make the changes as described below:
Look for the following code at line 40:
$orderByDefault["priceAsc"] = "minPrice ASC";
$orderByDefault["priceDesc"] = "minPrice DESC";
...and REPLACE with:
$orderByDefault["priceAsc"] = "minPrice ASC";
$orderByDefault["priceDesc"] = "minPrice DESC";
$orderByDefault["shippingAsc"] = "shipping ASC";
$orderByDefault["shippingDesc"] = "shipping DESC";
Look for the following code at line 50:
$orderByFullText["priceAsc"] = "minPrice ASC";
$orderByFullText["priceDesc"] = "minPrice DESC";
...and REPLACE with:
$orderByFullText["priceAsc"] = "minPrice ASC";
$orderByFullText["priceDesc"] = "minPrice DESC";
$orderByFullText["shippingAsc"] = "shipping ASC";
$orderByFullText["shippingDesc"] = "shipping DESC";
...and finally look for the following code beginning at line 249:
$sortPriceAsc = ($sort=="priceAsc"?"<strong>".translate("Low to High")."</strong>":"<a href='".$sortHREF."priceAsc'>".translate("Low to High")."</a>");
$sortPriceDesc = ($sort=="priceDesc"?"<strong>".translate("High to Low")."</strong>":"<a href='".$sortHREF."priceDesc'>".translate("High to Low")."</a>");
$banner["h3"] = translate("Order by").": ".$sortRelevance.$sortRating." | ".translate("Price").": ".$sortPriceAsc.", ".$sortPriceDesc;
...and REPLACE with:
$sortPriceAsc = ($sort=="priceAsc"?"<strong>".translate("Low to High")."</strong>":"<a href='".$sortHREF."priceAsc'>".translate("Low to High")."</a>");
$sortPriceDesc = ($sort=="priceDesc"?"<strong>".translate("High to Low")."</strong>":"<a href='".$sortHREF."priceDesc'>".translate("High to Low")."</a>");
$sortShippingAsc = ($sort=="shippingAsc"?"<strong>".translate("Low to High")."</strong>":"<a href='".$sortHREF."shippingAsc'>".translate("Low to High")."</a>");
$sortShippingDesc = ($sort=="shippingDesc"?"<strong>".translate("High to Low")."</strong>":"<a href='".$sortHREF."shippingDesc'>".translate("High to Low")."</a>");
$banner["h3"] = translate("Order by").": ".$sortRelevance.$sortRating." | ".translate("Price").": ".$sortPriceAsc.", ".$sortPriceDesc. " | ".translate("Price inc. Shipping").": ".$sortShippingAsc.", ".$sortShippingDesc;
Cheers,
David.