News:

Looking for documentation? Take a look on our wiki

Main Menu

Add text to product details in category page

Started by TaDrik, May 10, 2020, 16:13:15 PM

Previous topic - Next topic

TaDrik

Hello to all.

I need to add some custom text in product details when in category view for 2 cases.
1) I want to display a text when product is discontinued
2) I want to display a text when the product has a specific "Product Details Page" selected

Joomla 3.9.18 and virtuemart 3.6.10

I searced a lot in the forum and did not find something. Sorry if it is already posted

Jörgen

Make an override of layout, products.php  if I remember correctly
1, Check for the discontinued field in product data an do what you like.
2. Check for the view = productdetails and do what you like.

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

pinochico

Quote1) I want to display a text when product is discontinued

Yes, as wrote Jurgen, you must crreate override in template for product detail and check if product is discontinued then add custom text.
But correct is change a lot of more:

- hidden add to cart
- hidden price
- show info about discontinued
- hidden from search results - change core VM codes
- hidden from filtering results - change core VM codes
- hidden from all types of VM products modules - change core VM codes
- hidden form export for feeds (Google, another...)
- don't make off discontinued products - the best option, if you don't want create 404


This is original eshop, the one of big from Czech (not VM):

Seagate IronWolf Pro 6TB - discontinued product
https://www.alza.cz/seagate-ironwolf-pro-6tb-d5252575.htm
with text: We're sorry, but the sale is over

This is VM eshop from our development:
https://www.kolo-park.cz/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=20160&Itemid=596
with text: We're sorry, but the sale is over

Try search this product or filtering: SKU - 28330 on eshop www-kolo-park.cz


This solution for Discontinued products is the best and profesional :)
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

TaDrik

Thank you for your answers.

I have done the overide but I do not know the functions I need to call to make the php if rule.
Thats what I am asking for. Sorry for not making it clear from the beggining

Jörgen

#4
As Pinochico sais, it takes a bit coding, not very hard but it is ore than 5 minutes work to make it right.

Here are my examples

Discontinued product:
https://cms.kreativfotografi.se/index.php?option=com_virtuemart&lang=en&view=productdetails&virtuemart_product_id=2121&virtuemart_category_id=123&Itemid=125

Back in stock:
https://cms.kreativfotografi.se/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=2381&virtuemart_category_id=57&Itemid=515&lang=en

Preorder option:
https://cms.kreativfotografi.se/index.php?option=com_virtuemart&lang=en&view=productdetails&virtuemart_product_id=2275&virtuemart_category_id=144&Itemid=515


Bevare that back in stock and preorder are Time dependant and Will be reset automatically when the configurated Numbers of days has run out or stock is updated.


regards
Jörgen @ Kreativ Fotografi

Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

pinochico

#5

<?php 
if ((int)$this->product->product_discontinued == 1) {
//Your custom text for discontinued products

?>

www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

TaDrik

Thank you for your answer pinochico, but unfortunately the code does nothing.

Jörgen

Pinochicos code is a pattern to use, and You will have to insert Your own code where he showed.
It sounds like Your PHP skills are not upp to this, making the overrides we are talking about are quite easy, but not done in 5 min.
If You do not understand what Pinochico suggests You will better hire a programmer that makes the alterations in Your code. There will be more than one little line of.
You will have to insert snippets in several places in Your override to accomplish this. Or design a plugin that alters Your html if You want that kind of solution.
I think this is beyond the scope of free support. But you may find someone who is willing to do this for free.

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

TaDrik

I know some php code. I did the changes in the provided code (added an echo .... to show a message) added the code to the php file, but it does not show. Maybe the variable is not right? If someone givew me the 2 variables that I have to use, I can make the coding. Is there a catalog (updated) with the virtuemart fields and variables.

Thank you

Jörgen

#9
This is a living organism, there is no catalog, you have to check the code:


echo '<pre>';
echo '$this->product: </ br>';
print_r($this->product);
echo '$product: </ br>';
print_r($product);
echo '</pre>';


This is a start, as soon as you get the principle You will be able to investigate other variables, structures and arrays.
You should probably use $product->product_discontinued, depends on the context. The above code makes it visible;

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.