HOW TO INSTALL GOOGLE CHECKOUT MODULE FOR OSC (v1.4.5_CCS)
If you haven't read the README file yet, please read it first.
NOTE: This will work with New OSCommercer v2.2. RC1
http://www.oscommerce.com/solutions/downloads
The only file modified for v2.2RC1 is:
catalog/checkout_payment.php
IMPORTANT: Uninstall and re install the module. If not, many new configuration
will not be enabled.
--------------------------------------------------------------------------------
FRESH INSTALL
=============
There are two installation options you need to choose from, so please read
carefully to determine which option is right for you.
OPTION A:
=========
If you have the basic osCommerce installation without any other modules or
add-on's, simply copy the provided files into your osCommerce system,
preserving the file structure.
For your reference, here is the list of files you need to copy over to your
system:
OSC_DIR:
CHANGELOG
INSTALLATION.txt
README.txt
states.jpg
UPGRADE
OSC_DIR/catalog:
checkout_payment.php
gc_return.php
login.php
shopping_cart.php
OSC_DIR/catalog/admin:
htaccess.php
modules.php
orders.php
OSC_DIR/catalog/admin/includes/functions:
general.php
OSC_DIR/catalog/googlecheckout:
gcheckout.php
index.html
responsehandler.php
shipping_methods_ccs.php
shipping_methods.php
OSC_DIR/catalog/googlecheckout/library:
googlecart.php
googleitem.php
googlelog.php
googlemerchantcalculations.php
googlerequest.php
googleresponse.php
googleresult.php
googleshipping.php
googletax.php
index.html
OSC_DIR/catalog/googlecheckout/library/xml-processing:
gc_xmlbuilder.php
gc_xmlparser.php
index.html
OSC_DIR/catalog/googlecheckout/logs:
index.html
response_error.log
response_message.log
OSC_DIR/catalog/googlecheckout/shipping_generator:
index.php
multigenerator.php
multishipping_generator.js
multishipping_generator.php
README
shipping_method_generator.php
OSC_DIR/catalog/googlecheckout/shipping_metrics:
readme
ship_metrics
shipping_metrics_commandline.php
shipping_metrics.log
OSC_DIR/catalog/includes/languages/english/modules/payment:
googlecheckout.php
OSC_DIR/catalog/includes/languages/espanol/modules/payment:
googlecheckout.php
OSC_DIR/catalog/includes/languages/german/modules/payment:
googlecheckout.php
OSC_DIR/catalog/includes/modules/payment:
googlecheckout.php
* Note: If you applied a patch or manually modified the files to disable
register_globals, go for Option B.
OPTION B:
=========
If you have other modules installed on your osCommerce installation, replacing
your existing files might break your existing installation. In this case, you
need to edit the existing files manually.
For this option, follow the instructions below:
I. Copy the following new files into your existing system, preserving the file structure:
-----------------------------------------------------------------------------------------
OSC_DIR:
CHANGELOG
INSTALLATION.txt
README.txt
states.jpg
UPGRADE
OSC_DIR/catalog:
gc_return.php
OSC_DIR/catalog/admin:
htaccess.php
OSC_DIR/catalog/googlecheckout:
gcheckout.php
index.html
responsehandler.php
shipping_methods_ccs.php
shipping_methods.php
OSC_DIR/catalog/googlecheckout/library:
googlecart.php
googleitem.php
googlelog.php
googlemerchantcalculations.php
googlerequest.php
googleresponse.php
googleresult.php
googleshipping.php
googletax.php
index.html
OSC_DIR/catalog/googlecheckout/library/xml-processing:
gc_xmlbuilder.php
gc_xmlparser.php
index.html
OSC_DIR/catalog/googlecheckout/logs:
index.html
response_error.log
response_message.log
OSC_DIR/catalog/googlecheckout/shipping_generator:
index.php
multigenerator.php
multishipping_generator.js
multishipping_generator.php
README
shipping_method_generator.php
OSC_DIR/catalog/googlecheckout/shipping_metrics:
readme
ship_metrics
shipping_metrics_commandline.php
shipping_metrics.log
OSC_DIR/catalog/includes/languages/english/modules/payment:
googlecheckout.php
OSC_DIR/catalog/includes/languages/espanol/modules/payment:
googlecheckout.php
OSC_DIR/catalog/includes/languages/german/modules/payment:
googlecheckout.php
OSC_DIR/catalog/includes/modules/payment:
googlecheckout.php
II. Manually edit the following files from your system as instructed below:
---------------------------------------------------------------------------
OSC_DIR/catalog/admin/includes/functions:
general.php
OSC_DIR/catalog/admin:
modules.php
orders.php
OSC_DIR/catalog:
checkout_payment.php
login.php
shopping_cart.php
----------------------------------------------------------------------------
1. /catalog/admin/includes/functions/general.php LINE 758
============================================================================
ADD:
// ** GOOGLE CHECKOUT**
// Function to store configuration values(shipping options) using
// checkboxes in the Administration Tool
// carrier calculation
// perhaps this function must be moved to googlecheckout class, is not too general
function gc_cfg_select_CCshipping($key_value, $key = '') {
//add ropu
// i get all the shipping methods available!
global $PHP_SELF,$language,$module_type;
require_once (DIR_FS_CATALOG . 'includes/modules/payment/googlecheckout.php');
$googlepayment = new googlecheckout();
$javascript = "";
$string .= $javascript;
$key_values = explode( ", ", $key_value);
foreach($googlepayment->cc_shipping_methods_names as $CCSCode => $CCSName){
$name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
$string .= " " . $CCSName . ""."\n";
foreach($googlepayment->cc_shipping_methods[$CCSCode] as $type => $methods) {
if (is_array($methods) && !empty($methods)) {
$string .= ' '. $type .' ';
$string .= 'Def. Value | Fix Charge | Variable | Method Name';
foreach($methods as $method => $method_name) {
$string .= ' ';
// default value
$value = gc_compare($CCSCode . $method. $type , $key_values, "_CCS:", '1.00|0|0');
$values = explode('|',$value);
$string .= DEFAULT_CURRENCY . ': ';
$string .= DEFAULT_CURRENCY . ': ';
$string .= '% ';
$string .= ''."\n";
$string .= $method_name;
}
}
}
}
return $string;
}
function gc_cfg_select_multioption($select_array, $key_value, $key = '') {
for ($i=0; $i';
return $string;
}
// Custom Function to store configuration values (shipping default values)
function gc_compare($key, $data, $sep="_VD:", $def_ret='1')
{
foreach($data as $value) {
list($key2, $valor) = explode($sep, $value);
if($key == $key2)
return $valor;
}
return $def_ret;
}
// perhaps this function must be moved to googlecheckout class, is not too general
function gc_cfg_select_shipping($select_array, $key_value, $key = '') {
//add ropu
// i get all the shipping methods available!
global $PHP_SELF,$language,$module_type;
$module_directory = DIR_FS_CATALOG_MODULES . 'shipping/';
$file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
$directory_array = array();
if ($dir = @dir($module_directory)) {
while ($file = $dir->read()) {
if (!is_dir($module_directory . $file)) {
if (substr($file, strrpos($file, '.')) == $file_extension) {
$directory_array[] = $file;
}
}
}
sort($directory_array);
$dir->close();
}
$installed_modules = array();
$select_array = array();
for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {
$file = $directory_array[$i];
include_once(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/shipping/' . $file);
include_once($module_directory . $file);
$class = substr($file, 0, strrpos($file, '.'));
if (tep_class_exists($class)) {
$module = new $class;
//echo $class;
if ($module->check() > 0) {
$select_array[$module->code] = array('code' => $module->code,
'title' => $module->title,
'description' => $module->description,
'status' => $module->check());
}
}
}
require_once (DIR_FS_CATALOG . 'includes/modules/payment/googlecheckout.php');
$googlepayment = new googlecheckout();
$ship_calcualtion_mode = (count(array_keys($select_array)) > count(array_intersect($googlepayment->shipping_support, array_keys($select_array)))) ? true : false;
if(!$ship_calcualtion_mode) {
return ' '. GOOGLECHECKOUT_TABLE_NO_MERCHANT_CALCULATION . '';
}
$javascript = "";
$string .= $javascript;
$key_values = explode( ", ", $key_value);
foreach($select_array as $i => $value){
if ( $select_array[$i]['status'] && !in_array($select_array[$i]['code'], $googlepayment->shipping_support) ) {
$name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
$string .= " " . $select_array[$i]['title'] . ""."\n";
if (is_array($googlepayment->mc_shipping_methods[$select_array[$i]['code']])) {
foreach($googlepayment->mc_shipping_methods[$select_array[$i]['code']] as $type => $methods) {
if (is_array($methods) && !empty($methods)) {
$string .= ' '. $type .'';
foreach($methods as $method => $method_name) {
$string .= ' ';
// default value
$value = gc_compare($select_array[$i]['code'] . $method. $type , $key_values, 1);
$string .= '