Community Add-Ons
checkout button in cart box
for osCommerce Online Merchant v2.2
This very small mod puts a checkout button at the bottom of the shopping cart infobox. Just to improve usability a bit.
This Mod is simple and easy to install. It is not an update of the previous versions. It is an entirely different mod.
I made it compatible with different languages.
edit catalog/includes/boxes/shoppingcart.php
// view cart mod start
if ($cart->count_contents() > 0)
{
if (preg_match("/checkout/", $PHP_SELF))
{$info_box_contents[] = array('align' => 'left','text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><u>'.VIEW_BASKET.'</u></a>');}
else
{$info_box_contents[] = array('align' => 'left','text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><u>'. VIEW_BASKET.'</u></a><br><a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '"><u>'. CHECKOUT .'</u></a>');}
}
else
{$info_box_contents[] = array('align' => 'left','text' => '<u>'. BASKET_EMPTY .'</u>');}
// view cart mod end
and add the following code to the language files in catalog/includes/languages/ (example: dutch.php)
//view cart mod
define('VIEW_BASKET', 'View basket');
define('CHECKOUT', 'Checkout');
define('BASKET_EMPTY', 'Your basket is empty');
A slight change to the last contribution, this adds A "Your Cart Is Empty" text in the shopping cart info box if there is nothing in the cart.
This change is made to the file
/store/includes/boxes/shopping_cart.php
just before the last few lines (see below)
new infoBox($info_box_contents);
?>
</td>
</tr>
<!-- shopping_cart_eof //-->
add in this code above it
// view cart mod start
if ($cart->count_contents() > 0)
{
if (preg_match("/checkout/", $PHP_SELF))
{$info_box_contents[] = array('align' => 'left','text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><u>View Basket</u></a>');}
else
{$info_box_contents[] = array('align' => 'left','text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><u>View Basket</u></a><br><a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '"><u>Go Checkout</u></a>');}
}
else
{$info_box_contents[] = array('align' => 'left','text' => '<u>Your Basket Is Empty</u>');}
// view cart mod end
if there are no items in the cart, then "Your Cart Is Empty" is shown, once the cart contents is greater than 0, then you will see "view basket" and "Go checkout" both as links, except if the site visitor is in the checkout stage, then they will only see "view basket" as a link... no point seeing the checkout link, if already in the checkout process... this is a slight mod from what is already here... they deserve the credit...
zip file attached is simply the same text as pasted here..
I moded the code a little from what I could see around, this change is made to the file
/store/includes/boxes/shopping_cart.php
just before the last few lines (see below)
new infoBox($info_box_contents);
?>
</td>
</tr>
<!-- shopping_cart_eof //-->
add in this code above it
if ($cart->count_contents() > 0) {
if (preg_match("/checkout/", $PHP_SELF)) {
$info_box_contents[] = array('align' => 'left','text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><u>View Basket</u></a>');
} else {
$info_box_contents[] = array('align' => 'left','text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><u>View Basket</u></a><br><a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '"><u>Go Checkout</u></a>');
}
}
if there are no items in the cart, then nothing is shown, once the cart contents is greater than 0, then you will see 'view basket' and 'Go checkout' both as links, except if the site visitor is in the checkout stage, then they will only see 'view basket' as a link... no point seeing the checkout link, if already in the checkout process... this is a slight mod from what is already here... they deserve the credit...
zip file attached is simply the same text as pasted here..
it works fine for me... happy days...
This code is actually completely different than the versions posted below. I shortened it up a bit, etc.
The original intent of this modification was to make osC easier to use by placing a Checkout button in the customer's shopping cart status box. This update continues this theme by not including the checkout button in the the cart if the customer is already in the process of checking out. Prior to this, the customer would see a Checkout button while in the checkout process (which didn't make any sense to me) and if they clicked it, the checkout process would start over.
Have also included sample code (not multi-language friendly) to indicate to the customer they are about to purchase the items when they are in the checkout process.
Link was not directing customer to SSL for checkout. Slight modification to the code corrects this.
With this little patch the checkout button will NOT be displayed in cart box while a person is already in the checkout process. I think it is misleading to show the additional checkout button while a person is already checking out.
This patch just enhanced the previous one to two more pages, where the button is not displayed.
Adds logic to hide the checkout button in the cart box if you are already on the shopping cart page.
Dan's edit - while useful - left certain users of our site confused because it takes them to the shopping cart. As a result, a quick edit, and it now takes them direct to checkout_shipping (if an account exists).
This very small mod puts a checkout button at the bottom of the shopping cart infobox. Just to improve usability a bit.
