Amanda Arias's phpShop 0.6.x Customization Manual For Beginners
Includes links, how-to's, helpful tips, code snippets, etc. to aid you in creating your own customized phpShop.
Last updated: 8-26-04 - by Robert Temple: Removed broken links to Web sites and
forum posts no longer active.
Pre-Customization Notes
Please DO NOT change or delete any PHP codes unless you know PHP well enough.
I make no guarantees that any of the codes or ideas listed in this manual will work for
everyone. Most are just meant to be starting points or examples. Please make
backups of all files before you start making changes.
Also...you can simply edit/convert the categories and products
already in the demo store over to your new categories and products. You
don't need to delete them first.
^ Back to top
Files in this folder to edit:
s_header.ihtml - The header file for entire store.
s_footer.ihtml - The footer file for entire store.
basket.ihtml - This is the shopping cart.
ro_basket.ihtml - This is the read only version of the cart during checkout. The one that they cannot delete items or change quantity in.
^ Back to top
Get Rid of Yellow Line
To get rid of the yellow horizontal rule that appears on each page displayed near the top of your main shop page (above Welcome to Washupito's....), edit the
following code in modules/templates/s_header.ihtml:
<TABLE WIDTH="90%" BORDER="0" CELLSPACING="0"CELLPADDING="0"
BGCOLOR="#FFCC33" ALIGN="CENTER">
<TR ALIGN="CENTER">
<TD><?php echo $error?></TD>
</TR>
</TABLE>
to look like this:
<?php if($error){ ?>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
<tr><td valign="top"> <b><font color="#ff0000"><?php echo
$error?></font></b></td></tr>
</TABLE>
<?php } ?>
That way if no error exists, you won't get a tacky yellow bar.
CREDIT - Taken from original post by forum member spb
^ Back to top
Change Font Style
The simplest way to change the font is to open /modules/templates/s_header.ihtml and change
the CSS font tag.
CREDIT - john@NOSPAMwebme.co.nz
You can also set the <basefont face="Arial"> tag in /modules/templates/s_header.ihtml just after the body tag.
CREDIT - webmaster@NOSPAMindependent-store.com
^ Back to top
index.ihtml - Controls the look of the mid section of your homepage and 'Featured
Items' list to the right hand side. This is also where you can delete the
words 'Welcome to Washupito's...'
leftmenu.ihtml - Controls the look of the left menu where
categories, search box, etc. are displayed. You will also need to change the
leftmenu.ihtml in the 'modules/account/html' and 'modules/checkout/html'
folders to be coded exactly like this one. Or you can just upload the
'modules/shop/html' version of your leftmenu.ihtml to those folders when you
have changed it to look the way you want it.
browse.ihtml - Controls the look of the page that lists all the products in
a particular category. So lets say you have a category 'hats'. When I click
on the 'hats' link in the left menu it will take me to a page (browse.ihtml)
that displays all of the products in the 'hats' category.
flypage.ihtml - Controls the way your products are displayed when a
visitor wants to view an individual product after clicking on a product
listed in the 'browse.ihtml' page.
cart.ihtml - Controls the area of space above and below your shopping cart.
It holds the checkout button the customer presses to checkout after viewing
their shopping cart.
login.ihtml - Controls the look of the login and registration form.
^ Back to top
Put 'Add to Cart Button' on Browse Page
Include this in your code (in 'browse.ihtml' of course) wherever you want the add to cart button:
<FORM ACTION="<?php echo URL ?>" METHOD=Post>
<input type=hidden name=product_id value=<?php print $db->f("product_id");?>>
<input type=HIDDEN name=ps_session value=$sess>
<input type=HIDDEN name=page value="shop/cart">
<INPUT TYPE=HIDDEN NAME=func VALUE="cartAdd">
<?php $sess->hidden_session() ?>
<INPUT TYPE=TEXT SIZE=2 MAXLENGTH=4 NAME=quantity VALUE=1>
<input type="submit" value="ADD TO CART">
</FORM>
Example:
<TR VALIGN=TOP>
<?php
// Set the flypage for this product based on the category.
// If no flypage is set then use the default as set in phpShop.cfg.
$flypage = $ps_product->get_flypage($db->f("product_id"));
?>
<TD width="10%" ><A HREF=<?php $sess->purl(URL . "?page=$flypage&product_id=" .
$db->f("product_id") . "&category_id=" . $db->f("category_id")); ?>
><?php $db->p("product_name"); ?></A></TD>
<td width="10%"><font size="2" color="#000066">Price - <?php
$price = $ps_product->get_price($db->f("product_id"));
echo $db->f("$product_id");
if ($price) {
echo $price["product_price"] . " " . $price["product_currency"];
} else {
echo "Call for Pricing";
}
?></font></td>
<TD width="20%" > <a href="<?php $sess->purl(URL . "?page=$flypage&product_id=" . $db->f("product_id") .
"&category_id=" . $db->f("category_id")); ?>">
<?php $ps_product->show_image($db->f("product_thumb_image"),"width=80"); ?></a></TD>
<TD width="60%"> <?php $db->p("product_s_desc"); ?>
<FORM ACTION="<?php echo URL ?>" METHOD=Post>
<input type=hidden name=product_id value=<?php print $db->f("product_id");?>>
<input type=HIDDEN name=ps_session value=$sess>
<input type=HIDDEN name=page value="shop/cart">
<INPUT TYPE=HIDDEN NAME=func VALUE="cartAdd">
<?php $sess->hidden_session() ?>
<INPUT TYPE=TEXT SIZE=2 MAXLENGTH=4 NAME=quantity VALUE=1>
<input type="submit" value="ADD TO CART">
</FORM></TD>
</TR>
If the above 'Add to Cart' button code does not work, try this version:
<form action="<?php echo URL ?>" method=POST>
<input type=HIDDEN name=page value="shop/cart">
<input type=HIDDEN name=product_id value="<? $sess->purl($db->f("product_id")); ?>">
<input type=HIDDEN name=func value="cartAdd">
<input type=TEXT size=4 maxlength=4 name=quantity value=1>
<input type=SUBMIT name=Order value=ADD TO CART>
</form>
^ Back to top
Using Different Flypages
If you want a different flypage for a particular category (to create a different background or accompanying text for certain
categories, etc.), you can create a new flypage by editing the default flypage 'flypage.ihtml' to meet your needs and renaming it to something different.
For example, if you want a different look for your the pages in your Garden category, you might create a file named
'garden_flypage.ihtml' and put it in the 'shop/html' directory.
You would then go to the Admin section, click the 'Products' link, then 'List Categories', click the category you want to use the new flypage, and lastly type the name of the new flypage path into the field 'Category Flypage'. In this example the path would be 'shop/garden_flypage'. Notice we do not include /html/ in the path or the extension .ihtml.
^ Back to top
index.ihtml - The page the customer goes to after clicking the
'Account Maintenance' link.
leftmenu.ihtml - Edit as previously mentioned.
shipping.ihtml - The page that is viewed when a person clicks the link
'Shipping Information' under the 'Account Maintenance' section.
shipto.ihtml - The page that is shown when a person wants to add a new
shipping address.
billing.ihtml - The page that is shown when a person wants to edit their
account information.
^ Back to top
index.ihtml - The first page after a customer clicks the checkout button. They select shipping address here. If you don't like the way the shipping section looks you will need to edit the file 'shipping.ihtml' in this same
folder. The other files in this folder that deal with shipping are to be used if you have the InterShipper enabled.
leftmenu.ihtml - Edit as previously mentioned.
confirm.ihtml - The second page of checkout sequence. This is where they give their credit card
information.
thankyou.ihtml - The last page of checkout. It spits out the invoice and
you can tell the customer thank you for shopping with you.
^ Back to top
Blank Thank You Page - Fix
If the thank you page is not appearing you will need to edit '/modules/checkout/html/thankyou.ihtml' by replacing the 3 lines of code at the top (beginning with $q) with the following 4 lines:
$q = "SELECT * FROM orders WHERE ";
$q .= "orders.user_id='" . $auth["user_id"] . "' ";
$order_id = $vars["order_id"];
$q .= "AND orders.order_id='$order_id'";
It is the 3rd line that is different (added) that will make the thank you page appear.
CREDIT - john@NOSPAMwebme.co.nz
^ Back to top
Folders Not Covered
Folders not covered here pretty much deal with the administration section of the store.
^ Back to top
Adding New Pages
1.) Create a new page (HTML and/or PHP) just as you normally would, except
do not include the following HTML tags:
<html>
<head>
<meta http-equiv="..........>
<title></title>
<meta name="..........>
</head>
<body>
</body>
</html>
2.) Name the file using the extension .ihtml ---> example: shipping_fees.ihtml
3.) Upload the file to a phpShop directory of your choice. ---> example: phpshop/modules/shop/html
4.) Add the link for your new page to the page of your choice (A good
example page to add your new link to would be: phpshop/modules/templates/s_header.ihtml) using the following link code as
an example:
<a href="<?php $sess->purl(URL . "?page=shop/shipping_fees");?>">Shipping
Fees</a>
By looking at the URL we can see that "shop" is the directory the file is located in and "shipping_fees" is the file itself. Notice that we do not include the .ihtml extension. Be sure to leave that off in the link.
5.) That's it. Your page will include the header, footer, etc. already when
it the link is opened, just as any other phpShop page would. =)
^ Back to top
Spacing in Shipping Address Selection - Fix
Want to get rid of the extra spacing in your checkout 'select shipping address' table so the options will be next to the checkbox instead of an inch away?
Open '/modules/checkout/lib/ps_checkout.inc' and edit the 'ship to address radio' function. I will
just paste the entire function here with the table edited.
/************************************************************************
name: ship_to_address_radio()
** created by: gday
** description: Get all the user_info Ship To (ST) records associated
** with the $user_id and print an HTML radio check box
** form element using the retrieved data.
** parameters: $user_id - user id of to display ship to addresses
** $name - name of the HTML radio element
** $value - If matched, then this radio item will be
** checked
** returns: Prints html radio element to standard out
***************************************************************************/
function ship_to_addresses_radio($user_id, $name, $value) {
global $sess;
$db = new ps_DB;
/* Select all the ship to information for this user id and
* order by modification date; most recently changed to oldest
*/
$q = "SELECT user_info_id FROM user_info ";
$q .= "WHERE user_id = '" . $user_id . "' ";
$q .= "AND address_type = 'BT' ";
$db->query($q);
$db->next_record();
$bt_user_info_id = $db->f("user_info_id");
$q = "SELECT user_info_id, address_type_name, company, title, ";
$q .= "last_name, first_name, middle_name, phone_1, phone_2, ";
$q .= "fax, address_1, address_2, city, ";
$q .= "state, country, zip ";
$q .= "FROM user_info ";
$q .= "WHERE user_id = '" . $user_id . "' ";
$q .= "AND address_type = 'ST' ";
$q .= "ORDER by address_type_name, mdate DESC";
$db->query($q);
echo "<BR><TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0>\n";
echo "<TR>\n";
echo "<TD valign='top'>\n";
if ($db->num_rows() and $bt_user_info_id != $value) {
echo "<INPUT TYPE=radio NAME=$name VALUE=\"$bt_user_info_id\">\n";
} else {
echo "<INPUT TYPE=radio NAME=$name VALUE=\"$bt_user_info_id\" CHECKED>\n";
}
echo "</TD>\n";
echo "<TD valign='top'>\n";
echo "Same as Billing Address.</b></font>\n";
echo "</TD>\n";
echo "</TR>\n";
while($db->next_record()) {
echo "<TR>\n";
echo "<TD valign='top'>\n";
if (!strcmp($value, $db->f("user_info_id"))) {
echo "<INPUT TYPE=radio NAME=$name VALUE=" . $db->f("user_info_id") . " CHECKED>\n";
}
else {
echo "<INPUT TYPE=radio NAME=$name VALUE=" . $db->f("user_info_id") . ">\n";
}
echo "</TD>\n";
echo "<TD valign='top'>\n";
echo "<TABLE border=0 cellspacing=0 cellpadding=1>\n";
echo "<TR>\n";
echo "<TD valign='top'>\n";
echo "<b>" . $db->f("address_type_name") . "</b> ";
$url = SECUREURL . "?page=account/shipto&user_info_id=" . $db->f('user_info_id');
$url .= "&next_page=checkout/index";
echo "(<a href=\"";
$sess->purl($url);
echo "\">Update Address</a>)\n";
echo "<BR>\n";
echo $db->f("title") . " ";
echo $db->f("first_name") . " ";
echo $db->f("middle_name") . " ";
echo $db->f("last_name") . "\n";
echo "<BR>\n";
if ($db->f("company")) {
echo $db->f("company") . "\n";
echo "<BR>\n";
}
echo $db->f("address_1") . "\n";
if ($db->f("address_2")) {
echo "<BR>";
echo $db->f("address_2"). "\n";
}
echo "<BR>\n";
echo $db->f("city");
echo ", ";
echo $db->f("state") . " ";
echo $db->f("zip") . "\n";
echo "<BR>\n";
echo "Phone:";
echo $db->f("phone_1") . "\n";
echo "<BR>\n";
echo "Fax:";
echo $db->f("fax") . "\n";
echo "</TD>\n";
echo "</TR>\n";
echo "</TABLE>\n";
}
echo "</TD>\n";
echo "</TR>\n";
echo "</TABLE>\n";
return(true);
}
^ Back to top
Secure URL in Sub-Categories - Fix
Open '/modules/product/lib/ ps_product_category.inc' and change SECUREURL to URL in the function
'print_child_list($category_id)'.
^ Back to top
Edit Wording
If you need to change any of the wording for your shop check the 'modules/any of the folders listed in modules/lib/lang_eng.inc' files.
^ Back to top
Customizing the E-Mail Receipt
To change the way the e-mail receipt looks, look in the function named
'email_receipt()' listed in the '/modules/checkout/lib/ps_checkout.inc'
file. Just be very careful with it.
^ Back to top
Broken Images in Admin
Question - In the Administration section, all of the image links are broken?
The links are all pointing to: http://www.mysite.com/ps_image/whatever.gif - instead of: http://www.mysite.com/shop/ps_image/whatever.gif
To fix that just copy the 'ps_image' directory out of the 'shop' directory, and into your main level
web directory....so that the link http://www.mysite.com/ps_image/whatever.gif will work.
Do not delete 'ps_image' from the 'shop' directory completely - You may want to leave the 'ps_image/vendor' directory inside of your 'shop' directory if you plan on using the vendor image upload formlocated in the admin area. That will still be pointing to http://www.mysite.com/shop/ps_image/vendor/vendor.gif.
^ Back to top
Upload Image Problem
Question - When I am uploading images via the admin area, I get the following error:
ERROR: Cannot write to thumbnail image destination directory.
/home/blabla/shop/shop_image/product/
ERROR: Cannot write to full image destination directory.
/home/blabla/shop/shop_image/product/
Answer - You need to chmod 777 your product directory (and vendor
directory as well).
Or as jangelu suggested, do the following:
Try changing the owner of the directory to 'www' like this:
chown directory_name www (or whatever the webuser is)
then chmod -R 755 directory_name
Whichever you feel more comfortable with...
^ Back to top
Credit Card Scramble
Question - How do I get phpShop to stop scrambling credit card numbers?
Change the following line in 'phpshop/modules/order/html/order_print.ihtml':
$q = "SELECT DECODE(\"".
addslashes($dbpm->f("order_payment_number"))."\",\"".ENCODE_KEY."\") as
account_number";
To this:
$q = "SELECT DECODE(order_payment_number,'".ENCODE_KEY."') as account_number
from order_payment where order_id='".$order_id."'";
CREDIT - kingj2@NOSPAMhotmail.com
^ Back to top
Country Order
Question - I would like the country order (in registration) to be as follows:
United States
Canada
etc.
etc.
Answer -
Step 1.) Change 'database country_id' in the MySQL database (this is where PhpMyAdmin would come in
handy) to the number you want.
Example: Change USA to 1 if you want it to appear first on the drop down list.
Step 2.) Edit 'function list_country' in 'admin/lib/ps_html.inc' to:
function list_country($list_name, $value="") {
$db = new ps_DB;
$q = "SELECT * from country ORDER BY country_id ASC";
$db->query($q);
echo "<SELECT NAME=$list_name>\n";
echo "<OPTION VALUE=\"\"> - </OPTION>\n";
while ($db->next_record()) {
echo "<OPTION VALUE=" . $db->f("country_id");
if ($value == $db->f("country_id")) {
echo " SELECTED";
}
echo ">" . $db->f("country_name") . "</OPTION>\n";
}
echo "</SELECT>\n";
return True;
}
CREDIT: Ron (Narwilly)
Added 3/22/2002: If that does not work properly for you, please try using the code above, but instead of:
echo ">"OPTION VALUE=" . $db->f("country_id");
Try:
echo ">"OPTION VALUE=" . $db->f("country_name");
CREDIT: Brian Spangler
^ Back to top
Customized Shipping
First you need to open 'modules/checkout/lib/ps_chekcout.lib' and edit the
function 'calc_order_shipping()'.
My shipping function (for example only-edit as needed) is as follows:
/************************************************************************
name: calc_order_shipping()
** created by: pablo
** description: Calculate the shipping charges for the current order
** parameters: $d
** returns: Shipping costs for this order
***************************************************************************/
function calc_order_shipping($d) {
eval(load_class("ISshipping", "ps_intershipper"));
$ps_intershipper= new ps_intershipper;
if (IS_ENABLE) {
if(!($shipping = $ps_intershipper->fetch_quote($d)))
return(0);
reset($shipping);
while (list($key,$val)=each($shipping)) {
if (strcmp(trim($key),trim($d["ship_method_id"])) == 0)
$quote = $shipping[$key]["rate"];
}
return($quote);
}
else {
//fetch the subtotal of the order, this is the cost of the goods exclusive
of tax etc.
$order_subtotal =$this->calc_order_subtotal($d);
if ($order_subtotal > 150.00){
return 1.65;
}
elseif ($order_subtotal > 100.00){
return 16.60;
}
elseif ($order_subtotal > 89.99){
return 14.60;
}
elseif ($order_subtotal > 59.99){
return 12.60;
}
elseif ($order_subtotal > 34.99){
return 10.60;
}
elseif ($order_subtotal > 14.99){
return 8.60;
}
else {
return 6.60;
}
}
}
----- END OF CODE------
Which basically figures the shipping as so:
If subtotal is $1.00 to $14.99 - Shipping is $6.60
If subtotal is $15.00 to $34.99 - Shipping is $8.60
If subtotal is $35.00 to $59.99 - Shipping is $10.60
If subtotal is $60.00 to $89.99 - Shipping is $12.60
If subtotal is $90.00 to $100.00 - Shipping is $14.60
If subtotal is $101.00 to $150.00 - Shipping is $16.60
If subtotal is $151.00 or more - Free Shipping (plus $1.65 handling fee)
Intershipper will need to be turned off. This is done in your 'etc/phpShop.cfg' file at the the line:
#InterShipper Directives
#yadda yadda
"IS_ENABLE" => "0",
Setting IS_ENABLE to 0 means it is off. Set to 1 and it is on...
You may also need to edit your ro_basket file. (phpshop/modules/templates/ro_basket.ihtml)
Take this code from that file:
<TD COLSPAN=4 ALIGN=RIGHT>Shipping: </TD>
<TD><?php
if (IS_ENABLE AND $weight_total!=0) {
$order_shipping = $ps_intershipper->get_rate($vars);
}
else {
$order_shipping = 0;
}
printf("%.2f", $order_shipping);
?>
</TD>
and replace it with:
<TD COLSPAN=4 ALIGN=RIGHT>Shipping: </TD>
<TD>$<?php
if (IS_ENABLE AND $weight_total!=0) {
$order_shipping = $ps_intershipper->get_rate($vars);
}
else {
$order_shipping = $ps_checkout->calc_order_shipping($vars);
}
printf("%.2f", $order_shipping);
?>
</TD>
Note: The above is just meant as a starting point to customizing the shipping. I know it won't fit everyone's needs. Just a helpful example.
Thanks to JohnS who helped me with that code originally.
^ Back to top
Final Note
I guess that is all that I can think of!
If you are looking for add-ons, modifications, and modules for
your shop, visit http://zephware.com.
If you have any additions to or suggestions for this manual, please e-mail me at Amanda_31907@NOSPAMmsn.com.
Good luck,
Amanda Arias
Amanda_31907@NOSPAMmsn.com
(Remove NOSPAM to send an e-mail to me. Also applies to any of the other e-mail addresses given in this manual.)
Thank You's
Special thanks to everyone on the boards who directly or indirectly helped me, including - in no particular order - Brett, spb, JohnS, heiko, narwilly, Kelly Meeks, dab, TopoGijo, Derrick Wooden, and Brian Spangler. Thank you also to Gord Fisch for helping me get this manual into HTML format since I was too busy (lazy?) to do it all myself.
If I failed to give credit to anyone I apologize.
^ Back to top