Jump to content

Show extra information about each product on the products page


ahmed salah

Recommended Posts

3 hours ago, ahmed salah said:

I'm trying to add some extra information to show it to user on the website. i tried to read about custom filed but i didn't understand it well. for example if i want to add tags to each product and then display it on the website, how can i do it ?

you might need to be more specific, e.g with screenshots, as to where this info is to be shown... do you mean on the product/servicess table, or in product details ??

Link to comment
Share on other sites

17 hours ago, brian! said:

you might need to be more specific, e.g with screenshots, as to where this info is to be shown... do you mean on the product/servicess table, or in product details ??

Thank you for your replay, specifically i need to show it in the product details when the user open the websites 

Capture55.JPG

Link to comment
Share on other sites

52 minutes ago, ahmed salah said:

specifically i need to show it in the product details when the user open the websites 

what's the information you need to show??

  • if it's additional information for each product, then editing the product description in the admin area would be the simplest way...
  • if it's additional product group details, then using product group features might work if the template supports outputting them. - though any template could be redesigned to show them if required.
  • I don't think you would show custom fields at that early stage of the ordering process..
Link to comment
Share on other sites

48 minutes ago, brian! said:

what's the information you need to show??

  • if it's additional information for each product, then editing the product description in the admin area would be the simplest way...
  • if it's additional product group details, then using product group features might work if the template supports outputting them. - though any template could be redesigned to show them if required.
  • I don't think you would show custom fields at that early stage of the ordering process..

For example i want to add product name in Arabic Lang, or add some tags to the product like the Most popular plan. in the product description i just write the product specifications (details).

Link to comment
Share on other sites

1 hour ago, ahmed salah said:

For example i want to add product name in Arabic Lang

instead of the English name, or both to be shown at the same time??

if instead, Product names and details can be shown in multiple languages, so if the user can choose a language, the product details will be shown in that language..

if you need to show both together, then that's really a template edit... possibly you could use a hook, but either could mess with your layout if done incorrectly.

1 hour ago, ahmed salah said:

or add some tags to the product like the Most popular plan.

if you're lucky, the template that you're using might already have that visual option for products that are marked as "featured" in their setup....

8JhAkMp.png

depending on the template, products with the Feature checkbox ticked, can display a "Most Popular" strapline/ribbon... but this only works if the template is designed to utilise the option.

from that screenshot, I assume that you're using a custom template - so possibly it's worth asking it's developer whether the feature already exists in the template to do this.

Link to comment
Share on other sites

1 hour ago, brian! said:

instead of the English name, or both to be shown at the same time??

if instead, Product names and details can be shown in multiple languages, so if the user can choose a language, the product details will be shown in that language..

if you need to show both together, then that's really a template edit... possibly you could use a hook, but either could mess with your layout if done incorrectly.

if you're lucky, the template that you're using might already have that visual option for products that are marked as "featured" in their setup....

8JhAkMp.png

depending on the template, products with the Feature checkbox ticked, can display a "Most Popular" strapline/ribbon... but this only works if the template is designed to utilise the option.

from that screenshot, I assume that you're using a custom template - so possibly it's worth asking it's developer whether the feature already exists in the template to do this.

really this is easy for translation, i did a lot of work to translate it on my way.  but i tried it and no results appear for on the product page. 

Quote

from that screenshot, I assume that you're using a custom template - so possibly it's worth asking it's developer whether the feature already exists in the template to do this.

I'm the developer of the theme and i'm confusing how to do it (Most Popular Tag),  i'm working on Six Theme 

Capture.JPG

Link to comment
Share on other sites

10 minutes ago, ahmed salah said:

i did a lot of work to translate it on my way.  but i tried it and no results appear for on the product page. 

what should happen if you've translated the product field is that it will show the product name in your default language - but if you switch to using Arabic, it should switch to using the Arabic translation that you entered.

