Zen Cart Logo
Forums / General Questions / Looking to migrate to ZenCart from OSC

Looking to migrate to ZenCart from OSC

Views: 13,055

Results 81 to 100 of 200
21 May 2014, 3:54 AM
#81
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Looking to migrate to ZenCart from OSC

The new products centerbox is intended as a teaser for a page where the main content is another listing of products, hence it only has the ability to show name and image with a link to see details. To turn it into a full-fledged listing, you would need to adapt the code from the new products page to look up the full dataset and output what is desired.
The featured centerbox will be the same situation.

21 May 2014, 7:37 AM
#82
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

mc12345678:

Doing some catching up on this thread. Having found the location of the depth "factor", perhaps it would help others if it was posted here as well.

Hi ... yes I agree and apologies that I didn't do this earlier.

To change the number of manufacturers listed in the sidebox selection box before it has to be scrolled:

In your Admin go to CONFIGURATION ==> MAXIMUM VALUES ==> MANUFACTURERS LIST - SCROLL BOX SIZE/STYLE

and edit the number to however many you wish to display before scrolling is required.

If you set this figure to either 1 or 0 then the manufacturers list will become a drop-down box.

21 May 2014, 12:27 PM
#83
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

gjh42:

The new products centerbox is intended as a teaser for a page where the main content is another listing of products, hence it only has the ability to show name and image with a link to see details. To turn it into a full-fledged listing, you would need to adapt the code from the new products page to look up the full dataset and output what is desired.
The featured centerbox will be the same situation.

OK - thanks. I had to put an addon in on the OSC site to do this. I understand the teaser aspect but the site doesn't really work in the standard way. I have located where I need to make the changes so I will work through to see if I can get the description added. I also need to add the Author (manufacturer) to the New Books for ............ as this enables our members to hone in on books of interest quickly so I'll check how it displays in main listings and try to incorporate that as well.

21 May 2014, 8:57 PM
#84
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

Hi All

I have managed to make a lot of changes to the Product Info display but now hit a real snag that I just cannot get my head around.

All books are downloadable and I realise that the last three lines of the following extract from tpl_modules_attributes.php have to be performed to enable downloading to take place:

<?php /** * Module Template * * Template used to render attribute display/input fields * * @package templateSystem * @copyright Copyright 2003-2005 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: tpl_modules_attributes.php 3208 2006-03-19 16:48:57Z birdbrain $ */ ?> <div id="productAttributes"> <?php if ($zv_display_select_option > 0) { ?> <h3 id="attribsOptionsText"><?php echo TEXT_PRODUCT_OPTIONS; ?></h3> <?php } // show please select unless all are readonly ?> <?php for($i=0;$i<sizeof($options_name);$i++) { ?> <?php if ($options_comment[$i] != '' and $options_comment_position[$i] == '0') { ?> <h3 class="attributesComments"><?php echo $options_comment[$i]; ?></h3> <?php } ?> <div class="wrapperAttribsOptions"> <h4 class="optionName back"><?php echo $options_name[$i]; ?></h4> <div class="back"><?php echo "\n" . $options_menu[$i]; ?>

The problem I am facing is that after the Download radio button (option value) Zip file - it is displaying [was £xxx.xx now is: Free] - in this instance the book is (and always was free).

