FPHPSC Customize

From FreeBert Wiki

Jump to: navigation, search

Contents

[edit] Customizing The Free PHP Shopping Cart to better match your site's look & style


There are a number of ways you can customize the look of your Free PHP Shopping Cart, to better blend the cart pages in the basic look & style of the rest of your site.
Firstly, you can choose an alternate .CSS file (in the Local_Settings.php file) to change between looks of your site.
Alternatively you can edit the active .CSS file to change specific elements, color schemes and other visual properties.
The cart package contains two files, Overall_Header.php and Overall_Footer.php (located in the script's /inc/skin/ directory) that are included in every visible cart page. They are a good place to add site logos and links to help the cart fit seamlessly into your site's main design.
Finally, if you are PHP savvy, you can edit the actual codes and functions in the cart pages, taking complete control of the look, feel and function of your cart. Be careful if/when editing PHP pages - a single misplaced quote or semi-colon could stop the functioning of your entire cart!

[edit] Further Customization

[edit] Clearing The Cart

A question sent in from email asked:
Got a quick tip for emptying the cart when a customer clicks to continue shopping? This is because our page that feeds the cart is a check list and cart should be cleared if customer goes back.
Answer:
The contents of the shopping cart are stored in session variables, so the easiest / fastest way to empty the cart is to clear all sessions for the current user:

    // Clear all session vars for current user
foreach ($_SESSION as $VarName => $Value)
{
unset ($_SESSION[$VarName]);
}

Note: if you use / set any session vars elsewhere on your site (say, to store a user's ID after loggin in), you will want to store those values temporarily first, then clear all sessions, then reset those session vars. For example:

    // Store existing session vars
$Temp_ID=$_SESSION['User_ID'];
// Clear all session vars for current user
foreach ($_SESSION as $VarName => $Value)
{
unset ($_SESSION[$VarName]);
}
// Restore required session vars
$_SESSION['User_ID']=$Temp_ID;

Remember: any PHP page that does anything with sessions (read, write, etc) needs to start with (i.e. put the following line at the top of your PHP page's code, right after the <? or <?PHP:

    session_start();

Finally, to fully answer your question I would suggest adding the empty cart code to the top of the page you want customers to go t'o 'continue shopping'. If THAT doesn't work or interferes with the coding of the page for other "non-continue shopping" users, hide it behind an 'IF' that checks for a GET command to clear the cart:

    if ($_GET['cc']==1)
{
// Store existing session vars
$Temp_ID=$_SESSION['User_ID'];
// Clear all session vars for current user
foreach ($_SESSION as $VarName => $Value)
{
unset ($_SESSION[$VarName]);
}
// Restore required session vars
$_SESSION['User_ID']=$Temp_ID;
}

And add ?cc=1 to the url of that page to links when you want users to have their cart's cleared.


[edit] Clearing The Cart Part II

A follow up question sent in from email asked:
We want to use our form to make changes to cart. Thus, I've been trying to set up a "clear cart" and return to our form with a history function (set up a special 'clearing page' to run the php function then java history). This is presenting problems with browser compatibility. It works in IE 7 (NOT in firefox). Instead, it might be this easy: Is there a change I can make so that when each post to ShoppingCart.php the order starts fresh (not adding to existing totals, instead clearing and posting new)?
i.e. If we post to ShoppingCart.php with
1 part A
1 part B
Then we use a goback for continue shopping (so that our form has old values).
Customer changes the form to
2 part A
0 part B
and it is posted again to ShoppingCart.php , the result in the cart is
2 part A
(not 3 part A, 1 part B)

Please let me know if there is a line I can change in the shopping cart controls.
Answer:
Regarding your issue, if I understand you correctly, the easiest way to achieve what you want would be to call the php 'clear cart' function just before adding items to the cart.

To do so:
in ShoppingCart.php, look for the section starting with: "if ($cmd_In==1)" for single item additions, or "if ($cmd_In==5)" if you use the add batch items.
Add your 'php clear cart' function just after the opening curly bracket "{" of that section. That way, whenever an item is added to the cart, the cart is cleared first.
I hope that helps, let me know if you have any further questions.


[edit] Skipping The Choose Payment Page

A question sent in from email asked:
We only have paypal as payment option. So the "payment option" screen is redundant. Anyway to skip from shoppingcart to makepayment?
Answer:
The easiest way to jump direct to the PayPal buy it now button is to edit the Checkout link located on the ShoppingCart.

To do so, edit "inc/functions/Cart_Functions.php" In the "DisplayEditableCart" function definition section look for:

    <table width="0%" border="2" bordercolor="#FF0000">
<tr>
<td><div align="center" class=""><a h**f="ChoosePayment.php" class="InSiteLink">Checkout</a> </div></td>
</tr>
</table>


Change that to:

    <table width="0%" border="2" bordercolor="#FF0000">
<tr>
<FORM ACTION="MakePayment.php" METHOD="post">
<td><div align="center" class=""><input type="submit" name="Submit" value="Checkout"></div></td>
<INPUT TYPE="hidden" NAME="PayType" VALUE="PayPal">
</FORM>
</tr>
</table>

By still showing the MakePayment page (instead of posting direct to PayPal from the ShoppingCart page) you give the customers a chance to review and make sure they are happy with their order & quantities - also, the "editable" shopping cart on the shoppingcart page does not show shipping amounts, while the carts on the other pages (choose & make payment) do show the shipping amounts.

If you do jump over the choosepayment page, you might want to update the cart menu (that box near the top of that page that lists the 3 steps to checkout (take out step 2, you can find that menu in: inc/functions/Cart_Templates.php


[edit] Changing The Currency Displayed

(Problem resolved in Latest Version Released: V0.70 - December 11, 2007) A question sent in from email asked:
I have changed the Paypal to GBP currency and have edited the Total in the ShoppingCart.php to read (GBP) but I cannot find where I can change the $ sign in front of the actual amount to a £ sign.
Answer:
As mentioned in the question, if you want to change the currency of the shopping cart, you need to make sure you change all parts which use the currency. If you are using it, the PayPal payment mod will need to be changed to let PayPal know what currency you are using. And, in addition to the currency symbol itself, there is a currency title used by the shopping cart. It is also found in the Cart_Functions file and can be easily found and replaced to the title of the currency of your choice.

Support to include a setting for currency title and symbol have been added to the to do list for the next release.

For now, you can manually change the $ to the £ fairly easily using any text editor that allows text seach or find or replace:

  • Open the Cart_Functions.php page (located in the inc/functions folder)
  • Search/Find in that document all instances of "$ '." - (only what is between the "", don't include the "" in your search - to be explicit, that is a dollar sign, a space, a single quote, and a period)
  • Replace each instance you find with "£ '." - (again, only what is between the "" - as you can see, replacing the $ with your £.)

By my count, there are 7 instances of the above string that you will find & replace. That’s it. Save and upload your file.

Why search for that (a dollar sign, a space, a single quote, and a period)? As you can see, PHP uses a lot of dollar signs in its code, so searching / replacing all dollar signs will corrupt the code. By searching for that string, you will find all and only the Dollar Signs that are being displayed to represent the currency.

UPDATE: There are more actually more places that require updating in regards to the currency change. The issue of setting a currency symbol ($) and currency code (USD) is resolved in Latest Version Released: V0.70 - December 11, 2007. Simply set the value you desire for the symbol and currency code in the local settings file.

UPDATE: See also the discussion regarding paypal currency codes in the Trouble Shooting & Feedback section.


Personal tools