Display category name instead of manufacturer name

Hello, I am trying to display the category name of a product, instead of its manufacturer.

I found the part of code where this should be replaced (it's located in func_draw.inc.php) but for some reason it doesn't display the way I would like it to.

'. (($product['manufacturer_name']) ? $product['manufacturer_name'] : ' ') .'' . PHP_EOL

So instead of> manufacturer_name

I want to display category name the product belongs to. Can you please assist me?

A product can be mounted in several categories. Do you wish to display them all or just the first one?

Sorry if I wasn't clear enough in my first post.

I am talking about any page where the products are being displayed. By default, underneath the product name, the manufacturer name is displayed. I want the category name instead of the manufacturer name. On all pages.

I've attached an image so you could understand me better.
In that case, ""Rubber Ducks"" should be displayed instead of ""ACME corp"".

Try the following vqmod. Place it in vqmod/xml/category_name_in_listing.xml


    Category Name In Listing
    1.0
    2.4.0
    litecart.net

            snippets = array(
      ]]>

             $product['manufacturer_name'],
      ]]>
             $first_category->name[language::$selected['code']],
      ]]>

      ]]>

      ]]>

Thank you for your quick response in this matter. I am using an older version of LiteCart (1.1.2) and don't have vqmod. I copied the files from the newer version of LiteCart regarding vqmod, and when I try to activate the XML file I get this error message

Fatal error: Call to undefined method document::ilink() in /home/lite/public_html/mainsite/admin/vqmods.app/vqmods.inc.php on line 14

Could you point me in the right direction, possibly without upgrading to a newer version?

Thank you!

The new 1.2 files are not compatible to patch just some files. You need a complete upgrade if you wanna benefit from 1.2 functionality.

Thank you for your responses. I eventually fixed it without having to upgrade to latest version.

I just added

$categories = explode(',', $product['categories']);
$first_category = new ref_category(array_shift($categories));

to the file func_draw.inc.php and also replaced the line of code where the manufacturer was being displayed like so:

'. $first_category->name[language::$selected['code']] .'' . PHP_EOL

:)

Þessum þræði hefur verið lokað vegna langrar óvirkni. Get ekki sent inn á það.
View code on GitHub