I have tried various amendments to the three lines of the script above but everything I do stops the book from being downloadable. (I have found and tried ob_start() ... ob_clean() which has the same effect. What is more frustrating is that I have no idea where the text "[was £xxx.xx now is: Free]" is generated. If I remove the echo then Zip file also disappears so it is attached to the option value somewhere but I cannot find that anywhere in the Admin attributes controller.

Short of replacing this output with surrounding <font color=white> ...... </font> can anyone suggest please how I can go about removing this odd text?

Thanks

Attachment 14096

21 May 2014, 9:30 PM
#85
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Looking to migrate to ZenCart from OSC

DigiBooks:

Hi All

I have managed to make a lot of changes to the Product Info display but now hit a real snag that I just cannot get my head around.

All books are downloadable and I realise that the last three lines of the following extract from tpl_modules_attributes.php have to be performed to enable downloading to take place:

<?php /** * Module Template * * Template used to render attribute display/input fields * * @package templateSystem * @copyright Copyright 2003-2005 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license <http://www.zen-cart.com/license/2_0.txt> GNU Public License V2.0 * @version $Id: tpl_modules_attributes.php 3208 2006-03-19 16:48:57Z birdbrain $ */ ?> <div id="productAttributes"> <?php if ($zv_display_select_option > 0) { ?> <h3 id="attribsOptionsText"><?php echo TEXT_PRODUCT_OPTIONS; ?></h3> <?php } // show please select unless all are readonly ?> <?php for($i=0;$i<sizeof($options_name);$i++) { ?> <?php if ($options_comment[$i] != '' and $options_comment_position[$i] == '0') { ?> <h3 class="attributesComments"><?php echo $options_comment[$i]; ?></h3> <?php } ?> <div class="wrapperAttribsOptions"> <h4 class="optionName back"><?php echo $options_name[$i]; ?></h4> <div class="back"><?php echo "\n" . $options_menu[$i]; ?>

The problem I am facing is that after the Download radio button (option value) Zip file - it is displaying [was £xxx.xx now is: Free] - in this instance the book is (and always was free).

I have tried various amendments to the three lines of the script above but everything I do stops the book from being downloadable. (I have found and tried ob_start() ... ob_clean() which has the same effect. What is more frustrating is that I have no idea where the text "[was £xxx.xx now is: Free]" is generated. If I remove the echo then Zip file also disappears so it is attached to the option value somewhere but I cannot find that anywhere in the Admin attributes controller.

Short of replacing this output with surrounding <font color=white> ...... </font> can anyone suggest please how I can go about removing this odd text?

Thanks

Attachment 14096

Forgive me, but I've forgotten how to address that specific issue, but can say that the attempted code change is definitely not the way to go. A few things: should get familiar with the developer's tool kit if not already, also krrp in minf that many ZC text items are built in parts. So I just did a search on is now: and found that said portion of text is defined as TEXT_ATTRIBUTE_IS_FREE in the language files.

Thatleads me to think about what settings have been chosen in the attribute manager and on the product relating to the price and free status. Then also in the product type. Further there may be something in the attributes.php file that constructs the text, but I haven't looked into it personally. Basically after doing a text search like I did to find a defined constant, then would search for how/where that constant is used to see what effects might exist by changing it and whether I needed to make some other adjustment (such as include or exclude a price in a price field, select a radio button somewhere, etc...) Hope that helps at least a little. I think for this one should also look in the faq about how to provide a free download product. Something isn't set right, but wish I could without playing with a cart tell you what is wrong.

21 May 2014, 9:53 PM
#86
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

mc12345678:

Forgive me, but I've forgotten how to address that specific issue, but can say that the attempted code change is definitely not the way to go. A few things: should get familiar with the developer's tool kit if not already, also krrp in minf that many ZC text items are built in parts. So I just did a search on is now: and found that said portion of text is defined as TEXT_ATTRIBUTE_IS_FREE in the language files.

Thatleads me to think about what settings have been chosen in the attribute manager and on the product relating to the price and free status. Then also in the product type. Further there may be something in the attributes.php file that constructs the text, but I haven't looked into it personally. Basically after doing a text search like I did to find a defined constant, then would search for how/where that constant is used to see what effects might exist by changing it and whether I needed to make some other adjustment (such as include or exclude a price in a price field, select a radio button somewhere, etc...) Hope that helps at least a little. I think for this one should also look in the faq about how to provide a free download product. Something isn't set right, but wish I could without playing with a cart tell you what is wrong.

Thanks for taking a look. I followed the FAQ and some advice from Paul on how to set up the free product download which got that working in the first instance. Digging around I can see now that whilst the product has been ticked as free (and you retain the normal default shipping settings) the problem appears to be with a secondary Free option selection in the Download Option itself (the blue box in the screen shot below). Switching this off removes the wording and and continues to allow downloads (so I'm guessing free product overrides this area somehow).

The main problem now will be that the way the site works under membership subscription the products will be free anyway so when I finally import the data across from OSC I presume that there will be a database table with a setting for this download attribute that I will need to mass change through SQL to stop the text appearing.

What is odd though is that when you define the download option in the first place there is no obvious setting that can be selected to switch these attributes on or off by default. I will take a look into the attributes_controller.php to see if there is a way that this can be set to off by default.

Thanks again

Attachment 14097

21 May 2014, 10:03 PM
#87
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

And thanks for the hint on the Developers Tool Kit ..... I tried that in All files and can see how it can really help :)

21 May 2014, 10:36 PM
#88
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Looking to migrate to ZenCart from OSC

DigiBooks:

Thanks for taking a look. I followed the FAQ and some advice from Paul on how to set up the free product download which got that working in the first instance. Digging around I can see now that whilst the product has been ticked as free (and you retain the normal default shipping settings) the problem appears to be with a secondary Free option selection in the Download Option itself (the blue box in the screen shot below). Switching this off removes the wording and and continues to allow downloads (so I'm guessing free product overrides this area somehow).

The main problem now will be that the way the site works under membership subscription the products will be free anyway so when I finally import the data across from OSC I presume that there will be a database table with a setting for this download attribute that I will need to mass change through SQL to stop the text appearing.

What is odd though is that when you define the download option in the first place there is no obvious setting that can be selected to switch these attributes on or off by default. I will take a look into the attributes_controller.php to see if there is a way that this can be set to off by default.

Thanks again

Attachment 14097

Again, while the code controls how everything works, sometimes it helps a little to step out of it. Take a look at the products/categories area, product types, then edit the layout of the product "types" that are in question. Towards the bottom of the list,and I hope this isn't because of something I had installed, because I forget what it was if I did, but towards the end of the list is:

PRODUCT Attribute is Free - Default
PRODUCT Attribute is Free
Attribute is Free When Product is Free
0= No 1= Yes

But, this is for the generation of new products, not necessarily an upload of product data. Yeah, umay need to run a sql statement (after backing up) or could use one of those spreadsheet programs that was described earlier in this thread. I'm not so sure you want to go about modifying the base code to "simplify" how the data is presented because of how it was (or possibly was) incorrectly entered for this application. Afterall, come next upgrade (seems pending) much of those changes would have to be reproduced. :/ instead if the data was right, then no change necessary. Just some thoughts.

Welcome on the dtk. Just one more tool to have for mods and quick lookups. I tend to abuse it rather than perform the targeted searches that it offers. :) I know, cpu time, extra information, etc... I learn something about the system almost every time I use it. :)

22 May 2014, 7:29 AM
#89
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

mc12345678:

Again, while the code controls how everything works, sometimes it helps a little to step out of it. Take a look at the products/categories area, product types, then edit the layout of the product "types" that are in question. Towards the bottom of the list,and I hope this isn't because of something I had installed, because I forget what it was if I did, but towards the end of the list is:

PRODUCT Attribute is Free - Default
PRODUCT Attribute is Free
Attribute is Free When Product is Free
0= No 1= Yes

But, this is for the generation of new products, not necessarily an upload of product data. Yeah, umay need to run a sql statement (after backing up) or could use one of those spreadsheet programs that was described earlier in this thread. I'm not so sure you want to go about modifying the base code to "simplify" how the data is presented because of how it was (or possibly was) incorrectly entered for this application. Afterall, come next upgrade (seems pending) much of those changes would have to be reproduced. :/ instead if the data was right, then no change necessary. Just some thoughts.

Welcome on the dtk. Just one more tool to have for mods and quick lookups. I tend to abuse it rather than perform the targeted searches that it offers. :) I know, cpu time, extra information, etc... I learn something about the system almost every time I use it. :)

