Page 5 of 6 FirstFirst ... 3456 LastLast
Results 41 to 50 of 59
  1. #41
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: how do I require application_top.php in folder in admin with a composer package?

    Agree with DrByte that PHPStorm is worth trying/using. I have/use it when I need to do some more "intricate" review, coordination, evaluation though more frequently I enter code directly I'll say into the file. Like anything there is a learning curve and to say the least it is very powerful. Back in the day I had used some other IDEs the names of which I forget, but its great to have the additional tools of code completion, assignment/use lookup, it even has a git interface though I have a separate tool that I have come to like because with that tool I can also visually look through the history of the commits, see my branches, do branch/commit comparison, etc...

    As to the question about the order creation. Again, it is good to indicate what is it that you are trying to understand or question to answer? Some questions that come to mind is, do you just want to see what data needs to exist prior to initiating creation, do you want to see how the order gets created, how its used after it was created, everything?

    Because no pre-knowledge is identified, what I would suggest is to start using and becoming familiar with the Developers Tool Kit found under the admin's tools menu. The broadest search capability is found in the lower row of that tool. For order related information, I would suggest to start searching on "new order" (without the quotes) May even want to narrow it down to: "= new order" such that text with just the first phrase doesn't appear in the search. Then I suggest also changing the number of lines above/below to at least a value of 3 instead of the default of 0. (BTW, that is a default in the file admin/developers_tool_kit.php that can be changed at/around line 10 of the file.)

    Once you find instances of that text, you can 1) follow the logic of the class' constructor as to which way it goes and what is available, 2) work backwards to see what was done to get to that point and how other classes and code work together to get there.

    And lest didn't know/realize, help spills out when it is seen what has been tried, what is working, what is wanted, what doesn't work, etc... One thing seen (and I've said something similar before), those that show that they are trying to help themselves get help even with things that are difficult to accomplish.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: how do I require application_top.php in folder in admin with a composer package?

    Quote Originally Posted by wolfderby View Post
    Where's the best place to look for order creation using the order class? I've been skimming the class and the one page checkout add-on...
    When customers are shopping via their browser, products get added to the cart using data submitted from product-listing page forms or buy-now-button-links, which trigger some functions in the shopping_cart class via:
    https://github.com/zencart/zencart/b...ns.php#L42-L56

    Then during checkout, the checkout_process "page" calls the checkout_process "module", and essentially creates the new order using all the collected data from the customer's choices (cart contents, shipping/payment selections, applying discounts and taxes).
    https://github.com/zencart/zencart/b...header_php.php
    https://github.com/zencart/zencart/b...ut_process.php
    .

    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. #43
    Join Date
    Dec 2008
    Location
    Pittsburgh, PA
    Posts
    237
    Plugin Contributions
    1

    Default Re: how do I require application_top.php in folder in admin with a composer package?

    i need to still look into the last 2 replies but I skimmed code for a few hours this morning and really the only issue with...

    Code:
     $insertOrderSql = "INSERT INTO " . TABLE_ORDERS . 
                          "(orders_id, customers_id, customers_name, payment_method, payment_module_code, shipping_method, shipping_module_code, date_purchased, orders_status, currency, currency_value, order_cogs, order_total, order_tax)" .
                          " VALUES ('".$newoID."','429', 'Amazon Gmail Import','Amazon Payments', 'amazon', 'Store Pickup (Walk In)', 'storepickup', '" . $newdate . "', 1, 'USD', '1.000000', '".$_POST['Cogs']."', '".$_POST['SoldFor']."', '0.0000');";
      $insertOrdersTotalsSubsql = "INSERT INTO " . TABLE_ORDERS_TOTAL .
                          "(orders_id, title, text, value, class, sort_order)" .
                          " VALUES ('". $newoID . "', 'Sub-Total:', '$".$_POST['SoldFor']. "', '".$_POST['SoldFor']. "', 'ot_subtotal', '100');";
        $insertOrdersTotalsShipSql = "INSERT INTO " . TABLE_ORDERS_TOTAL .
                          "(orders_id, title, text, value, class, sort_order)" .
                          " VALUES ('". $newoID . "', 'Amazon Shipping:', '$".$_POST['Ship']. "', '".$_POST['Ship']. "', 'ot_shipping', '200');";
        $insertOrdersTotalsSql = "INSERT INTO " . TABLE_ORDERS_TOTAL .
                          "(orders_id, title, text, value, class, sort_order)" .
                          " VALUES ('". $newoID . "', 'Total:', '$".$_POST['SoldFor']. "', '".$_POST['SoldFor']. "', 'ot_total', '999');";
        $insertOrdersStatusSql = "INSERT INTO " . TABLE_ORDERS_STATUS_HISTORY .
                          "(orders_id, orders_status_id, date_added, comments)" .
                          " VALUES ('". $newoID . "', '3', '" . $newdate . "', '" . $orderData . "');";
        $insertOrdersProdsSql = "INSERT INTO " . TABLE_ORDERS_PRODUCTS .
                          "(orders_id, products_id, products_model, products_name, products_price, products_cost, final_price, products_tax, products_quantity)" .
                          " VALUES ('". $newoID . "', '".$_POST['Pid']."', '".$_POST['Model']. "', '".$_POST['Skus']. "', '".$_POST['SoldFor']. "', '".$_POST['Cogs']. "', '".$_POST['SoldFor']. "', '0.0000', '".$_POST['Quan']. "');";
        $insertOrdersAmazonSql = "INSERT INTO `orders_amazon` " .
                          "(orders_id, orders_id_amazon, orders_amazon_status, orders_amazon_earnings, orders_amazon_shipping)" .
                          " VALUES ('".$newoID."','".$_POST['AmazonOrderId']."', '".$status."','".$_POST['Earn']."', '".$valueShipWePaid."');";
    ...followed by the respective globe db->execute's ...is just setting the orderID/$oID

    I found a tab in phpmyadmin to change up the auto-increment. I've experimented w/ the store manager reset next Order ID and manually editting all order tables back, however the auto-increment field in phpmyadmin doesn't want to change, it throws ...

    Code:
    "Error
    SQL query: Copy Edit Edit
    
    
    FLUSH PRIVILEGES;
    MySQL said: Documentation
    
    #1030 - Got error 176 "Read page with wrong checksum" from storage engine Aria    "
    ...I spent some time trying to repair tables twice from stackexchange or overflow, but to no avail.

  4. #44
    Join Date
    Dec 2008
    Location
    Pittsburgh, PA
    Posts
    237
    Plugin Contributions
    1

    Default Re: how do I require application_top.php in folder in admin with a composer package?

    this is the groaner section of code I need to objectify ;)

    Code:
        //THIS BLOCK IS HOW IT SHOULDN'T BE    
        $otherSql = " SELECT LAST_INSERT_ID();";
        $newoIDResult = $db->Execute($otherSql);
        $newoID = $newoIDResult->fields['LAST_INSERT_ID()'];
        $testsql = "SELECT * FROM `orders`";
        $db->Execute($testsql);
        $newoID_part2 = $db->Insert_ID();
        echo '$newoID_part2 is ' . $newoID_part2;
        $insertOrderSql = "INSERT INTO " . TABLE_ORDERS . 
                          "(orders_id, customers_id, customers_name, payment_method, payment_module_code, shipping_method, shipping_module_code, date_purchased, orders_status, currency, currency_value, order_cogs, order_total, order_tax)" .
                          " VALUES ('".$newoID."','429', 'Amazon Gmail Import','Amazon Payments', 'amazon', 'Store Pickup (Walk In)', 'storepickup', '" . $newdate . "', 1, 'USD', '1.000000', '".$_POST['nameCogs']."', '".$_POST['nameSoldFor']."', '0.0000');";
        //END - THIS BLOCK IS HOW IT SHOULDN'T BE
    this code "works" but it jumped my order_id count by like 60,000?!

  5. #45
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: how do I require application_top.php in folder in admin with a composer package?

    Quote Originally Posted by wolfderby View Post
    this is the groaner section of code I need to objectify ;)

    Code:
        //THIS BLOCK IS HOW IT SHOULDN'T BE    
        $otherSql = " SELECT LAST_INSERT_ID();";
        $newoIDResult = $db->Execute($otherSql);
        $newoID = $newoIDResult->fields['LAST_INSERT_ID()'];
        $testsql = "SELECT * FROM `orders`";
        $db->Execute($testsql);
        $newoID_part2 = $db->Insert_ID();
        echo '$newoID_part2 is ' . $newoID_part2;
        $insertOrderSql = "INSERT INTO " . TABLE_ORDERS . 
                          "(orders_id, customers_id, customers_name, payment_method, payment_module_code, shipping_method, shipping_module_code, date_purchased, orders_status, currency, currency_value, order_cogs, order_total, order_tax)" .
                          " VALUES ('".$newoID."','429', 'Amazon Gmail Import','Amazon Payments', 'amazon', 'Store Pickup (Walk In)', 'storepickup', '" . $newdate . "', 1, 'USD', '1.000000', '".$_POST['nameCogs']."', '".$_POST['nameSoldFor']."', '0.0000');";
        //END - THIS BLOCK IS HOW IT SHOULDN'T BE
    this code "works" but it jumped my order_id count by like 60,000?!
    Ok.. Couple of things... The orderID is an auto_increment field... It doesn't need to be set when adding to the "orders" table ... By inserting a new row of data (suggest excluding the orders_id in that insert), the data is entered into the table at the point next following the LAST_INSERT_ID...

    Even with that in mind, note that calling $db->Insert_ID() asks for the system to return the id (whatever it was) that was last inserted... That insert could be from anything that previously happened but in the above code, an insert hasn't occurred until the query generated two lines later is actually executed.
    Then, also for database protection, the posted data (e.g. $_POST['nameCogs'] should be treated/handled to ensure that something isn't injected that could cause an issue. There are a number of ways to handle/address, but it is never a good idea to insert into a database the exact content from user's input without some sort of data validation/sanitization. The level of that sanitization is often questionable, but you want to protect the existing database, ensure that when the data is accessed that it doesn't support some undesirable action and while processing the insertion that something malicious doesn't happen.

    If you wanted to obtain the orders_id for this new record, then after $insertOrderSql is processed (next action that could possibly touch the database) the $newoID_part2 = $db->Insert_ID() function should be called... If some other database action is performed that inserts data (say a possible notifier action, a page change, another data insertion) then the returned value will represent the id of whatever record was inserted into whatever table was accessed...

    Basically for the above insert sql, remove the field orders_id from the first item after the initial quote and also remove it from the first values part.

    Ohhh... And another thing, add a space before the opening parentheses of the text that follows TABLE_ORDERS .

    Not having that space between the end of the table's name and before the opening parentheses could cause a SQL issue...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

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

    Default Re: how do I require application_top.php in folder in admin with a composer package?

    Quote Originally Posted by mc12345678 View Post
    Ok.. Couple of things... The orderID is an auto_increment field... It doesn't need to be set when adding to the "orders" table ... By inserting a new row of data (suggest excluding the orders_id in that insert), the data is entered into the table at the point next following the LAST_INSERT_ID...

    Even with that in mind, note that calling $db->Insert_ID() asks for the system to return the id (whatever it was) that was last inserted... That insert could be from anything that previously happened but in the above code, an insert hasn't occurred until the query generated two lines later is actually executed.
    Then, also for database protection, the posted data (e.g. $_POST['nameCogs'] should be treated/handled to ensure that something isn't injected that could cause an issue. There are a number of ways to handle/address, but it is never a good idea to insert into a database the exact content from user's input without some sort of data validation/sanitization. The level of that sanitization is often questionable, but you want to protect the existing database, ensure that when the data is accessed that it doesn't support some undesirable action and while processing the insertion that something malicious doesn't happen.

    If you wanted to obtain the orders_id for this new record, then after $insertOrderSql is processed (next action that could possibly touch the database) the $newoID_part2 = $db->Insert_ID() function should be called... If some other database action is performed that inserts data (say a possible notifier action, a page change, another data insertion) then the returned value will represent the id of whatever record was inserted into whatever table was accessed...

    Basically for the above insert sql, remove the field orders_id from the first item after the initial quote and also remove it from the first values part.

    Ohhh... And another thing, add a space before the opening parentheses of the text that follows TABLE_ORDERS .

    Not having that space between the end of the table's name and before the opening parentheses could cause a SQL issue...
    And remember, the order class takes care of all this internally :)
    .

    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.

  7. #47
    Join Date
    Dec 2008
    Location
    Pittsburgh, PA
    Posts
    237
    Plugin Contributions
    1

    Default Re: how do I require application_top.php in folder in admin with a composer package?

    Thanks again for the input! This morning's endeavor shall be to create the simplest one order manually insertion php script using the order class.

  8. #48
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: how do I require application_top.php in folder in admin with a composer package?

    Quote Originally Posted by wolfderby View Post
    Thanks again for the input! This morning's endeavor shall be to create the simplest one order manually insertion php script using the order class.
    To re-emphasize what DrByte said and in light of all the sql that was written, if all of the data already exists in the "system" to support creating an order, then there are a number of ways to either modify the existing order (previously placed) or to incorporate data into the processing of the order as it is being generated... First, this really goes back to the earlier questioning about what is needed/desired to be done and in a way when it is to be done.

    So for example, if you are really wanting to incorporate new fields into the order as the order is being placed, then you would want to tap into the notifiers in the create method to effectively update the information for that order if updating just the orders table, the orders_totals table,
    and/or the orders_status_history table
    . There are also notifiers in the create_add_products method to be able to directly address fields in the orders_products table, orders_products_attributes table, and/or orders_products_downloads table.

    What this allows is for you to create a similar array format, use the provided information of the "just added" information and do an update on the associated table to incorporate your additional information and then possibly later perform some additional action....

    I don't readily have an example of doing such an update because where I have used this process I added data to a table that was created to support the associated software instead of modifying the default store database format. But that said, the zen_db_perform function is found at the following link: https://github.com/zencart/zencart/b...atabase.php#L2

    Where it is possible to see the layout of the call "definition":
    Code:
    function zen_db_perform($table, $data, $action = 'insert', $parameters = '') {
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #49
    Join Date
    Dec 2008
    Location
    Pittsburgh, PA
    Posts
    237
    Plugin Contributions
    1

    Default Re: how do I require application_top.php in folder in admin with a composer package?

    Confused on how to actually add the order object to the database. Here's a super basic version of what I currently have:

    https://github.com/wolfderby/simple_admin_insert_order

    I just started looking into
    zen_db_perform('TABLE_ORDER ... ?

    when I was called to family breakfast.

  10. #50
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: how do I require application_top.php in folder in admin with a composer package?

    Quote Originally Posted by wolfderby View Post
    Confused on how to actually add the order object to the database. Here's a super basic version of what I currently have:

    https://github.com/wolfderby/simple_admin_insert_order

    I just started looking into
    zen_db_perform('TABLE_ORDER ... ?

    when I was called to family breakfast.
    Added comments of various importance (several don't affect operation, they are just different ways of doing the same thing). They can be seen at: https://github.com/wolfderby/simple_...a2f7fbe2780R26

    From what I see overall, with what you're doing the order isn't being created it is being retrieved from the database, modified and then presumably "restored" back to the database... If the goal is to create a **new** order, then as described in the comments a different approach is needed when processing the posted data.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 
Page 5 of 6 FirstFirst ... 3456 LastLast

Similar Threads

  1. error admin Warning: require(includes/application_top.php
    By unusualfinds in forum Addon Shipping Modules
    Replies: 12
    Last Post: 6 Apr 2012, 07:50 PM
  2. Error MessageWarning: require(includes/application_top.php) [function.require]: faile
    By valbuhagiar in forum Installing on a Linux/Unix Server
    Replies: 2
    Last Post: 31 Oct 2011, 07:44 PM
  3. Warning:require(includes/application_top.php) error
    By Lurkzilla in forum Installing on a Linux/Unix Server
    Replies: 1
    Last Post: 25 Aug 2010, 06:00 PM
  4. admin error message require(includes/application_top.php)
    By mitdrissia in forum Installing on a Linux/Unix Server
    Replies: 3
    Last Post: 27 Nov 2009, 10:06 AM
  5. Replies: 0
    Last Post: 10 Oct 2009, 02:38 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