Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Join Date
    Jun 2008
    Posts
    328
    Plugin Contributions
    0

    help question Extract Transaction's Customer Info to be written to a file?

    I would like to "intercept" a transaction's customer details, in order to write it to a text file.

    I know that this is possible (because customer information is in the database, accessible by Zen Cart's PHP scripts, and displayable accordingly), but I don't know what is the correct approach to implement it?

    Should I hack an existing PHP file to pipe this information to the text file?

    Or is there already a "hook" somewhere in Zen Cart that allows me to do that more cleanly and/or elegantly?

    Thanks,
    Daniel

  2. #2
    Join Date
    Jun 2008
    Posts
    328
    Plugin Contributions
    0

    Default What is the PHP page that SENDS order confirmation email?

    I would like to tap/hook into the PHP page that sends order confirmation email, so that I can retrieve customer information from there and write it to a temporary file.

    Where do I do that?

    Thanks,
    Daniel

  3. #3
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: What is the PHP page that SENDS order confirmation email?

    You can look in includes/modules/checkout_process.php about line 75

    Code:
    //send email notifications
    $order->send_order_email($insert_id, 2);
    $zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL');
    Zen-Venom Get Bitten

  4. #4
    Join Date
    Jun 2008
    Posts
    328
    Plugin Contributions
    0

    Default Re: What is the PHP page that SENDS order confirmation email?

    Quote Originally Posted by kobra View Post
    You can look in includes/modules/checkout_process.php about line 75

    Code:
    //send email notifications
    $order->send_order_email($insert_id, 2);
    $zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL');
    Thank you! I was mistakenly looking for it under /includes/modules/pages/checkout_process and I really needed this tip to know where to start. At least now I can start to see the light at the end of the tunnel.

    I understand that I now need to create a handler (observer class) for the NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL event, right?

    I think that the following tutorial can be helpful:

    http://www.zen-cart.com/wiki/index.p..._API_Tutorials

    Any other tips you can recommend?

    Perhaps there already is a handler/observer/hook in the contrib section that can save me the time of development and testing?

    Thanks,
    Daniel

  5. #5
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Extract Transaction's Customer Info to be written to a file?

    You should be on the correct track with that and the correct file to start with
    Zen-Venom Get Bitten

  6. #6
    Join Date
    Jun 2008
    Posts
    328
    Plugin Contributions
    0

    Idea or Suggestion Re: Extract Transaction's Customer Info to be written to a file?

    Quote Originally Posted by kobra View Post
    You should be on the correct track with that and the correct file to start with
    Thank you. After some learning, I managed to create an auto_loader config file in includes/auto_loader/ (first step required).

    Then, the file containing the actual intelligence of my mod, needs to be created. It's an observer class file in includes/classes/observers/ in which the main trick, IMHO, is to find the right object to attach. After some learning and research (with the help of DrByte, thank you!) I concluded that that object should be 'orders' (please correct if I am wrong). Thus, the resulting observer.writecustinfo.php looks like:
    PHP Code:
    <?php
    /**
     * Observer class to write customer info to a temp file.
     */
    class writecustinfo extends base {

     
    /**  constructor method !
       *  Attaches our class to the $orders class and watches for 1 notifier event.
       */
      
    function writecustinfo() {
        
    $orders->attach($this, array('NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL'));
      }

     
    /**   Actual Method to write data to file
       *  Called by observed class when any of our notifiable events occur
       *
       * @param object $class
       * @param string $eventID
       */
      
    function writetofile(&$class$eventID) {
        
    /**
        * Write the following fields to a file
        */

        
    orders->fields[orders_id];
        
    orders->fields[customers_id];
        
    orders->fields[customers_name];
        
    orders->fields[customers_company];
        
    orders->fields[customers_street_address];
        
    orders->fields[customers_suburb];
        
    orders->fields[customers_city];
        
    orders->fields[customers_postcode];
        
    orders->fields[customers_state];
        
    orders->fields[customers_country];
        
    orders->fields[customers_telephone];
        
    orders->fields[customers_email_address];
        
    orders->fields[customers_address_format_id];
        
    orders->fields[delivery_name];
        
    orders->fields[delivery_company];
        
    orders->fields[delivery_street_address];
        
    orders->fields[delivery_suburb];
        
    orders->fields[delivery_city];
        
    orders->fields[delivery_postcode];
        
    orders->fields[delivery_state];
        
    orders->fields[delivery_country];
        
    orders->fields[delivery_address_format_id];
        
    orders->fields[billing_name];
        
    orders->fields[billing_company];
        
    orders->fields[billing_street_address];
        
    orders->fields[billing_suburb];
        
    orders->fields[billing_city];
        
    orders->fields[billing_postcode];
        
    orders->fields[billing_state];
        
    orders->fields[billing_country];
      }
    }
    ?>
    Does the above make sense at all?

    Do you identify fundamental flaws in the code or in my understanding of the process?

    (for simplicty, I didn't include the actual file writing code, I will start working on it shortly).

    Thanks,
    Daniel

  7. #7
    Join Date
    Jan 2004
    Posts
    66,419
    Blog Entries
    7
    Plugin Contributions
    277

    Default Re: Extract Transaction's Customer Info to be written to a file?

    That is the concept, yes
    .

    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.

  8. #8
    Join Date
    Jun 2008
    Posts
    328
    Plugin Contributions
    0

    Idea or Suggestion Re: Extract Transaction's Customer Info to be written to a file?

    Quote Originally Posted by DrByte View Post
    That is the concept, yes
    Concepts are great but when it comes to real life...

    When I tried to implement the above using $orders->attach(), the entire store blanked! This puzzled me for a moment since the 'freeProduct' example in the Developers API Tutorial works on my system without any problem (or modification).

    At first, I tried changing the $autoLoadConfig offset (aka 'action point'), in the config file, from 90 to 210, thinking that perhaps this has to do with the fact that $orders is not instantiated until offset 180. That didn't help (same exact white blank page).

    So, after some research I came across this excellent thread: Use Of Notifiers - How To.

    I then realized that, despite having different symptoms, I probably have the same exact problem: attempting to use a class ($orders) instead of the 'stub' notifier class, $zco_notifier. It is also the class that actually sends the notification. That solved the blanking problem!

    So, I can now start working on the actual functionality of this observer.

  9. #9
    Join Date
    Jun 2008
    Posts
    328
    Plugin Contributions
    0

    Default Re: Extract Transaction's Customer Info to be written to a file?

    OK, I got the update() method of the observer class to act upon email confirmation and to write something to a test text file.

    The only problem now is that... all $orders->fields[] elements seem to be empty.

    Using SuperGlobals Plus I can see at the successful checkout page that the $orders->fields[] elements are there and contain valid and correct values. So it seems that by the time my observer class receives the NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL notification, the $orders->fields[] array has gone???

    I will try tying my observer class to NOTIFY_HEADER_START_CHECKOUT_SUCCESS to see if I can intercept that $orders->fields ...

    Thanks again Kobra & DrByte for all your help and guidance. It's fun to program in such great environment.

    Daniel

  10. #10
    Join Date
    Jan 2004
    Posts
    66,419
    Blog Entries
    7
    Plugin Contributions
    277

    Default Re: Extract Transaction's Customer Info to be written to a file?

    Isn't the object named $order, not $orders ?
    .

    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: 7 Jun 2010, 03:22 AM
  2. which file inserts customer info in DB?
    By g_force in forum Managing Customers and Orders
    Replies: 6
    Last Post: 12 Feb 2010, 08:11 PM
  3. Storing order/customer info in a flat file
    By mithaimate in forum General Questions
    Replies: 0
    Last Post: 30 Sep 2009, 10:29 AM
  4. What file holds all the order and customer info ?
    By snarkys in forum Managing Customers and Orders
    Replies: 3
    Last Post: 19 Nov 2006, 12:26 PM
  5. Can I extract a customer list???
    By Honeysmom in forum General Questions
    Replies: 2
    Last Post: 12 Jul 2006, 02:28 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