admin

Oct 272006
 

I’ve not found a built in way to control sorting the product attributes yet. There’s probably a contribution to do this however considering it’s only a single line change which took me about 5 minutes to find I figured it wasn’t a concern to find a contribution for it. At present there is no ordering of the attributes when they’re pulled from the database. Regardless of how you enter them in the retrieval seems to just randomly make its own mind up about how they should be displayed! When a client first brought this to my attention and said they’d been inputting them in the correct order, and the order of the attributes where in the same order as the order id’s (ie. lowest id for the first item and highest id for the last item) it made me wonder just how it was coming out. Usually when you run a SELECT statement in MySQL if you don’t give it an order it comes out in the row order. But at the same time this often isn’t the same order as the items were added.

Anyhow, so which line do you change? Under the products_info.php file find the line:
$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");

and at the end of the SQL statement add (for ordering by id)
ORDER BY pov.products_options_values_id ASC

giving you
$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' ORDER BY pov.products_options_values_id ASC");

This method orders the attributes by id number, the number you see at the start of the attribute line in the admin section. If you wanted it ordered alphabetically you could use (untested!)
ORDER BY pov.products_options_values_name ASC

or by price
ORDER BY pa.options_values_price ASC

 Posted by at 8:25 pm
Oct 262006
 

Despite buying a template for this website we’ve had rework the layout for the product display on the single page as well as every results listing. Due to the products my client’s selling, most of the images are long and thin as opposed to boxy. The original design had the image to the left and the text and price to the right, however with the long/thin images the text was getting pushed out of the fixed width design.

So last night and today I’ve been digging out the various files that are used for the product display and altering them to have the image first and then below the image comes the title, text, price and buy now buttons. On the results listings the image above and the title, price and buy now button on the line below. For the long and thin images this looks quite nice however for the few square images there are it unfortunately doesn’t look too great, however without a lot of rewriting of the HTML and adding in some CSS floats to control where the text sits depending on the image, then this is the next solution.

Pages I’ve had to update have been
product_info.php – for the single display page
bestsellers.php
includes/classes/boxes.php
includes/modules/product_list.php
includes/modules/new_products.php

I had to dramatically alter the boxes.php page, and copy the class usually used for displaying boxes into the product’s own class so that it could be amended just for the product display, as I didn’t know what else it would affect. The trouble was the products came out, one product per row with the image, title, price and buy now button each in a separate column. So getting a second row into the mix and making the first row span 3 columns, was the hardest part. After a lot of trial and error and a missing equals sign (sending the file into a neverending loop!), the products finally started to display correctly.

Unfortunately my client however has been uploading her image photos with a lot of white space on them. All of the photos are on clear white backgrounds however she’s not been cropping them down, so at present some images sit higher above the title and price associated with it than others. It’s also taken me 3 goes to explain to her that I cannot reduce the size between the product image and the text below it as there has been no padding or margins added! I’m hoping once she crops the images she’ll start to get the idea otherwise I’ll be outlining all of the images so that she can see where they start and end for herself!

 Posted by at 6:00 pm
Oct 242006
 

It’s been one of those months with no ADSL connection at home, and too many deadlines going on to really get much done on this site. Knowing my client still had plenty of work with adding the products her end meant I relaxed a little about the last few alterations for her site to get the other work done and out the way. However that’s all pretty much done now so it’s back to the site.

She mentioned to me last week that she has the option to change the product order on her other site, plus she wanted to offer a gift wrap service as well. So these are two more contributions I need to find along with working out with Protx module to install. Plus edit the product layout!

 Posted by at 10:35 pm
Oct 242006
 

When we first installed the auto thumbnailer contribution it worked fine, absolutely perfectly. However after installing the other contributions I noticed that even though the extra pics were resizing on the page, the main product image wasn’t, but it was in the product listings and search results. So I sat down today and ran through the PHP code for the contribution to see what had altered. I had a nagging feeling in my mind that the More Pics contribution had overwritten something that the Auto Thumbnailer was relying on.

After digging through the PHP code in the product_info.php page I noticed the line where the main image is printed to the page

document.write('' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), (MOPICS_RESTRICT_PARENT=='false'?'':SMALL_IMAGE_WIDTH), (MOPICS_RESTRICT_PARENT=='false'?'':SMALL_IMAGE_HEIGHT), 'hspace="5" vspace="5"') . '
' . TEXT_CLICK_TO_ENLARGE . ''; ?>');

Here you can see the additions added by the More Pics contrib
(MOPICS_RESTRICT_PARENT=='false'?'':SMALL_IMAGE_WIDTH)
(MOPICS_RESTRICT_PARENT=='false'?'':SMALL_IMAGE_HEIGHT)

Looking at the code (for anyone who doesn’t know PHP) it essentially says if the constant ‘MOPICS_RESTRICT_PARENT’ is set to false then don’t print anything, otherwise print the small image width/height. However this doesn’t control where the image is pulled from, and in the pages the main product image was coming from the original directory and not the resized image cache directory. After removing the if statement and forcing the small image width/height to be printed suddenly it all worked fine again. I’m sure there’s probably a language file somewhere to change to get the same affect but I certainly can’t work out what to change!

