News:

Looking for documentation? Take a look on our wiki

Main Menu

Product Name and custom fields

Started by zaheer45, October 07, 2012, 10:13:21 AM

Previous topic - Next topic

zaheer45

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?

bytelord

#1
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


Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

zaheer45

Bundle of thnaks for your help but kindly tell me the exact place where i find that file.

bytelord

#3
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
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

PolishedGeek

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?
~ Deb Cinkus, CEO
Polished Geek, LLC   |    www.PolishedGeek.com

Creators of JoomLister - eBay Lister for Joomla!

zaheer45

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

bytelord

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
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

shenlong2210

<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.