Under my Product Types I don't have the three you listed so probably you did install something. Under the Attributes Controller the Download Free attribute button (blue) is checked (blue rather than a cross) and in the Attributes Flags it clearly says that Attribute is Free
When Product is Free: (Yes is checked); however this is the problem - when it is checked it will display "was £0.00 now is: Free" - when unchecked the text disappears. This leads me to the conclusion that if we select Free Product in the product setup the system automatically assumes that there was a price but at this time it is now free (makes sense). Because of the way we work that's the bit we don't need.

I will take a look in tpl_attributes.php because DTK is indicating that this is where it is probably attached to the end of "Zip File" and comment out this concatenation (and make a note for future release :) )

22 May 2014, 7:39 AM
#90
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

DigiBooks:

Under my Product Types I don't have the three you listed so probably you did install something. Under the Attributes Controller the Download Free attribute button (blue) is checked (blue rather than a cross) and in the Attributes Flags it clearly says that Attribute is Free
When Product is Free: (Yes is checked); however this is the problem - when it is checked it will display "was £0.00 now is: Free" - when unchecked the text disappears. This leads me to the conclusion that if we select Free Product in the product setup the system automatically assumes that there was a price but at this time it is now free (makes sense). Because of the way we work that's the bit we don't need.

I will take a look in tpl_attributes.php because DTK is indicating that this is where it is probably attached to the end of "Zip File" and comment out this concatenation (and make a note for future release :) )

