VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: zaheer45 on October 07, 2012, 10:13:21 AM

Title: Product Name and custom fields
Post by: zaheer45 on October 07, 2012, 10:13:21 AM
Hello,
i am having a strange demand from customer. please help me
my customer have 12 digit numeric product id (it may be name or any custom field)
he want that he put complete twelve digit at backend when entering the product in VM.
but on front page it shows only last 6 digit of those twelve digits.
How it is possible?
any idea?
Title: Re: Product Name and custom fields
Post by: bytelord on October 07, 2012, 16:21:57 PM
Hello,

You could easy do it when id is echo' ing to change that code to print out only the 6 latest characters. You could use substr command for that in PHP, e.g.

$productid = "012345678910";
$length = strlen($productid);
$characters = 6;
$start = $length - $characters;
$productid = substr($productid , $start ,$characters);
echo $productid;  //Output 678910


or just use:
echo substr($productid ,6 , 6);

You can find more information here: http://php.net/manual/en/function.substr.php

The above is just a php code example

Regards


Title: Re: Product Name and custom fields
Post by: zaheer45 on October 16, 2012, 00:26:05 AM
Bundle of thnaks for your help but kindly tell me the exact place where i find that file.
Title: Re: Product Name and custom fields
Post by: bytelord on October 16, 2012, 12:11:46 PM
Hello,

The above is just an example how to use substr, you have to modified for the product id (what to you mean i suppose, something like product sku, not actual product id) and also you have to override all template files that echo'ing that product id (product details, category, etc) on the front end and also inside invoice template.

Regards
Title: Re: Product Name and custom fields
Post by: PolishedGeek on October 17, 2012, 03:18:52 AM
Will the full 12 digits need to show up on the order confirmation and PDF?  Is it being hidden just from searchbots and the general public on the frontend, or hidden from customers entirely?
Title: Re: Product Name and custom fields
Post by: zaheer45 on October 19, 2012, 18:06:51 PM
infect this is specific requirement, if a password of 12 or 14 digits if being sold, i need to show only first few or last few (say 4 or 6) digits, i want to display only short digit name, (anywhere if it fits, product id, sku number, or product name ), if i use product name as the digits and out 12 digits, i want to show 6 for all front end users, customemrs, but when i customer pay for the product i will have to provide full 12 digits
Title: Re: Product Name and custom fields
Post by: bytelord on October 19, 2012, 18:12:19 PM
Hello,

So, using substr is not cover you? You can used inside your templates folder for that specific custom field...

Why you don't try it?

Regards
Title: Re: Product Name and custom fields
Post by: shenlong2210 on August 24, 2015, 18:00:02 PM
<div class="product-name">
                     <h2>
                     <?php echo JHTML::link($product->link,shopFunctionsF::limitStringByWord($product->product_name, 20, '...')); ?></h2>
                  </div>

20 is maximum characters you can use.