Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2016
    Location
    Orem Utah
    Posts
    8
    Plugin Contributions
    0

    Default Tracking and Order Status Program

    I have been creating a program to update order status and send a tracking email. It is working but it sends multiple emails when it should only send one. Here is a sample of the code:

    $trackingOnly =
    Array
    (
    [48462] => Tracking Number 4206043594055102008303
    [48461] => Tracking Number 42089445940011020083
    [48460] => Tracking Number 420195209400110200
    [48458] => Tracking Number 4208021894055102
    [48457] => Tracking Number 1Z67V75V03
    )

    $PWinvoiceEmailsAll =
    Array
    (
    [48464] => Array
    (
    [fullname] => Ebinezer Hoodamackie
    [date] => Wednesday 2 November, 2016
    [email] => emailaddress######################
    [status] => 1
    [notified] => 1
    )

    [48463] => Array
    (
    [fullname] => George Washington
    [date] => Wednesday 2 November, 2016
    [email] => emailaddress######################
    [status] => 1
    [notified] => 1
    )
    )


    foreach($trackingOnly as $orderNum => $trackingComment)
    {
    foreach($PWinvoiceEmailsAll as $orderPW => $arrayPW)
    {
    if($orderNum == $orderPW)
    {
    $queryB = "INSERT INTO orders_status_history (orders_id,orders_status_id,date_added,customer_notified,comments)
    VALUES ($orderNum,3,NOW(),1,'$trackingComment')";

    $queryC = "UPDATE orders
    SET orders_status=3
    WHERE orders_id=$orderNum";

    odbc_exec($connectA,$queryB);
    odbc_exec($connectA,$queryC);


    //send email to customer

    $dateToPost = $arrayPW['date'];
    $nameToPost = $arrayPW['fullname'];
    $orderToPost = $orderNum;
    $emailToPost = $arrayPW['email'];
    $trackingToPost = $trackingComment;

    $message = 'date='.$dateToPost.'&name='.$nameToPost.'&order='.$orderToPost.'&email='.$email ToPost.'&tracking='.$trackingToPost;

    $ch = curl_init("http://www.companyname.com/test.php");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
    curl_exec($ch);
    curl_close($ch);

    }
    }
    }

    And here is the file it posts to:

    require('includes/application_top.php');
    include('/includes/functions/functions_email.php');

    $date = $_POST['date'];
    $name = $_POST['name'];
    $order = $_POST['order'];
    $email = $_POST['email'];
    $tracking = $_POST['tracking'];

    $message="Order Number: $order\n\nDetailed Invoice: http://www.companyname.com/index.php?main_page=account_history_info&order_id=$order\n\nDate Ordered: $date\n\nThe comments for your order are: $tracking\n\nYour order has been updated to the following status:\nNew status: Shipped\n\nPlease reply to this email if you have any questions.\n\n\n";

    zen_mail($name,$email,"Order Update #$order",$message,"Company Name","[email protected]");


    Can anyone tell me what I am doing wrong?

  2. #2
    Join Date
    Dec 2008
    Location
    New Zealand
    Posts
    88
    Plugin Contributions
    1

    Default Re: Tracking and Order Status Program

    Sorry, not able to help you with your code problem, but is there a reason you are not using Ty Package Tracker?

    https://www.zen-cart.com/downloads.php?do=file&id=75

    I have it installed & it works well - it should be a deault part of zc imho!

  3. #3
    Join Date
    Oct 2016
    Location
    Orem Utah
    Posts
    8
    Plugin Contributions
    0

    Default Re: Tracking and Order Status Program

    The reason I don't use this package tracker is that our site is a wholesale site and often products are shipped in large quantities with large freight carriers and the tracking is entered manually in our warehouse inventory program.

    So my program grabs data from the inventory program database and updates the status and tracking based on when the warehouse guys enters the numbers. The website does not actually handle any payments. We import them into the warehouse inventory program.

  4. #4
    Join Date
    Dec 2008
    Location
    New Zealand
    Posts
    88
    Plugin Contributions
    1

    Default Re: Tracking and Order Status Program

    Makes sense, thought that you might be reinventing the wheel because you hadn't seen the existing mod. Not that I would have ever done that myself

    Question - when you say you are getting multiple emails sent, how many? Is it the same for every order?

    I had an issue with a bash script I wrote previously, because the email headers were formatted incorrectly, replying would send two emails. If you are getting one email for each line in the array, I guess your notification is in the wrong place in the loop. Probably not a lot of help, but I struggle to get my head around arrays.

 

 

Similar Threads

  1. v150 Product and Order Status
    By smithdp1 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 11 Jul 2012, 08:30 PM
  2. Can I add under the customer's account their order histor and order status??
    By flash01 in forum Customization from the Admin
    Replies: 8
    Last Post: 28 Nov 2010, 09:49 PM
  3. Order Status and Order History
    By scottmcclean in forum Managing Customers and Orders
    Replies: 7
    Last Post: 6 Jan 2010, 07:01 PM
  4. Replies: 1
    Last Post: 21 Mar 2007, 07:50 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