That did it :)

in includes/modules/attributes.php

Line149:
// if product_is_free and product_attribute_is_free
if ($products_options->fields['product_attribute_is_free'] == '1' and $product_info->fields['product_is_free'] == '1') {
$products_options_display_price= TEXT_ATTRIBUTES_PRICE_WAS . $products_options->fields['price_prefix'] .
$currencies->display_price($new_attributes_price, zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . TEXT_ATTRIBUTE_IS_FREE;
} else {
// normal price

replaced with:

                  // if product_is_free and product_attribute_is_free
                  if ($products_options->fields['product_attribute_is_free'] == '1' and $product_info->fields['product_is_free'] == '1') {
                    //$products_options_display_price= TEXT_ATTRIBUTES_PRICE_WAS . $products_options->fields['price_prefix'] .
                    //$currencies->display_price($new_attributes_price, zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . TEXT_ATTRIBUTE_IS_FREE;

					// do nothing!

                  } else {
                    // normal price

Now I won't have to do any SQL on the incoming data!

Thanks again for pointing me in the right direction :)

22 May 2014, 7:42 PM
#91
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

Thanks for all the help here.

I'm getting there in the product displays but just wondered if there is another thing I can do .....

I know that for downloadable products I have to allow the attributes to be processed but I would really like to be able to switch off browser display of the download radio button (as per the screenshot) and still enable downloads .... is this possible please?

Attachment 14099

23 May 2014, 1:22 AM
#92
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Looking to migrate to ZenCart from OSC

Can we see it live? The /TESTBED is saying no database connection. It should be possible to do a CSS display: none; on that attribute without affecting function.

23 May 2014, 7:37 AM
#93
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

gjh42:

Can we see it live? The /TESTBED is saying no database connection. It should be possible to do a CSS display: none; on that attribute without affecting function.

Yes of course - I did move the folder because I fouled up initially and started again.

http://digibooks.org.uk/2014ZCtest

23 May 2014, 2:57 PM
#94
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Looking to migrate to ZenCart from OSC

There are two possibilities with the stock files.
Adding to your stylesheet ```
#attrib-1-1, #attrib-1-1+label {display: none;}


If this is the only attribute you have for any product (and you want to hide them all), just use ```
.wrapperAttribsOptions {display: none;}

If you need to get more selective, Flexible Attributes from Plugins gives class/id tags to every element so that you have total control of the attribute layout and display.

23 May 2014, 4:20 PM
#95
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

gjh42:

There are two possibilities with the stock files.
Adding to your stylesheet ```
#attrib-1-1, #attrib-1-1+label {display: none;}

> 
> If this is the only attribute you have for any product (and you want to hide them all), just use ```
.wrapperAttribsOptions {display: none;}

If you need to get more selective, Flexible Attributes from Plugins gives class/id tags to every element so that you have total control of the attribute layout and display.

Thank you very much ... I will take a look at this tonight :)

23 May 2014, 5:03 PM
#96
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

Again thanks - the: .wrapperAttribsOptions {display: none;} works perfectly!!!!

Every book is a download so it is not necessary for us to display this information as the membership knows this already.

There is still a lot I need to learn about CSS so I am really grateful for all your assistance :)

23 May 2014, 8:15 PM
#97
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

Hi all.

Sorry to be a pain and ask a really stupid question :/ but I'm a little green on the SQL querying aspect and had just got my head round the method used in OSC and I'm now a little stuck in Zencart!

In the new_products.php I want to display not just the book cover and title but the author (manufacturer) as well like I did in OSC. I know that I have to insert 'p.manufacturers_id' into this line:

$new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_status = 1 " . $display_limit;

in order to obtain the ID for the author in the manufacturers table. I know also that I then need to assign the authors name to a variable in the fashion:

		$new_manufacturer = ***SOMETHING***($new_products_query['manufacturers_id']);

I'm just not sure what the SOMETHING should be !!!! ( in OSC this line read: $new_manufacturer = tep_get_products_manufacturer($new_products['manufacturers_id']); )

