VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: ribo on January 20, 2021, 23:22:31 PM

Title: Display Sku in product details and in category view
Post by: ribo on January 20, 2021, 23:22:31 PM
Hello, i added in my template override the code <?php echo $product->product_sku ?> in category view of products and the <?php echo $this->product->product_sku ?> in product details. How can i add in these codes also and the language text of Sku Product?
I use joomla 3.9.24 Virtuemart 3.8.6 10373 and php 7.3.26 .
Title: Re: Display Sku in product details and in category view
Post by: Jörgen on January 21, 2021, 02:12:35 AM
Search the JOOMLA language override manager and You WILL find the keys to use. Search for SKU in language keys.

Jörgen @ Kreativ Fotografi
Title: Re: Display Sku in product details and in category view
Post by: ribo on January 21, 2021, 05:54:55 AM
Yes but where i must put the COM_VIRTUEMART_PRODUCT_SKU in the code ?
Title: Re: Display Sku in product details and in category view
Post by: ribo on January 21, 2021, 06:20:54 AM
I found the solution for product details here https://forum.virtuemart.net/index.php?topic=129510.msg445722#msg445722
But for products in category it is not work.
Title: Re: Display Sku in product details and in category view
Post by: Jörgen on January 21, 2021, 09:26:24 AM
If You refer to this line of code:
<?php echo '<span class="bold">'.JText::_("COM_VIRTUEMART_PRODUCT_SKU").'</span> : '.$this->product->product_sku?>

Add only the jText part :)

Presenting the SKU you say you already have figured out.

Jörgen
Title: Re: Display Sku in product details and in category view
Post by: ribo on January 21, 2021, 10:42:34 AM
This line is for in product details as <?php echo $this->product->product_sku ?> is work there but in category this is give error.
For category products this line <?php echo $product->product_sku ?> works but i am not able to use correctly the '<span class="bold">'.JText::_("COM_VIRTUEMART_PRODUCT_SKU").'</span> there
Title: Re: Display Sku in product details and in category view
Post by: Jörgen on January 21, 2021, 11:33:49 AM
You have to brush up your php skills. If in HTML mode then add <?php   ......  ?> and echo the function result.

Please read what echo does in PHP.net

https://www.php.net/manual/en/function.echo.php (https://www.php.net/manual/en/function.echo.php)

This is actually a PHP question nothing with JOOMLA or VM to do.

Jörgen
Title: Re: Display Sku in product details and in category view
Post by: Studio 42 on January 22, 2021, 09:38:23 AM
ribo in product details view
<?php echo '<span class="bold">'.JText::_("COM_VIRTUEMART_PRODUCT_SKU").'</span> : '.$this->product->product_sku; ?>
In the category
<?php echo '<span class="bold">'.JText::_("COM_VIRTUEMART_PRODUCT_SKU").'</span> : '.$product->product_sku; ?>
The category use sublayouts and need to be in
/templates/YOURTEMPLATE/html/com_virtuemart/sublayouts/products.php
Original virtuemart file is
/components/com_virtuemart/sublayouts/products.php