PDA

View Full Version : No stock -a simple idea, but help required


Bud
03-03-08, 02:30
As you've all probably gathered my coding is non existent.

So, in an effort to give visitors more than a blank page when they land on a product that no longer exists, I thought I'd put a simple piece of code in to say 'sorry, this item has been moved - please search again', sort of thing.

Now, 6 hours later I've only managed to get this sorted by using:


{if $fSearchPrice != 0}

{include file="elements`$DIRECTORY_SEPARATOR`product_display.tpl"}

{else}
Sorry, this item has been moved.
{/if}


That seems to have limited success but is not always true when using $fSearchPrice as the check.

I would like to use $sProductName as the check (or even better $sProductName+$fSearchPrice) - i.e. if there's no title, then it isn't in stock (that seems to be true).

Replacing $fSearchPrice with $sProductName doesn't work and I can't figure out how to change it to make that work.

I know most of you will be falling about laughing by now but it's bugging the hell out of me! :o

Any advice would be very gratefully received.

Cheers - Bud

:confused:


PS. Additional to my quest above (I'm not asking for help with this, or for it to be posted here. It's just an idea for those that can), I thought that if you had the knowledge you could perhaps take the search term from Google etc and automatically enter this into your search box, thus presenting the user with an instant search entry. At least that would help a large %age of the SERPs visitors obtain something useful even though they've landed on a page where the item has been removed.

IntroSites
03-03-08, 10:24
have you tried

{if !$sProductName}

Bud
03-03-08, 12:28
Thanks for the suggestion Intro but I can't seem to get that working. Should there be any qualifier for that statement ie. == 0 or similar?

I've replaced {if $fSearchPrice != 0} with {if !$sProductName} and a few variations eg. {if !$sProductName != 0} etc with no joy.

Confuscius
03-03-08, 13:47
Hi Bud

Can you provide and example of a visitor that matches what you say - in other words how did they find the missing product? What was the page requested? There are several ways to hit a 'blank' page!

I will then investigate further ( or ask Andy to! ) and try to advise.

Paul

Bud
03-03-08, 15:01
Thanks Paul

This is the sort of thing I'm trying to combat.

A google search for york c301:

http://www.google.co.uk/search?q=york+c301&hl=en&cr=countryUK%7CcountryGB&start=50&sa=N

The Offset Shop is listing in the results and google sends the visitor to:

http://www.theoffsetshop.co.uk/product.php?p=20034103&c=559

Obviously this is no longer available.

Before I had done the {if $fSearchPrice != 0} modification the visitor would just see the normal product page but with no image, description or price.

Now at least they get a short message instead of a 'dead' page.

All I'd like to do be able to do is not base this landing page on a price of £0.00 as there are legitimate items, but rather have it generated should there be no product title.

Hope that makes sense.

Cheers
Bud



Also - as you can see if you do a search for 'york c301' the item is available elsewhere (at £349) which is why, for those of you who can, it may be useful to import the search term directly to the search box thus enabling the visitor to simply click 'Search'.

Or, having thought about this a bit more, if the check failed to return a product the 'Search' could also be automated so they wouldn't even have to click - couldn't it?
Thus presenting them with: http://www.theoffsetshop.co.uk/search.php?q=york+c301&c=0&search=Search

amcho
04-03-08, 16:14
Bud,
A good idea, I have tried changing product.php to test for a zero price, and then display the category with the results at:
http://motor-products.co.uk/aw-shop/test_product.php?p=71336962&c=80

to do this copy product.php to test_product.php
(otherwise you will screw your site for a day or 2 - bitter experience!)
at the bottom of the code change the line
$oSmarty->display('product.tpl');
to

$fSearchPrice = $oSmarty->get_template_vars('fSearchPrice');

if ($fSearchPrice>0) {
$oSmarty->display('product.tpl');
}

else {
echo "Sorry - this product / page has been moved - please see below for similar products.";
require_once('category.php');
}

the require_once('category.php'); is probably an overkill and it may be good to just include the code actually required,

amcho
04-03-08, 18:13
we should really be testing something more than price as there are some zero prices that are valid - do a search on dating for instance.....
probably product name would be a better choice than price - change the if statement at the top to

$sProductName = $oSmarty->get_template_vars('sProductName');
// $sProductName is set to ' by ' if deleted product
if (strlen($sProductName)>4) {
$oSmarty->display('product.tpl');
}

else {

Bud
05-03-08, 02:20
amcho - great stuff!

A simple (if you know how!), but beautiful solution.

Thanks