if your orderform template is not doing that, then there is an issue with the coding - probably outdated template code.

10 minutes ago, ahmed salah said:

I'm the developer of the theme and i'm confusing how to do it (Most Popular Tag),  i'm working on Six Theme 

the Six theme is not the important part - it's the orderform template, assuming that first screenshot is the products.tpl template, where the problem lies.

Edited by brian!
Link to comment
Share on other sites

14 hours ago, brian! said:

what should happen if you've translated the product field is that it will show the product name in your default language - but if you switch to using Arabic, it should switch to using the Arabic translation that you entered.

if your orderform template is not doing that, then there is an issue with the coding - probably outdated template code.

the Six theme is not the important part - it's the orderform template, assuming that first screenshot is the products.tpl template, where the problem lies.

The above screenshot is from the Homepage where is display my products using Hooks.

Quote

 

if your orderform template is not doing that, then there is an issue with the coding - probably outdated template code.


 

 

It's working good on orderform, so the name is not displayed only on the pages i made.

Edited by ahmed salah
Link to comment
Share on other sites

4 hours ago, ahmed salah said:

The above screenshot is from the Homepage where is display my products using Hooks.

and you never thought to mention that before ?????? 🙄

4 hours ago, ahmed salah said:

It's working good on orderform, so the name is not displayed only on the pages i made.

then in some ways the situation is even simpler for you - you just use to get the hook to create the array however you want the output to be - so if you need product translations, you pull them from the tbldynamic_translations table, if it's to mark a product as "featured", then you alter the output in the template if the featured option for that product is enabled...

Link to comment
Share on other sites

11 minutes ago, brian! said:

and you never thought to mention that before ?????? 🙄

then in some ways the situation is even simpler for you - you just use to get the hook to create the array however you want the output to be - so if you need product translations, you pull them from the tbldynamic_translations table, if it's to mark a product as "featured", then you alter the output in the template if the featured option for that product is enabled...

Quote

 

and you never thought to mention that before ??????


 

 

Sorry for that i thought it doesn't matter where the product showed. 

Quote

 so if you need product translations, you pull them from the tbldynamic_translations table, if it's to mark a product as "featured", then you alter the output in the template if the featured option for that product is enabled...

What should i edit at my hook file, i'm using the regular way to output the product i get them from the  

function homepage_products_hook($vars) {

   $client = Menu::context('client');

   $products = Capsule::table('tblproducts')
                       ->join('tblpricing', 'tblproducts.id', '=', 'tblpricing.relid')
                       ->select('tblproducts.*','tblpricing.*')
                       ->where('tblpricing.type', 'product')
                       ->where('tblproducts.hidden','0')
                       ->where('tblproducts.gid','1')
                       ->groupBy('tblproducts.order')
                       ->get();
   foreach ($products as $data)
   {
      echo $data->normalPrice;
   }
   $encodedata = json_encode($products);
   
   $decodedata = json_decode($encodedata, true);
   return array("myproducts" => $decodedata);
}

 

Link to comment
Share on other sites

4 hours ago, ahmed salah said:

Sorry for that i thought it doesn't matter where the product showed. 

it matters in that I need to know how it's being generated... I had assumed from that screenshot that it was in the cart.

4 hours ago, ahmed salah said:

What should i edit at my hook file, i'm using the regular way to output the product i get them from the  

I recognise that hook, I wrote it years ago...

if we take a similar hook, which is almost identical to yours except i'm only returning 4 values per product, not the entire two tables, then we can loop through the results, and insert an Arabic translation of the product name (but only if one exists) into the array and return it to the template..

<?php

use WHMCS\Database\Capsule;

