Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2013
    Location
    Perth, WA, AU
    Posts
    279
    Plugin Contributions
    4

    Default Why doesn't this code I wrote work ?

    Hi

    To cut a long story short I want to add something to admin to test the order confirmation emails. Rather than having to create a new order to generate an email I want to press a button (i've successfully modified my orders.php to achieve this) which then regenerates the confirmation email for that order.

    Please stop me now if I'm re-inventing the wheel but I haven't seen anything that does this.

    So, can someone tell me why the following doesn't work ? Basically I get a fatal error at the
    $order->send_order_email($oID, 3);
    which is the most important bit.

    The "3" is me hijacking the 2nd passed variable to let the function know to send the email to admin only (not the customer).

    ---------------------------------------------------------------------------
    <?php

    require('includes/application_top.php');

    $oID = zen_db_prepare_input($_GET['oID']);
    $orders = $db->Execute("select orders_id
    from " . TABLE_ORDERS . "
    where orders_id = '" . (int)$oID . "'");

    include(DIR_WS_CLASSES . 'order.php');
    $order = new order($oID);


    ?>
    <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html <?php echo HTML_PARAMS; ?>>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
    <title><?php echo TITLE; ?></title>
    <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
    <script language="javascript" src="includes/menu.js"></script>
    </head>
    <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
    <!-- body_text //-->

    <?php
    $order->send_order_email($oID, 3);
    ?>


    <!-- body_text_eof //-->
    <br>
    </body>
    </html>
    <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

  2. #2
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Why doesn't this code I wrote work ?

    Quote Originally Posted by royaldave View Post
    Hi

    To cut a long story short I want to add something to admin to test the order confirmation emails. Rather than having to create a new order to generate an email I want to press a button (i've successfully modified my orders.php to achieve this) which then regenerates the confirmation email for that order.

    Please stop me now if I'm re-inventing the wheel but I haven't seen anything that does this.

    So, can someone tell me why the following doesn't work ? Basically I get a fatal error at the
    $order->send_order_email($oID, 3);
    which is the most important bit.

    The "3" is me hijacking the 2nd passed variable to let the function know to send the email to admin only (not the customer).

    ---------------------------------------------------------------------------
    <?php

    require('includes/application_top.php');

    $oID = zen_db_prepare_input($_GET['oID']);
    $orders = $db->Execute("select orders_id
    from " . TABLE_ORDERS . "
    where orders_id = '" . (int)$oID . "'");

    include(DIR_WS_CLASSES . 'order.php');
    $order = new order($oID);


    ?>
    <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html <?php echo HTML_PARAMS; ?>>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
    <title><?php echo TITLE; ?></title>
    <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
    <script language="javascript" src="includes/menu.js"></script>
    </head>
    <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
    <!-- body_text //-->

    <?php
    $order->send_order_email($oID, 3);
    ?>


    <!-- body_text_eof //-->
    <br>
    </body>
    </html>
    <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
    My best guess is that $_GET['oID'] is not assigned as expected. There is no verification performed that it is set, that it's not null or anything. I'm guessing if you manually substituted as a test a known order id, that the code would work. As such, how is this code being called? Is it by a button or a link? If by button, you probably want to change to a POST instead of a GET, or the source of running this code needs to pass the oid on in the desired format (get or post).

    If the error is at the email line, that would seem to imply the above. Otherwise you could add some notification/display code to identify what variable is equal to what through your program.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v151 Why doesn't the Search function work on my store?
    By rubyyin in forum General Questions
    Replies: 20
    Last Post: 9 Apr 2014, 10:14 PM
  2. v150 why does this code not work?
    By nazca in forum General Questions
    Replies: 6
    Last Post: 9 Oct 2013, 02:19 PM
  3. override system doesn't work - WHY?
    By stevefriedman71 in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 20 Sep 2006, 06:05 PM

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