Page 1 of 3 123 LastLast
Results 1 to 10 of 26
  1. #1
    Join Date
    Dec 2005
    Location
    Kalamazoo, MI
    Posts
    65
    Plugin Contributions
    0

    Default Sending order data to a script

    I'm looking to create a process where if a certain product is ordered, a function will be fired off to send specific order data to a web script, likely as post variables. In looking, it seems that perhaps an observer may be the way to go here, though there are quite a few related to checkout.
    First, am I on the right track with this? I would need to grab new orders as they came in, check to see if a specific item was included in the order, check the status to make sure it is set to processing meaning a payment was received, and then post the variables to the website script (customer name, E-mail address, etc.)

    Any guidance would be much appreciated.
    J.J. Meddaugh
    http://www.atguys.com

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

    Default Re: Sending order data to a script

    .

    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
    Dec 2005
    Location
    Kalamazoo, MI
    Posts
    65
    Plugin Contributions
    0

    Default Re: Sending order data to a script

    Great. This seems like it may work out. Will post back if I get stuck, which will probably be in about 6 minutes, grin.
    J.J. Meddaugh
    http://www.atguys.com

  4. #4
    Join Date
    Dec 2005
    Location
    Kalamazoo, MI
    Posts
    65
    Plugin Contributions
    0

    Default Re: Sending order data to a script

    I seem to have the simple part of this.
    <?php
    class orderNotifier extends base {
    function orderNotifier() {
    $this->attach($this, array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL'));
    }
    function update(&$Class, $notifier, $paramsArray) {
    // Code to look through the order
    }


    ?>
    Is there docs somewhere to show me where the info on the order would be? Would it be under $class or do I pull it from session variables? For example, I'm looking for customer name/email, status, and ids of products ordered.
    Thanks much.
    J.J. Meddaugh
    http://www.atguys.com

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

    Default Re: Sending order data to a script

    $class->info array
    and the
    $class->products multidimensional array

    If you use print_r() or var_dump() on those you'll see what they contain.
    .

    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.

  6. #6
    Join Date
    Dec 2005
    Location
    Kalamazoo, MI
    Posts
    65
    Plugin Contributions
    0

    Default Re: Sending order data to a script

    Quote Originally Posted by DrByte View Post
    $class->info array
    and the
    $class->products multidimensional array

    If you use print_r() or var_dump() on those you'll see what they contain.
    I tried adding the class and autoloader but this just makes my Shopping acrt and other pages show a blank page. Tried adding error_reporting E_all but this doesn't seem to help debug what's going on.

    Code:
    <?php
    class orderNotifier extends base {
    function orderNotifier() {
    $this->attach($this, array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL'));
    }
    function update(&$Class, $notifier, $paramsArray) {
    // Code to look through the order
    print_r($paramsArray);
    print_r($Class->info);
    print_r($Class->products);
    }
    }
    ?>
    and then this
    Code:
    <?php
    $autoLoadConfig[10][] = array('autoType'=>'class',
    'loadFile'=>'observers/class.orderNotifier.php');
    $autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
    'className'=>'orderNotifier',
    'objectName'=>'orderNotifier');
    ?>
    Thanks for your patience.
    J.J. Meddaugh
    http://www.atguys.com

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

    Default Re: Sending order data to a script

    error reporting is redirected: https://www.zen-cart.com/tutorials/index.php?article=82

    And you'll probably need to wrap a die() around your print_r outputs, since they need to be echoed and then execution halted in order to see anything.

    This is what I'll often do:

    die('info: <pre> ' . print_r($var1, true) . print_r($var2, true) . print_r($var3, true));
    .

    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
    Dec 2005
    Location
    Kalamazoo, MI
    Posts
    65
    Plugin Contributions
    0

    Default Re: Sending order data to a script

    Got it. I've got all of the product variables now along with order info from the info class. The only thing I'm not seeing in either of these is the customer data. Is this in a different class?
    J.J. Meddaugh
    http://www.atguys.com

  9. #9
    Join Date
    Dec 2005
    Location
    Kalamazoo, MI
    Posts
    65
    Plugin Contributions
    0

    Default Re: Sending order data to a script

    Nevermind, that would be $Class->customer (lucky guess). So I'm thinking I'm going to write the observer class to post several variables from each order to an external script and then let that script handle the order from there, so I don't have to fiddle with the observer class for each new case. Does this seem like a sane way to go? Will share my results when I'm done with this.
    J.J. Meddaugh
    http://www.atguys.com

  10. #10
    Join Date
    Dec 2005
    Location
    Kalamazoo, MI
    Posts
    65
    Plugin Contributions
    0

    Default Re: Sending order data to a script

    Hello. I am just about there, but getting a 500 server error when trying to send out the URL with CURL. I do have CURLSSL installed on the server and the rest of the script appears to check out codewise. I have it narrowed down to when my CURL function is being called. Didn't see a matching error in my Apache logs but perhaps I'm looking in the wrong spot.
    PHP Code:
    <?php
    class orderNotifier extends base {
    function 
    orderNotifier() {
    $this->attach($this, array('NOTIFY_ORDER_AFTER_SEND_ORDER_EMAIL'));
    }
    function 
    update(&$Class$notifier$paramsArray) {
    $num $paramsArray[0];
    $cust $Class->customer;
    $country urlencode($cust['country']['title']);
    foreach (
    $cust as $k => $v)
    if (!
    is_array($k))
    $cust[$k] = urlencode($v);
    $inf $Class->info;
    if (
    $inf['order_status'] == 1) {
    foreach(
    $Class->products as $prod) {
    $url 'http://www.mystore.com/blabla.php?num=' $num '&firstname=' $cust['firstname'] . '&lastname=' $cust['lastname'] . '&email=' $cust['email_address'] . '&company=' $cust['company'] . '&address=' $cust['street_address'] . '&city=' $cust['city'] . '&state=' $cust['state'] . '&postcode=' $cust['postcode'] . '&country=' $country '&telephone=' $cust['telephone'] . '&qty=' $prod['qty'] . '&prod_name=' urlencode($prod['name']) . '&id=' $prod['id'];
    submit_form($url);
    }
    }
    }
    function 
    submit_form($url) {
    $ch curl_init();
    curl_setopt($chCURLOPT_INTERFACE'my_ip');
    curl_setopt($chCURLOPT_URL$url);
    curl_setopt($chCURLOPT_TIMEOUT20);
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
    $data curl_exec($ch);
    }
    }
    ?>
    J.J. Meddaugh
    http://www.atguys.com

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. Custom Customer Data To Order Data
    By fotofx in forum General Questions
    Replies: 1
    Last Post: 22 Aug 2010, 08:10 PM
  2. Sending data back to opening window (greybox)
    By blackwolf in forum General Questions
    Replies: 0
    Last Post: 19 May 2010, 09:11 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