Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    32
    Plugin Contributions
    0

    Default Customising the checkout_success page

    Hi

    I have added the following to my checkout_success.php page:

    <?php
    $code_link = mysql_connect('localhost', 'username', 'password');
    if (!$code_link)
    {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db ('database' , $code_link);
    $zv_orders_id = (isset($_SESSION['order_number_created']) && $_SESSION['order_number_created'] >= 1) ? $_SESSION['order_number_created'] : $orders_id;
    $code_ordered = mysql_query("SELECT products_id FROM orders_products WHERE orders_products_id ='".$zv_orders_id."'");
    while($row = mysql_fetch_array($code_ordered))
    {
    echo $code_ordered;
    echo " | ";
    if ($code_ordered == "192")
    {
    $code_quantity = mysql_query("SELECT products_quantity FROM orders_products WHERE orders_products_id ='".$zv_orders_id."'");
    while($row = mysql_fetch_array($code_quantity))
    {
    echo $code_quantity;
    }
    }
    else
    echo " | None orderd";
    }
    ?>


    It won't work. I can't get the $code_ordered and $code_quantity to show.

    I've taken it down at the moment so my store is functioning again.

    Thanks

    Glenn

  2. #2
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    32
    Plugin Contributions
    0

    red flag Re: Customising the checkout_success page

    OK, I have this partly working..

    What I am trying to achieve is find out whether or not my customer has bought product no. 192, and if so, return the number of these that have been bought. I will then use this number to implement another php script

    If there is only the 192 product in the transaction, it works fine, but if there are other products in the shopping cart, then it returns the other item.

    I have the following code:

    <?php
    $code_link = mysql_connect('localhost', 'username', 'password');
    if (!$code_link)
    {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db ('database' , $code_link);
    $zv_orders_id = (isset($_SESSION['order_number_created']) && $_SESSION['order_number_created'] >= 1) ? $_SESSION['order_number_created'] : $orders_id;
    $code_ordered = mysql_query("SELECT products_id FROM orders_products WHERE orders_id ='".$zv_orders_id."'");
    $code_ordered_result = mysql_fetch_row($code_ordered);
    echo print_r ($code_ordered_result,TRUE);
    if ($code_ordered_result [0] == "192")
    {
    $code_quantity = mysql_query("SELECT products_quantity FROM orders_products WHERE orders_id ='".$zv_orders_id."'");
    while ($code_quantity_result = mysql_fetch_row($code_quantity))
    echo $code_quantity_result[0];
    }
    else
    echo "None ordered";
    ?>

    Help would be appreciated!! I also have a question about the security. Do I need to secure the data being passed to and from my database, or is Zen-Cart doing that for me?

    Thanks

    Glenn

  3. #3
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Customising the checkout_success page

    You're getting bad results because you're not looping through the available records -- thus you're likely only ever seeing the first item in the order.
    If you use the Zen Cart database abstraction layer, you may end up with less confusion between queries.

    Instead of what you've done, try this:
    Code:
    $sql = "SELECT products_id, products_qty from orders_products where orders_id = " . $zv_orders_id;
    $result = $db->Execute($sql);
    while(!$result->EOF) {
      if ($result->fields['products_id'] == 192) {
        echo $result->fields['products_quantity'];
      }
      $result->MoveNext();
    }
    .
    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.

  4. #4
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    32
    Plugin Contributions
    0

    Default Re: Customising the checkout_success page

    Legend, thank you.

    Is this correct, now I can take $result and do other things with it?

    Also, is this data secure as it is transferred to and from the database?

    Glenn

  5. #5
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Customising the checkout_success page

    Quote Originally Posted by glennnz View Post
    Is this correct, now I can take $result and do other things with it?
    The same way you echo out the data, you can use the same value(s) in whatever custom functions you desire to write.

    Quote Originally Posted by glennnz View Post
    Also, is this data secure as it is transferred to and from the database?
    I'm not sure what you're referring to. In what way would the data not be secure?
    .
    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
    May 2008
    Location
    New Zealand
    Posts
    32
    Plugin Contributions
    0

    Default Re: Customising the checkout_success page

    Quote Originally Posted by DrByte View Post
    I'm not sure what you're referring to. In what way would the data not be secure?
    This is a comment from a web developer friend:

    You need to make sure you are properly escaping and sanitising any values received from the browser before building the database query, otherwise you will lose your data in no time due to SQL Injection.
    http://phpsec.org/projects/guide/3.html#3.2

    Please tell me you have register_globals OFF also.
    http://phpsec.org/projects/guide/1.html#1.3

    See http://phpsec.org/projects/guide/ and http://phpsec.org/projects/guide/3.html#3.1 also.

    You need to ensure you spend the time to understand the security implications and/or seek professional advice otherwise your code might be compromised...
    Glenn

  7. #7
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Customising the checkout_success page

    Zen Cart takes security matters very seriously. If a vulnerability is found, a patch is issued as soon as possible, usually the same day. The latest version of Zen Cart includes fixes to all known problems and has taken into consideration best-practices in programming to prevent security vulnerabilities.

    Zen Cart already sanitizes (including escaping) data it collects and stores into the database; so a straight out-of-the-box install is already "secure" in that regard.


    However, I can't speak to the safety of any contributions or addon modules you might install or any custom code you might write yourself though. Perhaps your web developer friend might be willing to help you understand security implications of any custom code you write.



    As to Register Globals, that's up to you and your hosting company to work out for your particular server.
    .
    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
    Aug 2008
    Posts
    4
    Plugin Contributions
    0

    Default Re: Customising the checkout_success page

    I'm working on a checkout_success mod myself, and I just wanted to clarify something (if there is an answer). Shouldn't mods to zen pages be created as separate files and stored in the appropriate /includes/modules/pages/ folder? Just as with overrides in the custom language folders, I thought that page script enhancements should be done separately so that upgrades are not broken.

    I've been assuming all along that the checkout_success.php code should not be altered directly. Please advise one way or the other..

    Thank you to all in advance!!

  9. #9
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Customising the checkout_success page

    /includes/modules/xxxxx.php files can support overrides by placing the revised files in /includes/modules/TEMPLATENAME/xxxxx.php

    /includes/modules/pages/ folders do not support overrides. Any edits to those files must be direct edits.
    .
    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.

  10. #10
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    32
    Plugin Contributions
    0

    Default Re: Customising the checkout_success page

    I'm trying to use

    echo "<form method=\"post\" action=\"" .$_SERVER['PHP_SELF']. "\">";

    to run some php on the results from my form. This directs back to the product listing without executing my php, how can I fix this?

    Glenn

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v151 Customising the main page template
    By BoydBreen in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 15 May 2013, 12:51 AM
  2. Customising the basket page
    By mrkay in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 7 Oct 2009, 01:39 PM
  3. Customising the Admin/Product entry page?
    By TouranMan in forum General Questions
    Replies: 7
    Last Post: 11 Aug 2009, 10:58 AM
  4. Customising the index page.
    By roscoeh in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 17 Aug 2007, 09:59 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