Would someone be kind enough please to point me in the right direction for reading database tables in Zencart?

Thanks in advance

23 May 2014, 8:47 PM
#98
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

DigiBooks:

Hi all.

Sorry to be a pain and ask a really stupid question :/ but I'm a little green on the SQL querying aspect and had just got my head round the method used in OSC and I'm now a little stuck in Zencart!

In the new_products.php I want to display not just the book cover and title but the author (manufacturer) as well like I did in OSC. I know that I have to insert 'p.manufacturers_id' into this line:

$new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_status = 1 " . $display_limit;

in order to obtain the ID for the author in the manufacturers table. I know also that I then need to assign the authors name to a variable in the fashion:

  	$new_manufacturer = ***SOMETHING***($new_products_query['manufacturers_id']);

I'm just not sure what the SOMETHING should be !!!! ( in OSC this line read: $new_manufacturer = tep_get_products_manufacturer($new_products['manufacturers_id']); )

Would someone be kind enough please to point me in the right direction for reading database tables in Zencart?

Thanks in advance

I did try this: $new_manufacturer = zen_get_manufacturers($new_products_query['manufacturers_id']);

but just get the word 'Array' displayed

and: $new_manufacturer = zen_get_products_manufacturers_name($new_products_query['manufacturers_id']);

doesn't return anything.......

23 May 2014, 9:09 PM
#99
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

DigiBooks:

I did try this: $new_manufacturer = zen_get_manufacturers($new_products_query['manufacturers_id']);

but just get the word 'Array' displayed

and: $new_manufacturer = zen_get_products_manufacturers_name($new_products_query['manufacturers_id']);

doesn't return anything.......

I played around a bit and found the answer :)

		$new_manufacturer = zen_get_products_manufacturers_name($new_products->fields['products_id']);

Once you get a handle on ZC it's obvious that there are more well-thought out functions built in than OSC :)

24 May 2014, 9:47 AM
#100
digibooks avatar

digibooks

Zen Follower

Join Date:
May 2014
Location:
UK
Posts:
317
Plugin Contributions:
0

Re: Looking to migrate to ZenCart from OSC

Hi all.

I thought I might have achieved my first bit of real PHP programming but I've come unstuck a little somewhere :/

In the new books centre box I have already succeeded in adding the author's name below the book title, but I want to go one step further and also display the genre (category) thus:

A Winter's Tale
by
Trisha Ashley
(Chick Lit)

We operate on a maximum of three category/sub-category levels: Genre ==> Author ==> Series Name (Category ==> Sub-category ==> Sub-sub-category) so in the above example A Winter's Tale is stored in Chick-Lit ==> Trisha Ashley.

If I just use the standard function: zen_get_products_category_id then this would return as:

A Winter's Tale
by
Trisha Ashley
(Trisha Ashley)

so I am part-way through programming a top-level extraction function which is where it's gone a bit pear-shaped!

This book has a master category ID of 5 (Trisha Ashley) with a parent category ID of 4 (Chick-Lit).

In includes/modules/new_products.php I added this line:

		$new_category_master_id = zen_get_products_category_id($new_products->fields['products_id']);

this correctly returns $new_category_master_id as 5

going one step further to now try to extract the parent ID I added:

		$new_toplevel_genre_id = zen_get_toplevel_category_id($new_category_master_id);

and in /includes/functions/functions_lookups I added this function:

/* DB#1 BEGIN - extract the top-level genre

  • TABLES: categories
    */
    function zen_get_toplevel_category_id($this_category_id) {
    global $db;
    global $is_toplevel_category;
    global $this_parent_id;

    $is_toplevel_category = $this_category_id;
    $this_parent_id = 9;

    do {
    $the_toplevel_category_query = "select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . $is_toplevel_category . "'";
    $the_toplevel_category = $db->Execute($the_toplevel_category_query);

       $is_toplevel_category = $the_toplevel_category->fields['categories_id'];
       $this_parent_id = $the_toplevel_category->fields['parent_id'];
    

    } while ($this_parent_id >0);

    return $is_toplevel_category;
    }

/* END DB#1 */

Now I was hoping this function would keep looping until the parent_id resolves to 0 giving me the ID of the top level category - but it is just returning a null value.

Would somebody please be able to advise me where I have gone wrong?

Thanks in advance