Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Jul 2005
    Location
    Charlottesville, VA
    Posts
    431
    Plugin Contributions
    0

    Default PhP question about a line of code in includes/classes/order.php

    Howdy.

    I really wasn't sure where to post this question. Perhaps a custom code questions forum is needed, for snippets like this? I reckon this is a code issue dealing with orders, so here goes.

    I want to reconcile a line that controls the HTML display of our custom purchase order module, with the new code that displays credit card type. I didn't get it to work in 1.3.6 and I still haven't gotten it to work in 1.3.7.

    Here's your code in includes/classes/order.php approx line 956
    $html_msg['PAYMENT_METHOD_FOOTER'] = (is_object($GLOBALS[$_SESSION['payment']] && $GLOBALS[$payment_class]->email_footer != '') ? $GLOBALS[$payment_class]->email_footer : $this->info['cc_type'] );
    Here's my code for displaying purchase order info in emails, invoices, browser, and packing slips. This works fine, but doesn't show credit card type:
    $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']) : ' ');
    How to mush these together? Each works on its own. I've tried a few variations in webmonkey manner, but I only get parsing errors.

    Bountiful thanks in advance to PHP code-knowledgeable persons.

    ---Diana

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: PhP question about a line of code in includes/classes/order.php

    If you set a $this->email_footer variable within your custom module to contain the required information, then the order class will display it automatically without having to be changed.
    Something like this might work?:
    Code:
    $this->email_footer = sprintf('Account: %s (%s) -- P/O number: %s', $this->info['account_name'], $this->info['account_number'], $this->info['po_number']);
    Maybe your $this->info references might need to change to $order->info ?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

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

    Default Re: PhP question about a line of code in includes/classes/order.php

    Hi, Dr. Byte!

    This is correctly configured in the PO module, I think.

    in includes/modules/payment/po.php
    in function po()

    Code:
    global $order;
    $this->email_footer = MODULE_PAYMENT_PO_TEXT_EMAIL_FOOTER;
    in includes/languages/english/modules/payment/po.php

    Code:
      define('MODULE_PAYMENT_PO_TEXT_EMAIL_FOOTER', 'with the following information:<br>
      Account name:&nbsp; &#37;s<br>
      Account number:&nbsp; %s<br>
      PO Number:&nbsp; %s');
    If I use the 1.3.7 includes/classes/order.php email footer line, I don't get the purchase order detail in the email, although it does display nicely on screen, in invoices and packing slips. But not in email, where we need it because our order fulfillment team uses the email order notification to collect detail.

    ... warning, webmonkey code to follow ...

    will this work?

    $html_msg['PAYMENT_METHOD_FOOTER'] = (is_object($GLOBALS[$_SESSION['payment']] && $GLOBALS[$payment_class]->email_footer != '') ? $GLOBALS[$payment_class]->email_footer : $this->info['cc_type'], $this->info['account_name'], $this->info['account_number'], $this->info['po_number'] );
    feh, it generated this error:
    Code:
    Parse error: parse error, unexpected ','
    ---Diana
    Last edited by dbrewster; 5 Jan 2007 at 03:28 PM.

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

    Default Re: PhP question about a line of code in includes/classes/order.php

    Progress to report!

    This gets the PO info into the email, but does NOT make a line feed between the data, it strings it together, which makes it hard to decipher.

    $html_msg['PAYMENT_METHOD_FOOTER'] = (is_object($GLOBALS[$_SESSION['payment']] && $GLOBALS[$payment_class]->email_footer != '') ? $GLOBALS[$payment_class]->email_footer : $this->info['cc_type'] . $this->info['account_name'] . "\n\n" . $this->info['account_number'] . "\n\n" . $this->info['po_number'] );
    I'm puzzled why . "\n\n" . isn't doing the job.

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

    Default Re: PhP question about a line of code in includes/classes/order.php

    after some more testing, I think I need sprintf for the PO email footer so that it is correctly formatted, with the right surrounding text strings defined in includes/languages/english/modules/payment/po.php. The email footer is supposed to look like this, and it does, using sprintf:

    Payment Method
    Purchase Order
    with the following information:
    Account name: Blah blah Charter School
    Account number: Pied02
    PO Number: 188945

    The problem: if I use sprintf I don't see how I can get the credit card type to display. I can't make two [FONT="Courier New"]$html_msg['PAYMENT_METHOD_FOOTER'] =[/FONT] statements in sequence, the second one overwrites the first.

    Actually this is a very minor problem, and I'm hoping there is a simple coding solution. If I have to choose, I won't use the 1.3.7 email payment info footer.

    Perhaps the question can be boiled down to: is there a way to string sprintf statements with this
    $GLOBALS[$payment_class]->email_footer : $this->info['cc_type']
    By the way, the following code works for line feeds in the footer:

    $html_msg['PAYMENT_METHOD_FOOTER'] = (is_object($GLOBALS[$_SESSION['payment']] && $GLOBALS[$payment_class]->email_footer != '') ? $GLOBALS[$payment_class]->email_footer : $this->info['cc_type'] . $this->info['account_name'] . "<br>" . $this->info['account_number'] . "<br>" . $this->info['po_number'] );
    Output looks like this:
    Payment Method
    Purchase Order
    TEST name
    TEST number
    TEST PO #

    it's the content without the formatting wrapper which only sprintf generates.

    ---Diana

  6. #6
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: PhP question about a line of code in includes/classes/order.php

    Quote Originally Posted by dbrewster View Post
    in includes/modules/payment/po.php
    in function po()

    Code:
    global $order;
    $this->email_footer = MODULE_PAYMENT_PO_TEXT_EMAIL_FOOTER;
    in includes/languages/english/modules/payment/po.php

    Code:
      define('MODULE_PAYMENT_PO_TEXT_EMAIL_FOOTER', 'with the following information:<br>
      Account name:&nbsp; &#37;s<br>
      Account number:&nbsp; %s<br>
      PO Number:&nbsp; %s');
    Why not change the po.php code from this:

    Code:
    global $order;
    $this->email_footer = MODULE_PAYMENT_PO_TEXT_EMAIL_FOOTER;
    to this:

    Code:
    global $order;
    $this->email_footer = sprintf(MODULE_PAYMENT_PO_TEXT_EMAIL_FOOTER, $this->info['account_name'],  $this->info['account_number'] , $this->info['po_number']);
    and this:
    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');
    to this:
    Code:
      define('MODULE_PAYMENT_PO_TEXT_EMAIL_FOOTER', 'with the following information:' . "\n" . '
      Account name:&nbsp; %s' . "\n" . '
      Account number:&nbsp; %s' . "\n" . '
      PO Number:&nbsp; %s');

    And then just fix the order class file to convert line-breaks to BR tags, like this:
    Code:
        $html_msg['PAYMENT_METHOD_FOOTER'] = (is_object($GLOBALS[$_SESSION['payment']] && $GLOBALS[$payment_class]->email_footer != '') ? $GLOBALS[$payment_class]->email_footer : $this->info['cc_type'] );
    becomes:
    Code:
        $html_msg['PAYMENT_METHOD_FOOTER'] = (is_object($GLOBALS[$_SESSION['payment']] && $GLOBALS[$payment_class]->email_footer != '') ? nl2br($GLOBALS[$payment_class]->email_footer) : $this->info['cc_type'] );
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

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

    Default Re: PhP question about a line of code in includes/classes/order.php

    Dr. Byte:

    Thank you so much for your code suggestion.

    I have tried it out, but it does not print a detailed footer in the email. All I get is

    Payment Method

    Purchase Order

    You're welcome to try it out on my test site, the PO pages and order.php page have been edited there according to your post, go ahead and place a purchase order and see the resulting email:

    http://register.coreknowledge.org

    (for comparison feel free to place a purchase order on my real website, that is set up the way I originally did it, that site is still 1.3.6, just please use the order motive field to indicate that this is a test, and comment that you are testing, so our customer care people don't get confused.)

    Invoice and packing slip still show the detail.

    It seems to me that only using sprintf and $this->info['account_name'], $this->info['account_number'], $this->info['po_number'] in order.php brings out the labels that are formatted in the language defines file.

    Note that the following does not work, either, but at least it does not generate an error:
    $html_msg['PAYMENT_METHOD_FOOTER'] = (is_object($GLOBALS[$_SESSION['payment']] && $GLOBALS[$payment_class]->email_footer != '') ? nl2br($GLOBALS[$payment_class]->email_footer, $this->info['account_name'], $this->info['account_number'], $this->info['po_number']) : $this->info['cc_type'] );
    ---Diana

  8. #8
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: PhP question about a line of code in includes/classes/order.php

    Where did you get your PO module from? Is it part of the super-orders contrib or otherwise?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

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

    Default Re: PhP question about a line of code in includes/classes/order.php

    Quote Originally Posted by DrByte View Post
    Where did you get your PO module from? Is it part of the super-orders contrib or otherwise?
    As I recall, I got it from Merlin. It's a hand-me-down from OSCommerce. I looked at Superorders, but it was a lot more code than I wanted to maintain, I just wanted a simple purchase order payment module. Although nice order reporting features would be nice, it wasn't a requirement for me, and I have enough extensions to maintain as it is.

    The PO module has received some updates along the way, from Absolute, as I began August 2005 with ZC 1.2.6.

    So, right now, if I maintain that orders.php line the way it was, it does what I want, but I see a divergence of code for the email footer in 1.3.7 and I wanted to stay current.

    It has to print out the order field detail with the labels for the fields in the email footer, for me to keep our customer service department happy.

    IMO ZC needs its own purchase order payment module.

    If you'd like to have a look at the PO module as it currently stands, send me a PM and I can send it to you in a zip. Y'all could include it in a ZC update!

    ---Diana

  10. #10
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: PhP question about a line of code in includes/classes/order.php

    guess what ... it's a bug

    Here's the fix ...
    http://www.zen-cart.com/forum/showth...535#post317535
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 9 Oct 2011, 06:24 AM
  2. Replies: 1
    Last Post: 28 Jul 2011, 07:43 PM
  3. Version help with admin/includes/classes/order.php
    By Brent in forum General Questions
    Replies: 2
    Last Post: 4 Jan 2011, 03:25 PM
  4. Warning: Division by zero in /includes/classes/shipping.php on line 94
    By keycraze in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 21 Sep 2008, 09:40 PM

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