hungryfrank Posted November 29, 2016 Share Posted November 29, 2016 (edited) am i correct to assume a- having an fopen of a second file does not effect the process of the primary page if i do not want to use result of the second file? b-opening the second page does not effect the load time of the first page c-if the visitor of the first page closes it the second process will continue to run. Edited November 29, 2016 by hungryfrank Quote Link to comment Share on other sites More sharing options...
requinix Posted November 29, 2016 Share Posted November 29, 2016 a- having an fopen of a second file does not effect the process of the primary page if i do not want to use result of the second file?...Probably? What second file? What primary page? What result? b-opening the second page does not effect the load time of the first pageProbably. It's quite possible for one to affect the other - like if there are file locks involved, which can block one process (page) from executing while another has a lock. c-if the visitor of the first page closes it the second process will continue to run.Yes. Quote Link to comment Share on other sites More sharing options...
hungryfrank Posted November 29, 2016 Author Share Posted November 29, 2016 (edited) thanks for your response. the first file invoves interaction with the visitor. it involves them completing their purchase in the online store. the second file is just communication with ebay. it is to change quantity of the listing based on the customer purchase. this file gets the order# from the first page before it actually loads. the order id is already created before this page so it is available at the beginning of this page. what i want to do is to not disturb the load time of the first page and start the ebay stuff in parallel. if there is a lock.is there a way to overcome this? is there a better way? Edited November 29, 2016 by hungryfrank Quote Link to comment Share on other sites More sharing options...
requinix Posted November 29, 2016 Share Posted November 29, 2016 What you're describing doesn't make sense. You say parallel. How? AJAX? And is there an actual problem you're trying to solve or is this all just conjecture? Quote Link to comment Share on other sites More sharing options...
hungryfrank Posted November 29, 2016 Author Share Posted November 29, 2016 (edited) this is an actual problem. here is the situation. customer on the website purchases a product. or multiple products. i will have the order that customer places on the last page presented to the customer. i want to communicate with ebay and change the quantity of the ebay items that are associated with this products at this time. there could be a few api calls. which i don't know how long it will take. i want this last page to load and don't have to wait for my api calls. and the api calls to be done in background Edited November 29, 2016 by hungryfrank Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted November 29, 2016 Share Posted November 29, 2016 I think the reason why everybody is confused is because you keep talking about “files”, and files don't make a lot of sense in your context. If you want to make API calls in the background, the easiest way is to create a cronjob which periodically scans the database for new orders, sends request to the ebay API and then marks the order so that it won't be processed again. So the purchasing script doesn't communicate with ebay at all. It just stores the order. Then a separate script is triggered by the operating system every n seconds and takes care of the API calls. Quote Link to comment Share on other sites More sharing options...
hungryfrank Posted November 29, 2016 Author Share Posted November 29, 2016 (edited) i don't want to use cron for this, because it can create situations in between crons. if i do this when the purchase is made then there will be no risk of selling an outof stock item on ebay. i will also use ebay notification to adjust the quantity on the store. and finally a cron for the double check just incase. sorry about the confusion i have created Edited November 29, 2016 by hungryfrank Quote Link to comment Share on other sites More sharing options...
Solution Jacques1 Posted November 29, 2016 Solution Share Posted November 29, 2016 Your goals and ideas don't make any sense from a technical standpoint. If you want to be sure that the eBay stock is updated during the purchase, there will be a delay for the user, even a potentially infinite delay. Network operations can be slow. Network operations can fail (yes, this happens). The only way would be to wait for the response indefinitely, and if there's any error, try again indefinitely. This is obviously unrealistic. And you may still end up selling out-of-stock items: What if somebody purchases the last item on eBay right after your user has clicked on the “order” button and before you make your API calls? Note that this is also a legal question, so if you're a newbie, you definitely shouldn't invent your own processes. Either find a widely accepted standard solution. Or discuss this with an e-commerce expert. The shops I worked on had a non-binding order confirmation on the website and a separate binding confirmation sent by e-mail. But I'm not a lawyer, so I cannot tell you if this works in every country and in every context. Quote Link to comment Share on other sites More sharing options...
hungryfrank Posted November 29, 2016 Author Share Posted November 29, 2016 the point is minimizing the situation. ebay sends you a notification when an item is sold. based on that notification the stock in the store is reduced. i want to reduce the stock on ebay when an item is sold. there is nothing illegal about that. i can just include the call on ebay in the file. but i want to do this in the background. i don't see what would be illegal about that either. it is totally logical. Instead of a cron doing it, it gets done as soon as a purchase is made. It is more accurate than some predetermined cron. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted November 30, 2016 Share Posted November 30, 2016 I understand that you find your own ideas “totally logical”, but as you already said, you're a newbie, so you're not qualified to make this statement. You clearly don't understand the technical background. Updating the eBay stock is illegal? Who on earth said that? I said that an order confirmation is a legal matter. If you don't understand that either, you're in the wrong business. Anyway, if you're not interested in advice, I wish you good luck with your “files”. Quote Link to comment Share on other sites More sharing options...
hungryfrank Posted November 30, 2016 Author Share Posted November 30, 2016 (edited) i didnot want to change the order confirmation page. i wanted to do this in the checkout success page which is just an information page as to what customer has bought. it comes after order confirmation page. the customer has not bought anything in order confirmation page so it would be stupid,regardless of legality issues. newbie doesn't mean stupid or illogical. Edited November 30, 2016 by hungryfrank Quote Link to comment Share on other sites More sharing options...
hungryfrank Posted November 30, 2016 Author Share Posted November 30, 2016 thanks. sometimes i get so involved with what i want to do that can't see what is right infront of me my apologise Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.