theisurgeon Posted August 30, 2013 Share Posted August 30, 2013 My shipping software .php file pulls notes in from Magento. Problem is, after a certain number of "note" characters, the invoice does not print properly on my thermal printer (not sure the character limit, so I will need to use trial-by-error. I am assuming there should be an easy string limiter code to cut the excess characters and possibly append an ellipsis? Please help! writeStartTag("Notes"); // check for order-level gift messages if ($order->getGiftMessageId()) { $message = Mage::helper('giftmessage/message')->getGiftMessage($order->getGiftMessageId()); $messageString = "Gift message for ". $message['recipient']. ": ". $message['message']; if (trim($message['recipient']) != '') { writeFullElement("Note", $messageString, array("public" => "true")); } } $orderComments = $order->getAllStatusHistory(); foreach ($orderComments as $comment) { $body = $comment->getData('comment'); if ($body != '' && strpos($body, 'Order imported from') === false) { writeFullElement("Note", "*** Buyer message: $body", array("public" => "true")); } } writeCloseTag("Notes"); Link to comment https://forums.phpfreaks.com/topic/281694-variable-call-character-limit-per-line/ Share on other sites More sharing options...
Andy-H Posted August 30, 2013 Share Posted August 30, 2013 strlen substr $max_length = 50; $ellipsis = '...'; if ( strlen($mystring) > ($max_length + strlen($ellipsis)) ) { $mystring = substr($mystring, 0, $max_length) . $ellipsis; } Link to comment https://forums.phpfreaks.com/topic/281694-variable-call-character-limit-per-line/#findComment-1447432 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.