ztwistbooks Posted January 10, 2010 Share Posted January 10, 2010 This is pretty basic, but I've looked all over, but I can't find instructions on how to write a module for OSCommerce. I need a new shipping module. The existing ones don't do what I need. Where do I find directions on how to write a module? I could go through all the PHP code and figure it out, but it would be much faster if the structure is all explained somewhere. Plus, I would know that I'm doing it right. Does anyone have a pointer to any kind of documentation? Tutorial? Anything? Quote Link to comment Share on other sites More sharing options...
Guest Posted January 10, 2010 Share Posted January 10, 2010 Dan, The basics, you need to know PHP very well, or atleast be able to hack up an existing module to suite you needs. You can use an existing module as a template to create your own. But, I don't think there is a 'HOW TO' guide for creating modules because they all vary depending on your needs. You can find PHP references at www.w3schools.com Chris Quote Link to comment Share on other sites More sharing options...
ztwistbooks Posted January 10, 2010 Author Share Posted January 10, 2010 While I don't know PHP, I've done a lot of programming, and it looks a lot like perl, so I can figure that out without difficulty. What I need to know is the general structure of a module and the store as a whole...how all the parts work with each other. Yeah, I could wade through all the code and figure it out, but that's slow and error-prone. In short, I want to provide media mail as free shipping. If the customer selects USPS priority mail, they should only have to pay the difference in price between media mail and priority mail. So... I want to write a new module for the discounted priority mail shipping. It should use (presumably existing) modules to calculate the media mail and priority mail prices, and subtract one from the other. This leaves a lot of questions: How do I use an existing shipping module to extract the price? It seems like there would have to be a function in a standard format for this.... What interface functions does the shipping module class have to provide? What is their format? What are their purposes? When do they get called? How does the Web site know it's there? I might have to set up some database tables to hold things like shipping prices for various weights and distances. Is there a standard format for doing that? I'll need to change them as prices change. What's the right way to set up a configuration interface in the admin section to manipulate these tables? Other than the main class, these modules invariably have the modification of lots of other files for the Web store. Why can't it all go in the module? Some of them seem to add general-purpose functions to the PHP libraries...why not include them in the module? Etcetera, etcetera. There's a lot to figure out.... OSCommerce has been around a long time. I'm hoping someone who has written modules has explained how to do that. Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted January 10, 2010 Share Posted January 10, 2010 OSCommerce has been around a long time. I'm hoping someone who has written modules has explained how to do that. Christian Lescuyer (who has been a team member of osC) made a contribution that explains that a long time ago (contribution 37): Documentation for shipping modules. Quote Link to comment Share on other sites More sharing options...
Ben Nevis Posted January 10, 2010 Share Posted January 10, 2010 (edited) There are no such general instructions that I am aware of. There is no API for custom modules to hook into. Addons don't necessarily work with each other. Logic and display functions are mixed within the same files. etc etc You just have to wade in, learn the structure of osc and how it all fits together by reading the code, browsing directories, inspecting functions and classes, seeing which other files are required within a script and reading them too etc. You don't need to worry about getting things wrong or breaking things if you back up a script before you change it. If it works then the change might be right, as long as it didn't break anything else or introduce a vulnerability. Before trying to write a new module best is to search existing addons to see if there's one that does what you want, or is maybe close to doing what you want that could be modified rather than writing one from scratch. It should also give you an idea of the code changes needed, which files will be affected etc. As Chris says, if you want to work on a new shipping template you can start by looking at an existing one and using it as a template - and the documentation refered to by Jan :) Edited January 10, 2010 by Ben Nevis Quote www.jyoshna.com. Currently using OsC with STS, Super Download Store, Categories Descriptons, Manufacturers Description, Individual Item Status, Infopages unlimited, Product Sort, Osplayer with flashmp3player, Product Tabs 2.1 with WebFx Tabpane and other bits and pieces including some I made myself. Many thanks to all whose contributions I have used! Link to comment Share on other sites More sharing options...
MariaMorrison Posted April 3 Share Posted April 3 thanks Quote Link to comment Share on other sites More sharing options...
MariaMorrison Posted April 3 Share Posted April 3 On 1/10/2010 at 9:07 AM, ztwistbooks said: While I don't know PHP, I've done a lot of programming, and it looks a lot like perl, so I can figure that out without difficulty. What I need to know is the general structure of a module and the store as a whole...how all the parts work with each other. Yeah, I could wade through all the code and figure it out, but that's slow and error-prone. In short, I want to provide media mail as free shipping. If the customer selects USPS priority mail, they should only have to pay the difference in price between media mail and priority mail. So... I want to write a new module for the discounted priority mail shipping. It should use (presumably existing) modules to calculate the media mail and priority mail prices, and subtract one from the other. This leaves a lot of questions: How do I use an existing shipping module to extract the price? It seems like there would have to be a function in a standard format for this.... What interface functions does the shipping module class have to provide? What is their format? What are their purposes? When do they get called? How does the Web site know it's there? I might have to set up some database tables to hold things like shipping prices for various weights and distances. Is there a standard format for doing that? I'll need to change them as prices change. What's the right way to set up a configuration interface in the admin section to manipulate these tables? Other than the main class, these modules invariably have the modification of lots of other files for the Web store. Why can't it all go in the module? Some of them seem to add general-purpose functions to the PHP libraries...why not include them in the module? Etcetera, etcetera. There's a lot to figure out.... OSCommerce has been around a long time. I'm hoping someone who has written modules has explained how to do that. Everything can be found on the Internet Quote Link to comment Share on other sites More sharing options...
kamekosabad Posted April 13 Share Posted April 13 On 1/10/2010 at 6:54 AM, Guest said: Dan, The basics, you need to know PHP very well, or atleast be able to hack up an existing module to suite you needs. You can use an existing module as a template to create your own. But, I don't think there is a 'HOW TO' guide for creating modules because they all vary depending on your needs. You can find PHP references at www.w3schools.com Chris thanks 👽 Quote Link to comment Share on other sites More sharing options...
kamekosabad Posted April 17 Share Posted April 17 (edited) On 1/10/2010 at 10:46 AM, Ben Nevis said: There are no such general instructions that I am aware of. There is no API for custom modules to hook into. Addons don't necessarily work with each other. Logic and display functions are mixed within the same files. etc etc You just have to wade in, learn the structure of osc and how it all fits together by reading the code, browsing directories, inspecting functions and classes, seeing which other files are required within a script and reading them too etc. You don't need to worry about getting things wrong or breaking things if you back up a script before you change it. If it works then the change might be right, as long as it didn't break anything else or introduce a vulnerability. Before trying to write a new module best is to search existing addons to see if there's one that does what you want, or is maybe close to doing what you want that could be modified rather than writing one from scratch. It should also give you an idea of the code changes needed, which files will be affected etc. As Chris says, if you want to work on a new shipping template you can start by looking at an existing one and using it as a template - and the documentation refered to by Jan A good module is a module that solves a specific problem and does it right. It should be easy to understand and easy to use by other developers. It is important to write clear documentation so that it is clear what the module does and how to use it. I remember that I found free essay examples to make it easier, I used https://phdessay.com/free-essay-examples/ for this. In addition, the module must be tested to ensure correct operation. Keep in mind that the module may be extensible in the future, so try to make it as flexible and versatile as possible. agree with this Edited April 17 by kamekosabad 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.