Contact Us
My Account
Features List
Begin Using AFCommerce
Documentation
Beginner's Tutorial
Customization
Home
PayPal Payment Solutions
Free PayPal Business Account
Free Google Checkout Account
Legal Policies
Contact Us
Email Address:
Password:
New PHP Functions And Features
customfunctions.php
-
(found in the functions directory)
This is the file you should add your own functions to. You can add them directly into this file, or include other files that have your functions in them and they will all automatically be added to all cart files. Make sure you ONLY write functions, not scripts (or even random programming code) because those scripts will run on every page load of the main cart and admin area. Functions can be loaded here with no problem, they will simply be declared here and then you can call them in any of the cart's scripts, just like the rest of the AFCommerce functions.
Creating New PHP Functions
If you are unfamiliar with php functions, the following website may be helpful in learning what they are:
www.rutgers.edu
. You will need to understand the php programming language to write any of your own functions.
Functions are not necessary to create any new features to your store, even if your feature requires php coding to make it work. Instead, functions are used as small programs, which may be re-used over and over again, so that you do not have to rewrite the same programming code in different areas of your software. This is why I use them constantly, and especially with AFCommerce. This way the functions and features that I write for AFCommerce can be used by you in your own features and functions.
When writing your own php functions, I first suggest that you declare them inside the file explained at the top of this page, customfunctions.php. This is because that file is automatically included with the rest of AFCommerce's default functions. This is done so that your functions will be available in all of your web pages, without having to figure out how to do that on your own. Experienced programmers who already know how to do this should probably still do it this way to save time and keep one solid structure, but this is of course up to you. The functions that you write are also up to you, they depend on what you are doing with your website and how you decide to accomplish these goals.
Creating New Shopping Cart Features
This can be a huge topic, and I am thinking of writing an entire tutorial explaining each step of creating some example features, but any features that I thought were going to be universal to everyone, I already built in to the default installation. For now, I will explain how AFCommerce can be used for almost any php website or application's foundation, and what I call AFCommerce's
custom development environment
.
A custom development environment is my way of explaining to our community the flexibility of the AFCommerce software. The primary use of AFCommerce is of course as an ecommerce shopping cart application, however it is also a strong foundation to almost any powerful php driven website. Some proof of this is seen in the add ons to the free shopping cart, and more specifically in how easily they were to integrate. I wrote the software, so yes it is easier for me to add to it than anyone else, however AFCommerce was written completely with the web developer in mind. By using the documentation, along with your own php knowledge, adding features to the AFCommerce software will normally be easier than building such features from scratch.
By using the AFCommerce foundation, your website automatically starts with all of the custom php functions created for the software, the security features, the universal design layout(s), the database connection, pre-built contact us form, and basically any other of the pre-built features that may be re-used for your own purpose. An example of another use of this environment is a real estate listing system, we used the AFCommerce software as the starting foundation and modified it from there. Doing it this way, saved us around 90% of the work (and time) it would have taken to write the real estate system from scratch. Since AFCommerce was a system developed by a real software designer, there were many considerations taken in account to create a server and browser compatible environment. Since our software has already been tested all over the world, many common problems that a developer will face when building their own application have already been solved, and hence will not be time wasted by you when developing. I do want it to be clear that while I am saying AFCommerce is a stronger foundation than what someone would normally build from scratch, I am NOT saying that this is because I am a better programmer than everyone else. Certainly not, different programmers prefer different methods of accomplishing the same task, which is one of the best aspects of programming, 10 people can do the same task 10 different ways, and they all might be perfect.
If you feel you are not a great programmer yet, then using AFCommerce as a foundation is probably a smart idea. If you are a great programmer, you can still save yourself a massive amount of time by using my database driven scripts and php functions. I feel I have a very readable programming style, and countless web designers have learned from my scripts, but again, if your style is different and preferences are different from mine, then you may be better off starting from scratch. This is the decision of the programmer, and there is no way for me (or anyone else) to give every person exactly what they want to see (you can't please everyone). A perfect (php) programming example is the using classes or functions. People get very touchy about this, and have read arguments on forums where programmers rant and rave about how not using classes is structurally wrong, disorganized, etc. Function programmers, like myself, feel classes are not flexible and make the code less readable to others. Who is right? None of them. Use what works for you, otherwise you are only limiting yourself.
AFCommerce's custom development environment is the same way, if you are comfortable with it, I feel its foundation is limitless. If you don't like it, there is no need to even try. It doesn't matter how good the code is, you won't be able to follow something you disagree with, so make sure you are already familiar with AFCommerce before you try making anything new with the code.
Here is how I would start any new feature or major customization / modification :
1.
The programming aspect should always be done last, never just jump right in without a plan and at least some research. The first step is to grab a piece of paper and write down each goal you have. I know, I know, you think you can remember it, but when you get stuck it's nice to just keep reading what you have already thought of over and over until you figure out what you are missing. Use a pencil so you can make changes without rewriting the whole thing.
2.
Separate each feature you want to create, leave some space to add notes below each one. Then make a second area to write your database structure (if necessary). Look at what information is already available, and do not start making changes to existing tables. There is rarely ever a reason to do that, with any application, because then you may have problems with existing scripts when that is not necessary. A perfect example can be seen with AFCommerce's products database table. Instead of rewriting my existing code when I need a new field for each (or some) product, I can make a new table and simply add a field in the new table to store the product's id number (prodid). This method links the new table with the products table, meaning you can add any number of fields anytime you need them without changing anything. This can be seen by looking at the specials, clearance, and product_descrip tables (and probably others). This is a technique that should probably always be used, no matter what you are adding to, but I know it's perfect for AFCommerce modification.
3.
Now you need to figure out what you need to do for each feature (or modification). Look at what you already have, or more importantly, code you could use in making your changes. You will rarely find a block of code that is exactly what you need (sometimes though), but the trick is to look for similar existing features (or code) that is doing basically the same thing. Like my knowledge base is very similar to the cart's search feature. Instead of searching the products table for matching names, captions and descriptions, I changed it to search a different table for different fields, but 90% of the work was already done before I even started. A good programmer can identify similar code blocks to what you need, copy and modify them to make completely different features. Also, look through the AFCommerce functions documentation to see which functions are already available to help you, chances are there is something that will at least speed you up somewhere, like get_config_value or any of the log in or session functions.
4.
Step 3 should be performed for all features before you start actually writing anything. You will find that by looking at them all together before you actually write the code, many ways to speed up the entire process. Examples are update and insert scripts, if you need 3 of each (for example), you should do them all at the same time.
5.
Now you would begin to write your code, figure out problems that come up along the way, and start testing. Now that you have the whole plan, just go down your list until the entire package is complete. Add or remove as you go, but try to stick to your plan as much as possible. This allows you to stay focused on what your goals are, and see the finish line. You should know when you are half done, 3/4 done, etc. This helps push you forward to do all tasks faster, and generally more effectively.
Custom Website Development
Copyright 2004 - 2007
www.afcommerce.com
AFCommerce Website
And Cart Builder
Powered by AFCommerce.com