Results 1 to 4 of 4
  1. #1
    Join Date
    May 2006
    Location
    Charlottesville, VA
    Posts
    1
    Plugin Contributions
    0

    Configure newline in PHP sprintf statement

    Hi!

    I'm using Merlin's purchase order module, and I have it working fine, except that I would like a newline in the email output, so that you see

    Payment Method
    Purchase Order
    with the following information:
    Account name: TESTING
    Account number: TESTING
    PO Number: TESTING

    I've edited includes/classes/order.php thus:
    Code:
    $html_msg['PAYMENT_METHOD_FOOTER'] = 
    (is_object($GLOBALS[$_SESSION['payment']]) ? 
    sprintf($GLOBALS[$payment_class]->email_footer, $this->info['account_name'], 
    "\n\n", $this->info['account_number'], "\n\n",    $this->info['po_number']) : '');
    However, this results in email output like this:
    Payment Method
    Purchase Order
    with the following information: Account name: TESTING Account number: PO Number: TESTING

    Before the message boards were archived, I receive these replies:

    From Dr. Byte:
    shouldn't those be . instead of , in that code for your \n\n additions?
    I tried
    Code:
    $html_msg['PAYMENT_METHOD_FOOTER'] = 
    (is_object($GLOBALS[$_SESSION['payment']]) ? 
    sprintf($GLOBALS[$payment_class]->email_footer, $this->info['account_name'] . 
    "\n\n" . $this->info['account_number'] . "\n\n" . $this->info['po_number']) : 
    '');
    but that produced a PHP error about too few arguments. My reference for PHP says that sprintf does use commas to separate elements of the string, not periods. What is the correct syntax for putting a newline into an sprintf statement? I see there is a PHP nl2br() function. Perhaps I need to insert
    Code:
    <? echo nl2br($payment_class); ?>
    ? But I don't believe that these purchase order fields are coded as part of $payment_class, that is why the sprintf function has to be spelled out for each field.

    Perhaps a PHP programmer would kindly show me the correct format.

    I also got this reply from Richard Fink:
    It would be easier if you modify the text template/define called PAYMENT_METHOD_FOOTER.

    Just add the line breaks there. If you don't know where it is located, search with the developeres toolkit.
    The only place I found where PAYMENT_METHOD_FOOTER is defined is in order.php. Because purchase order is an add-on payment module with extra fields, there doesn't seem to be a way to create a default configuration for it other than adding a line to force the print, as I am trying to do. If I leave out the sprintf statement for account_name, account_number, and po_number it just doesn't get printed in the email.

    ---Diana

  2. #2
    Join Date
    Jul 2005
    Location
    Charlottesville, VA
    Posts
    431
    Plugin Contributions
    0

    Default Re: Configure newline in PHP sprintf statement

    After more hunting and experimentation, I've come up with a solution, hooray! Richard Fink had the right idea but I had to stumble around to find it.

    includes/languages/english/modules/payment/po.php

    the original code:
    Code:
     define('MODULE_PAYMENT_PO_TEXT_EMAIL_FOOTER', 'with the following information:
     Account name:&nbsp; %s
     Account number:&nbsp; %s
     PO Number:&nbsp; %s');
    My edit to insert newlines (just HTML breaks as it turns out)
    Code:
    define('MODULE_PAYMENT_PO_TEXT_EMAIL_FOOTER', 'with the following information:<br>
     Account name:&nbsp; %s<br>
     Account number:&nbsp; %s<br>
     PO Number:&nbsp; %s');
    This line in includes/classes/order.php stays like this (no overrides system it seems for this file?)
    Code:
    	$html_msg['PAYMENT_METHOD_FOOTER'] = 
    (is_object($GLOBALS[$_SESSION['payment']]) ? 
    sprintf($GLOBALS[$payment_class]->email_footer, $this->info['account_name'], 
    $this->info['account_number'], $this->info['po_number']) : ' ');
    Added the space between the two quotes at the end.

    I'm posting this so other people using this module can see this adaptation for ZC 1.3.

    ---Diana

  3. #3
    Join Date
    Feb 2007
    Posts
    2
    Plugin Contributions
    0

    email error Re: Configure newline in PHP sprintf statement

    I am wondering what version of zen cart you did this modification to, I have the lastest 1.3.7 and in the files you described here do not match the default.

    I was wondering if you could be a bit more clear on the instructions, I know call me blond or a bit dim or what ever LOL , I understand what your talking about I just don't see the matches in the default files you mention in your instuctions.

    Thanks
    Matt...

    Quote Originally Posted by dbrewster View Post
    After more hunting and experimentation, I've come up with a solution, hooray! Richard Fink had the right idea but I had to stumble around to find it.

    includes/languages/english/modules/payment/po.php

    the original code:
    Code:
     define('MODULE_PAYMENT_PO_TEXT_EMAIL_FOOTER', 'with the following information:
     Account name:&nbsp; %s
     Account number:&nbsp; %s
     PO Number:&nbsp; %s');
    My edit to insert newlines (just HTML breaks as it turns out)
    Code:
    define('MODULE_PAYMENT_PO_TEXT_EMAIL_FOOTER', 'with the following information:<br>
     Account name:&nbsp; %s<br>
     Account number:&nbsp; %s<br>
     PO Number:&nbsp; %s');
    This line in includes/classes/order.php stays like this (no overrides system it seems for this file?)
    Code:
        $html_msg['PAYMENT_METHOD_FOOTER'] = 
    (is_object($GLOBALS[$_SESSION['payment']]) ? 
    sprintf($GLOBALS[$payment_class]->email_footer, $this->info['account_name'], 
    $this->info['account_number'], $this->info['po_number']) : ' ');
    Added the space between the two quotes at the end.

    I'm posting this so other people using this module can see this adaptation for ZC 1.3.

    ---Diana

  4. #4
    Join Date
    Jan 2007
    Posts
    149
    Plugin Contributions
    1

    Default Re: Configure newline in PHP sprintf statement

    Last post on this thread was an un answered question. anyone know what the fix would be for the 1.3.7 version. I too am not getting the po info in the admin email and the customers email confirmation also not showing the po info?

    Thanks,
    Slabadoo

 

 

Similar Threads

  1. Can't rename dist-configure.php because there is already a configure.php
    By mamasylvia in forum Installing on a Linux/Unix Server
    Replies: 1
    Last Post: 17 Mar 2008, 06:57 AM
  2. Replies: 1
    Last Post: 10 Feb 2008, 04:26 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR