If this is your first visit, check our documentation. To post, register or login.
Forums / Code Collaboration / how do I require application_top.php in folder in admin with a composer package?

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

Started by wolfderby on 28 Dec 2020, 4:51 PM · Views: 18,844

Results 41 to 59 of 59
14 Jan 2021, 5:40 PM
#41
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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...

14 Jan 2021, 6:41 PM
#42
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

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

wolfderby:

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/blob/v157/includes/main_cart_actions.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/blob/v157/includes/modules/pages/checkout_process/header_php.php
https://github.com/zencart/zencart/blob/v157/includes/modules/checkout_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.

14 Jan 2021, 7:52 PM
#43
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

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...

 $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 ...

"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.

14 Jan 2021, 7:55 PM
#44
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

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 ;)

    //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?!

14 Jan 2021, 10:41 PM
#45
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

wolfderby:

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

//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...

15 Jan 2021, 1:20 AM
#46
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

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

mc12345678:

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.

15 Jan 2021, 10:50 AM
#47
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

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.

15 Jan 2021, 12:21 PM
#48
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

wolfderby:

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/blob/c5d46919cb0a9028d31b176c3e6715a1c0a62b3c/includes/functions/database.php#L2

Where it is possible to see the layout of the call "definition": ```
function zen_db_perform($table, $data, $action = 'insert', $parameters = '') {

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

15 Jan 2021, 1:36 PM
#49
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

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.

15 Jan 2021, 4:45 PM
#50
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

wolfderby:

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_admin_insert_order/commit/aa5335f2351adf8c11f29ad1e44e8a2e6f7897a5#diff-cf96578179412e73d3273c49c08b168694ae2d1e811588cfd303ba2f7fbe2780R26

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...

15 Jan 2021, 9:16 PM
#51
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

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

not to be anti-social, but the learning curve seems steep..

$nextOrderId = "SELECT MAX(orders_id)
    FROM `orders`
    LIMIT 1;";
    $orderIdResult = $db->Execute($nextOrderId);
    echo '<pre>';
    $oId = ++$orderIdResult->fields['MAX(orders_id)'];
    echo 'next oId is ' . $oId . '<br />';

???

15 Jan 2021, 9:42 PM
#52
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

wolfderby:

not to be anti-social, but the learning curve seems steep..

$nextOrderId = "SELECT MAX(orders_id)
FROM orders
LIMIT 1;";
$orderIdResult = $db->Execute($nextOrderId);
echo '<pre>';
$oId = ++$orderIdResult->fields['MAX(orders_id)'];
echo 'next oId is ' . $oId . '<br />';

> 
> ???

It can be. But also can be helped by providing reasons for doing what is thought is needed. 

Again, note that when using the order class to create an oder, the orders_id is autogenerated by way of inserting the base order info into the orders table. 

Further note that the above code reviews the table for the highest number and then adds one to that. Problem is, if someone places an order, then that order is deleted and then this code is executed, two customers would have had the same order_id. No fun for customer or store.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

15 Jan 2021, 10:02 PM
#53
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

Btw, and this was something I learned I believe the hard way, but may have been through watching others get help... If in fact it is needed to determine the next value within a table using the autoincremented field, then the "math" should be done in the query instead of after the query has been run... so instead of just MAX(field_name), should use MAX(field_name) + 1. If the table gets truncated, then a query may return null instead of 0 and doing math after the fact could result in issues. Some of this is system/configuration dependent, but best to use something expected to always work rather than something that might work... :)

Still though doesn't seem like this information is needed for this at least until a further reason is identified...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

16 Jan 2021, 10:40 AM
#54
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

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

Issues today: getting the order_id "right"

Possible solutions:
Solution "keep it ghetto" > no order object > sql lock the order tables > increment max order_id in sql > run inserts > unlock tables

Solution "pro zen-er" > create order object > create order_totals object > create cart object > create currencies object > fudge SESSION data? since this is run in the admin? > I feel like I'm slowly build an entire zen-cart shopping cart. then after all the objects are made can I just then run $order->create(); I'm pretty sure those zen_db_perform('s are my pay-dirt.

I might do "keep it ghetto" then aim for "pro zen-er" if I have time

16 Jan 2021, 2:24 PM
#55
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

Whatever you choose. Let me say this with a little "tough love"... To insert a new order, you DO NOT need to know the order_id that is to be inserted when creating a new order...

You insert the data (without it including an order_id) and then ask what the order_id has become...

Session data... doesn't matter where you are in the system, having that session data variable set allows use/reuse of existing code that handles everything you need.

Building/rebuilding a cart? Of COURSE! You're incorporating the act of making a purchase on your Zen Cart store...

As far as locking all the tables or whatever, the only order table that really matters and the only time it matters for the most part is the orders table at the point of making an insert to that one table... Once the unnumbered data is inserted which then gets a number assigned, all other related orders tables get similar additions to reference that order_id.

Personally, I think it would be more work, time and effort to "take the short-cut" than it would to do a simple search through the order class perhaps on '$_SESSION', identify all of the unique parameters and really should only need to concern oneself with the create-like methods... then considering that data, compare to the data that you are receiving from your other direction and line the two up... the order class can handle not receiving something, but also need to be sure that as a user of the store that you are going to get out of this process what you want/need... for example, the shipping, payment, and normal home address information... right now, there doesn't appear to be a consideration of ensuring that the data is "uniquely" captured in the database. Meaning if person X places their first order, on their next order if they use the same addresses will the addresses be looked up and referenced or will they just be added to the person's account.

Are these purchasers gaining access to your Zen Cart store by making a purchase through the route you are implementing? Do they already have an account? If they do have an account, what verification is being done to ensure that the purchase they are making elsewhere (to be tracked here) should be associated with the data they have in the store? E.g. What authentication has been performed to relate the purchase made at this other shopping location with the person(s) in the shopping cart?

Again, you can choose what information you're not going to store in the database about an order, but you'll want to also understand what impact that has on order/data retrieval for you and for the customer(s).

And again whatever you do... stop trying to determine the value of something that automatically determines its value on its own... Let me see if I can think of an example...

Ok, perhaps obscure, but think of it this way, the order_id is the position in a race or marathon. Whoever appears at the end of the race is given a number associated to "how they did" in the race. Once they pass the finish line that number is assigned, but they had a lot to do to get to that finish line. Some may have taken easy paths, some harder, but in the end, they were given the number at which they finished (along with their time) rather than them "appearing" out of the blue and claiming a number... the process of performing the insert to the database is what assigns that number associated with finishing the race... that's also why you'll see in some places in the forum where it is said the first one to checkout wins... if you have limited quantity of a product, you don't want to oversell (taken care of in a way in the process)...

Anyways, hope you get the point..

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

19 Jan 2021, 3:59 PM
#56
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

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

mc12345678:

Whatever you choose. Let me say this with a little "tough love"... To insert a new order, you DO NOT need to know the order_id that is to be inserted when creating a new order...

You insert the data (without it including an order_id) and then ask what the order_id has become...

Session data... doesn't matter where you are in the system, having that session data variable set allows use/reuse of existing code that handles everything you need.

Building/rebuilding a cart? Of COURSE! You're incorporating the act of making a purchase on your Zen Cart store...

As far as locking all the tables or whatever, the only order table that really matters and the only time it matters for the most part is the orders table at the point of making an insert to that one table... Once the unnumbered data is inserted which then gets a number assigned, all other related orders tables get similar additions to reference that order_id.

Personally, I think it would be more work, time and effort to "take the short-cut" than it would to do a simple search through the order class perhaps on '$_SESSION', identify all of the unique parameters and really should only need to concern oneself with the create-like methods... then considering that data, compare to the data that you are receiving from your other direction and line the two up... the order class can handle not receiving something, but also need to be sure that as a user of the store that you are going to get out of this process what you want/need... for example, the shipping, payment, and normal home address information... right now, there doesn't appear to be a consideration of ensuring that the data is "uniquely" captured in the database. Meaning if person X places their first order, on their next order if they use the same addresses will the addresses be looked up and referenced or will they just be added to the person's account.

Are these purchasers gaining access to your Zen Cart store by making a purchase through the route you are implementing? Do they already have an account? If they do have an account, what verification is being done to ensure that the purchase they are making elsewhere (to be tracked here) should be associated with the data they have in the store? E.g. What authentication has been performed to relate the purchase made at this other shopping location with the person(s) in the shopping cart?

Again, you can choose what information you're not going to store in the database about an order, but you'll want to also understand what impact that has on order/data retrieval for you and for the customer(s).

And again whatever you do... stop trying to determine the value of something that automatically determines its value on its own... Let me see if I can think of an example...

Ok, perhaps obscure, but think of it this way, the order_id is the position in a race or marathon. Whoever appears at the end of the race is given a number associated to "how they did" in the race. Once they pass the finish line that number is assigned, but they had a lot to do to get to that finish line. Some may have taken easy paths, some harder, but in the end, they were given the number at which they finished (along with their time) rather than them "appearing" out of the blue and claiming a number... the process of performing the insert to the database is what assigns that number associated with finishing the race... that's also why you'll see in some places in the forum where it is said the first one to checkout wins... if you have limited quantity of a product, you don't want to oversell (taken care of in a way in the process)...

Anyways, hope you get the point..

I think it should work if I remove my "hammering in the oID" just haven't done it yet. The various order table's autoincrement value (under operations in phpmyadmin) was high and I couldn't seem to get it to reset. However when I got the bad/high oID values out, the reset oID in the admin store manager seemed to fix it.

19 Jan 2021, 4:03 PM
#57
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

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

So I have this "working" however I was thinking of launching it publicly on a git repo, (ideally to help me get a coding job), but I don't think it's quite there yet.

Would anyone be interested in me doing a screen cap video to show this script in action? I was thinking of putting it on youtube w/ a private link because it's using my personal store data I don't quite want out there right now. (I would private message people this link)

I'd be looking for constructive criticism in hopes of this script helping other people as a possible add-on, helping me get a job like this: (https://pineapplepayments.com/jobs/php-javascript-developer/) and to just better my skills in working within other paradigms.

19 Jan 2021, 10:19 PM
#58
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

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

Know of or remember the movie "Field of Dreams"? Build it and they will come...

If concerned about the store content, then build a separate "disposable" store... Do your video (don't wait for others to chime in especially this far in a thread), launch and see what happens... Further, if you make it a plugin and offer it to the Zen Cart community you may get hits off of that as well... Besides both could exist, the github repo and the ZC plugin which would further show your "engagement" with coding and design... Also, remember someone is more likely to appreciate someone that tries rather than someone that waits...

Sorry for not responding sooner, but because I didn't visit this site between the two messages I didn't get notified of the second message to be able to respond sooner.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

20 Jan 2021, 11:04 AM
#59
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

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

Gotcha good advice. Thanks.