Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default How to control extra_cart_actions file loading order

    I need to have a custom extra_cart_actions file load before another add-on extra_cart_actions file. Suggestions on how to do this without core code mods would be appreciated. The add-on in question is Stock by Attributes and I don't want to modify it either.

    Dave
    zc157c, php7.3.x

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

    Default Re: How to control extra_cart_actions file loading order

    Generally speaking the load order is alphabetical; however, some systems will load by order that files were loaded to the system. To address that last part, my suggestion would be to load the new file, then temporarily remove the other and then load it back. By removal I mean delete it from the system and then load it back...

    The file that "controls" the process is includes/main_cart_actions.php, but like said, it is basically system dependent. I would first try applying a file that is alphabetically before the one that you want to precede. That would at least give you an idea about how your system currently works. (may change in the future on some server upgrade.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default Re: How to control extra_cart_actions file loading order

    Quote Originally Posted by mc12345678 View Post
    Generally speaking the load order is alphabetical; however, some systems will load by order that files were loaded to the system. To address that last part, my suggestion would be to load the new file, then temporarily remove the other and then load it back. By removal I mean delete it from the system and then load it back...

    The file that "controls" the process is includes/main_cart_actions.php, but like said, it is basically system dependent. I would first try applying a file that is alphabetically before the one that you want to precede. That would at least give you an idea about how your system currently works. (may change in the future on some server upgrade.
    Isn't file order within a directory strongly OS dependent? So what happens on development system may differ from what happens on live web server. Seems ah, awkward to say the least. Any notifier before loading main_cart_actions.php? But I'll try your suggestion.

    Dave

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

    Default Re: How to control extra_cart_actions file loading order

    Quote Originally Posted by Dave224 View Post
    Isn't file order within a directory strongly OS dependent? So what happens on development system may differ from what happens on live web server. Seems ah, awkward to say the least. Any notifier before loading main_cart_actions.php? But I'll try your suggestion.

    Dave
    Well, wish I made it up, but I know lat9 has previously identified a related issue (observer sequencing can have a similar problem), and the php manual on at least one of the related functions https://php.net/manual/en/function.dir.php

    As to test versus live, that's a reason for the two to have matching systems. For some that is done by using a sub-domain on the live server so that can at least highly approximate the live server.

    As far as a "notifier" to observe, sure, in a way... there's the load point for the file of 140 at least in ZC 1.5.7, loading your "file" before that load point would at least ensure whatever was to be run would be there, though at that point in the load sequence, it is not (yet) clear what path that main_cart_actions will take.

    So other side to this would be, do you need a notifier in the SBA extra_cart_actions file and would you mind identifying what it is for/why and preferably in github or in the forum thread for the application?

    Besides the possibility of adding (and commenting) just that one line in the file, it may be of benefit to others...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default Re: How to control extra_cart_actions file loading order

    I tried to change the order of the files in the directory with no success. I'm using a Mac with a MAMP Pro development system. Using the Mac Terminal utility and the ls -f command to list the directory files unsorted, showed that the SBA file was first, followed by other files including the one in question. The files were not ordered alphabetically or by date added or date created or date modified or size or anything else I could look at. I deleted the file in question and replaced it with a copy from another drive. No change in file order in the directory. I deleted the file again, created a brand new file and copied the code to it. Same file order as before. I verified the file execution order with debug output. So it seems to me that trying to fool with the file order in the directory is a dead end.

    Your point on the development system is noted.

    Let's continue the discussion on the SBA notifier in the SBA forum thread.

    Dave

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

    Default Re: How to control extra_cart_actions file loading order

    Quote Originally Posted by Dave224 View Post
    I tried to change the order of the files in the directory with no success. I'm using a Mac with a MAMP Pro development system. Using the Mac Terminal utility and the ls -f command to list the directory files unsorted, showed that the SBA file was first, followed by other files including the one in question. The files were not ordered alphabetically or by date added or date created or date modified or size or anything else I could look at. I deleted the file in question and replaced it with a copy from another drive. No change in file order in the directory. I deleted the file again, created a brand new file and copied the code to it. Same file order as before. I verified the file execution order with debug output. So it seems to me that trying to fool with the file order in the directory is a dead end.

    Your point on the development system is noted.

    Let's continue the discussion on the SBA notifier in the SBA forum thread.

    Dave
    While not entirely clear above about which file(s) were removed and placed, but it is my understanding that one factor of a file's placement is that it receives some sort of "id" associated to a file being loaded to the system in such a way that it doesn't relate to date, time, or spelling... Its like a products_id, next file gets the next number...

    My thought therefore, to potentially account for that was since this alternate file has been placed to the server (call it file 2) *after* the SBA file (file 1), that file 1 would need to be fully removed from the system (not so much renamed or moved because in both of those cases it still exists, but has some different identifying information related to the "sequence"). And to then load file 1 back to the system (again from outside of the existing system) so that it effectively would have a new "number" that comes "after" file 2...


    The other thing is to actually cause the file to be executed rather than looked at in the directory... Meaning, for "arguments" sake, could set a variable in this other file such that if it is executed first then it could be detected in the second file. So, let's say the variable:
    Code:
    $imHere = true;
    in your "file 2" within the php space in such a place that a "diversion" doesn't occur away from processing the next file, then in file 1 (SBA file) at the top of the file (in the php space), could put a test like:
    Code:
    if (!empty($imHere)) {
        trigger_error('variable set', E_USER_WARNING);
    }
    What this would do (assuming that logs are able to be captured on the server) is, if the load sequence is 1) consistent from load to load and 2) such that file 2 is loaded before file 1, then a myDebug-xxx file would be created when interfacing with the shopping cart (adding a product or similar).

    If necessary, could also place a trigger_error like call in file 2 at/around the point of the variable assignment just to "prove" that the statement executed at least...

    But, again... The load sequence is system dependent (as we both said in our own way) and may be by some other "method" such as a filename/file data hash or...or...or...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. when using file upload how can I display loading message/page?
    By focus360 in forum Setting Up Categories, Products, Attributes
    Replies: 8
    Last Post: 30 Jul 2016, 04:45 PM
  2. How do I control the display order in Coupon Admin
    By nut4squirrel in forum Customization from the Admin
    Replies: 1
    Last Post: 29 Jul 2012, 11:47 PM
  3. v139h How to make the URL link as this and which php file control it?
    By explorer1979 in forum General Questions
    Replies: 2
    Last Post: 11 Apr 2012, 05:27 AM
  4. How to control new Define_XXXX.php file?
    By hara in forum General Questions
    Replies: 3
    Last Post: 2 Oct 2010, 05:34 PM
  5. Just added Upload file attribute, how do I keep it under control?
    By comedyshirts in forum General Questions
    Replies: 1
    Last Post: 28 Sep 2010, 01:41 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