So my code now is
document.write('' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . ''; ?>');

Which is what it was originally.

 Posted by at 10:21 pm
Oct 042006
 

So how far have we got? Well the site is now running on the live domain, the client is adding in her products and they’re almost displaying correctly on the front end.

Because of the product photos in use, some are long and narrow, others are square. Not ideal really, but we’ve got to work around these issues. So the product results and product info page has to be displayed in a different manor to the usual image on the left, detail on the right. Plus the Auto thumbnailer doesn’t seem to be working on the main product photo, just the extra photos and the search results pages. So a bit more PHP investigating is needed, along with still having to fix the Customer Title issues.

So there isn’t too much left to do, just a few PHP fixes here and there, and then probably a bit of CSS trickery to deal with the product info page dependent on the photo size.

 Posted by at 4:14 pm
Sep 292006
 

We’ve had two test sites running for this new store. The first is on the new domain, the site was purely set up to allow the client to start adding products. The second is on a spare domain for us to work on the site files, add the contributions etc.

Unfortunately yesterday we discovered the second test site wasn’t working correctly as it wasn’t picking up the shipping, payment or order modules in the admin and that was causing errors on the front end. So after trying to fix the modules we concluded that there was a server error of some sort and so decided to just update the new domain with our files and continue working directly on that, now that the admin section is finished with the contributions.

This has taken pretty much 24 hours to do however. Our ADSL has slowed down to less than dial up speeds and trying to upload the files for osCommerce has just been a joke. It took about an hour or so to just get the admin section online, and even then some of the files were only partially uploaded, so I’ve had to check every single file to ensure it’s online in its complete state. However finally the files are on the domain and so now I just have to fix the two contributions that aren’t working perfectly and play around with the product layouts a little. Hopefully this’ll all be finished and live soon!

 Posted by at 11:37 pm
Sep 282006
 

So today we decided to start adding the contributions to the new site. Armed with my new file comparison software I made a list of the contributions needed and set to work adding them in to the site code.

Contributions Used:

All went fine until I realised that the Customer Title contrib has been designed to be used with PWA 0.8, and the latest version of PWA is 1.12+ and has been written in a completely different way. I first used the Title contrib on another existing store which is running on an earlier version of PWA and the contrib merged in fine, but with this new version several of the PWA files are not used now as it’s been set to use existing files instead, which is fine except that I can’t seem to get the Title to save and display on the order pages and invoice.

To add to that the auto thumbnailer is not working on the product info page for the main product, yet it is working on the product listings pages and on the extra pics, so again a bit baffling and some more code that I’ll have to go through to determine what’s being missed and where. I had the thumbnailer working on my test site so clearly something is slightly different which is causing it to not play ball.

 Posted by at 9:37 pm
Sep 272006
 

A lot of customers won’t want to create an account with you, for whatever reason you don’t want to deter your customers from buying from you. So an express checkout option is a good idea to let those customers who don’t want to create an account still purchase from your store.

Purchase Without Account does the job well for this. It gives a quick route for purchasing keeping both you and your customers happy.

 Posted by at 10:51 pm
Sep 262006
 

When you start to customise your site from the default installation, adding contributions can become a harder job as you obviously cannot just overwrite the file with the contribution file otherwise you’ll lose your changes. So you have to compare the two sets of code to see what’s changed in the contribution file and copy that into your own file – a long and tedious job at times.

Most contributions mention about using a file comparison program which I downloaded today to try it out after I was going crossed eyed at comparing files manually. Beyond Compare is a fantastic program that makes the job ten times easier. After running this program and comparing two files I shot through the comparison so quickly I was amazed. This program could have been used so many times in the past and is definitely on my shopping list of software to buy next month! You get a 30 day trial but it works out to around $30 to buy (I think!).

If you need to compare files then this is the program for you.

 Posted by at 10:19 pm
Sep 232006
 

I’ve been trying to add the option for a Customer Title (Mr/Mrs/Miss etc) to an existing store. Without thinking of searching through the contributions I first hacked the code around to deal with it myself, however after I was half way through I realised how complicated osCommerce makes things. On every order it copies the customer’s name and address into a different table thus duplicating the information instead of just referencing the address via a record id. So even if you update the customer’s details the order details for the customer doesn’t update (try this with an order, update the customer’s details and then view the customer’s order and you’ll see their details haven’t changed!).

I had the bulk of the customer’s title script working until I realised it wasn’t working for the Express Checkout option that is already installed on the site. This of course doesn’t use the database in the same way, but relies on sessions more. So after trying to figure out how to fix this I took a look in the contributions on the osCommerce site and came across a Customer Title contribution which also worked with the Purchase Without Account Contribution, which is the express checkout contribution running on the web site. Great, I thought, this should fix all the issues.

So I grabbed the contribution and updated the site files with the code from it, updated the database and tested it on a test site – worked fine apart from one issue, the title wasn’t displaying on an invoice after an order had been made. I then spent an hour or so comparing the code from the contribution to all the admin files trying to connect the dots on how the address was displayed to where it came from etc. Eventually I discovered that all of my code was correct however the actual customer’s title wasn’t being pulled from the database, once I’d fixed that it all worked perfectly :)

For anyone who does use the contribution and finds the same problem I did simply edit line 28 (ish) in /admin/includes/classes/order.php from

$order_query = tep_db_query("select customers_name, customers_company, etc.

to

$order_query = tep_db_query("select customers_title, delivery_title, billing_title, customers_name, customers_company, etc.

This then pulls the titles out which is what the address format function needs.

 Posted by at 9:25 pm