Author Topic: Product Name and custom fields  (Read 3030 times)

zaheer45

  • Beginner
  • *
  • Posts: 8
Product Name and custom fields
« 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?

bytelord

  • Nikos
  • Global Moderator
  • Full Member
  • *
  • Posts: 2369
Re: Product Name and custom fields
« Reply #1 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.

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

or just use:
Code: [Select]
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

  • Beginner
  • *
  • Posts: 8
Re: Product Name and custom fields
« Reply #2 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.

bytelord

  • Nikos
  • Global Moderator
  • Full Member
  • *
  • Posts: 2369
Re: Product Name and custom fields
« Reply #3 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
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

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 263
  • Joomla! Innovation Refined.
    • Polished Geek, LLC - Joomla! extensions, web development & custom integrations
Re: Product Name and custom fields
« Reply #4 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?
~ Deb Cinkus, CEO
Polished Geek, LLC   |    www.PolishedGeek.com

Creators of JoomLister - eBay Lister for Joomla!

zaheer45

  • Beginner
  • *
  • Posts: 8
Re: Product Name and custom fields
« Reply #5 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

bytelord

  • Nikos
  • Global Moderator
  • Full Member
  • *
  • Posts: 2369
Re: Product Name and custom fields
« Reply #6 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
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

  • Beginner
  • *
  • Posts: 12
Re: Product Name and custom fields
« Reply #7 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.