function homepage_products_hook($vars)
{
	$products = Capsule::table('tblproducts')
			->join('tblpricing', 'tblproducts.id', '=', 'tblpricing.relid')
			->where('tblpricing.type', 'product')
			->where('tblproducts.hidden','0')
			->where('tblproducts.gid','1')	
			->select('tblproducts.id','tblproducts.name','tblproducts.description','tblpricing.monthly')
			->orderBy('tblproducts.order')						
			->groupBy('tblproducts.id')
			->get();
	$results = json_decode(json_encode($products), true);
	foreach($results as $key => $product) {
		$productname_translation = Capsule::table('tbldynamic_translations')->where('related_id',$product['id'])->where('language','arabic')->value('translation');
		if ($productname_translation) {
			$results[$key]['product_name_translation'] = $productname_translation;
		}
	}		
	return array("myproducts" => $results);
}
add_hook("ClientAreaPageHome", 1, "homepage_products_hook");
?>

9K7GrZk.png

if you're going to return all the values from both tables in the query....

->select('tblproducts.*','tblpricing.*')

then the translation line code becomes...

$productname_translation = Capsule::table('tbldynamic_translations')->where('related_id',$product['relid'])->where('language','arabic')->value('translation');
Edited by brian!
Link to comment
Share on other sites

20 hours ago, brian! said:

it matters in that I need to know how it's being generated... I had assumed from that screenshot that it was in the cart.

I recognise that hook, I wrote it years ago...

if we take a similar hook, which is almost identical to yours except i'm only returning 4 values per product, not the entire two tables, then we can loop through the results, and insert an Arabic translation of the product name (but only if one exists) into the array and return it to the template..


<?php

use WHMCS\Database\Capsule;

function homepage_products_hook($vars)
{
	$products = Capsule::table('tblproducts')
			->join('tblpricing', 'tblproducts.id', '=', 'tblpricing.relid')
			->where('tblpricing.type', 'product')
			->where('tblproducts.hidden','0')
			->where('tblproducts.gid','1')	
			->select('tblproducts.id','tblproducts.name','tblproducts.description','tblpricing.monthly')
			->orderBy('tblproducts.order')						
			->groupBy('tblproducts.id')
			->get();
	$results = json_decode(json_encode($products), true);
	foreach($results as $key => $product) {
		$productname_translation = Capsule::table('tbldynamic_translations')->where('related_id',$product['id'])->where('language','arabic')->value('translation');
		if ($productname_translation) {
			$results[$key]['product_name_translation'] = $productname_translation;
		}
	}		
	return array("myproducts" => $results);
}
add_hook("ClientAreaPageHome", 1, "homepage_products_hook");
?>

9K7GrZk.png

if you're going to return all the values from both tables in the query....


->select('tblproducts.*','tblpricing.*')

then the translation line code becomes...


$productname_translation = Capsule::table('tbldynamic_translations')->where('related_id',$product['relid'])->where('language','arabic')->value('translation');

Thank you, you always save the day 🙂, i edited the code to fetch the translated description also  with the name.

function linux_product_hook($vars)
{
	$products = Capsule::table('tblproducts')
			->join('tblpricing', 'tblproducts.id', '=', 'tblpricing.relid')
			->where('tblpricing.type', 'product')
			->where('tblproducts.hidden','0')
			->where('tblproducts.gid','1')	
			->select('tblproducts.id','tblproducts.name','tblproducts.description','tblpricing.monthly')
			->orderBy('tblproducts.order')						
			->groupBy('tblproducts.id')
			->get();
   $results = json_decode(json_encode($products), true);
   	
	foreach($results as $key => $product) {
      $product_translation = Capsule::table('tbldynamic_translations')
      ->where('related_id',$product['id'])
      ->where('language','arabic')
      ->select('tbldynamic_translations.translation')
      ->get();

      // print_r($product);

		if ($product_translation) {
         $results[$key]['product_name_translation'] = $product_translation[0];
         $results[$key]['product_desc_translation'] = $product_translation[1];
      }
   }

      return array("linux_product" => $results);
}

This will return the translation array which contains tow array one for the name and the second for the description. and then pull them to the $result array.

Thank you. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated