0

What I'm seeking to do is display the SKU of a product on the frontend of my Magento cart, which is working accurately with this code:

<?php echo $this->htmlEscape($_product->getSku()) ?>

However, what I need to do in addition to this is truncate the last character returned when the SKU is loaded on the front end. How can I achieve this with PHP, what code can I use to accomplish this, and how would I insert it into this string to truncate the last character from the output?

Thanks for any help in advance! :]

Jennii
  • 3
  • 1
  • 3

1 Answers1

0

To truncate the last character in a string call substr with -1 for the second parameter.

 <?php echo $this->htmlEscape(substr($_product->getSku(), 0, -1)) ?>
Orangepill
  • 24,500
  • 3
  • 42
  • 63