Hello,
The following modifications will allow you to select whether or not a product can be purchased through the Google Checkout IPN, on a per product basis. It is by default set for each product to be able to. To set a product to not be able to be purchased using the Google Checkout IPN payment option - in the admin ui's product page (categories.php) you just set the newly created "Allow Google Payment:" drop down to "No".
Though it is presented here based on a vanilla 2.2 install, it's not been tested on a vanilla install. It was originally done for a heavily modified install. It's been put together by mimicking code from oscommerce and several oscommerce contributions, and it is not likely coded efficiently, nor prudently. I don't even know that all the code is necessary. I do know it works well in my modified environment.
As an aside, I've used the same/similar procedure/process to make several different per product switches/flags and triggers.
Regards,
CT
In:
admin/categories.php
1) Find:
'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']));
1) Replace with:
'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']),
// prevent GCIPN payment option
'products_google_payment_product' => tep_db_prepare_input($HTTP_POST_VARS['products_google_payment_product']));
// /prevent GCIPN payment option
2) Find:
$product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
2) Replace with:
// prevent GCIPN payment option (added: , products_google_payment_product)
$product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id, products_google_payment_product from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
// /prevent GCIPN payment option (added: , products_google_payment_product)
3) Find:
tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "', now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')");
3) Replace with:
// prevent GCIPN payment option (added: , products_google_payment_product)
tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_google_payment_product) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "', now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')");
// /prevent GCIPN payment option (added: , products_google_payment_product)
4) Find:
'manufacturers_id' => '');
4) Replace with:
'manufacturers_id' => '',
// prevent GCIPN payment option
'products_google_payment_product' => '');
// /prevent GCIPN payment option
5) Find:
$product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
5) Replace with:
// prevent GCIPN payment option (added: , p.products_google_payment_product)
$product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_google_payment_product from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
// /prevent GCIPN payment option (added: , p.products_google_payment_product)
6) Find:
$tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
6) Replace with:
// prevent GCIPN payment option
$google_payment_product_array = array(array('id' => '1', 'text' => TEXT_YES), array('id' => '0', 'text' => TEXT_NO));
// /prevent GCIPN payment option
$tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
First Find:
TEXT_PRODUCTS_PRICE_GROSS
7) Then find 2 lines below:
</tr>
7) Replace with:
</tr>
// prevent GCIPN payment option
<tr bgcolor="#ebebff">
<td class="main"><?php echo TEXT_PRODUCTS_GOOGLE_PAYMENT_PRODUCT; ?></td>
<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('products_google_payment_product', $google_payment_product_array, $pInfo->products_google_payment_product); ?></td>
</tr>
// /prevent GCIPN payment option
8) Find:
$product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");
8) Replace with:
// prevent GCIPN payment option (added: , p.products_google_payment_product)
$product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id, p.products_google_payment_product from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");
// /prevent GCIPN payment option (added: , p.products_google_payment_product)
9) Find:
$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");
9) Replace with:
// prevent GCIPN payment option (added: , p.products_google_payment_product)
$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id, p.products_google_payment_product from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");
// /prevent GCIPN payment option (added: , p.products_google_payment_product)
10) Find:
$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name");
10) Replace with:
// prevent GCIPN payment option (added: , p.products_google_payment_product)
$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_google_payment_product from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name");
// /prevent GCIPN payment option (added: , p.products_google_payment_product)
11) Find:
$contents[] = array('text' => '<br>' . TEXT_PRODUCTS_AVERAGE_RATING . ' ' . number_format($pInfo->average_rating, 2) . '%');
11) Replace with:
$contents[] = array('text' => '<br>' . TEXT_PRODUCTS_AVERAGE_RATING . ' ' . number_format($pInfo->average_rating, 2) . '%');
// prevent GCIPN payment option
if ($pInfo->products_google_payment_product == "1") {
$google_payment_product_indicator = TEXT_YES;
} else {
$google_payment_product_indicator = TEXT_NO;
}
$contents[] = array('text' => '' . TEXT_PRODUCTS_GOOGLE_PAYMENT_PRODUCT . ' ' . $google_payment_product_indicator . '');
// /prevent GCIPN payment option
----------------------------
In:
admin/includes/languages/english/categories.php
1) Find:
?>
1) Replace with:
// prevent GCIPN payment option
define('TEXT_PRODUCTS_GOOGLE_PAYMENT_PRODUCT', 'Allow Google Payment:');
// /prevent GCIPN payment option
?>
----------------------------
In:
checkout_payment.php
2) Find:
$selection = $payment_modules->selection();
2) Replace with:
$selection = $payment_modules->selection();
// prevent GCIPN payment option
$order->info['g_payment'] = $cart->g_payment;
if (($cart->g_payment) > 0) {
for($i=0, $n=sizeof($selection); $i<$n; $i++) {
if($selection[$i]['module'] == MODULE_PAYMENT_GOOGLE_TEXT_TITLE) {
array_splice($selection, $i, 1);
break;
}
}
}
// /prevent GCIPN payment option
----------------------------
In:
includes/classes/shopping_cart.php
1) Find:
var $contents, $total, $weight, $cartID, $content_type;
1) Replace with:
// prevent GCIPN payment option (added: , $g_payment)
var $contents, $total, $weight, $cartID, $content_type, $g_payment;
// /prevent GCIPN payment option (added: , $g_payment)
First Find:
function calculate() {
2) Then find 2 lines below:
$this->weight = 0;
2) Replace with:
$this->weight = 0;
// prevent GCIPN payment option
$this->g_payment = 0;
// /prevent GCIPN payment option
3) Find:
$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
3) Replace with:
// prevent GCIPN payment option (added: , products_google_payment_product)
$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight, products_google_payment_product from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
// /prevent GCIPN payment option (added: , products_google_payment_product)
4) Find:
if ($product = tep_db_fetch_array($product_query)) {
4) Replace with:
// prevent GCIPN payment option
$products_google_payment_product = $product['products_google_payment_product'];
// /prevent GCIPN payment option
if ($product = tep_db_fetch_array($product_query)) {
5) Find:
$this->total += tep_add_tax($products_price, $products_tax) * $qty;
5) Replace with:
$this->total += tep_add_tax($products_price, $products_tax) * $qty;
// prevent GCIPN payment option
$this->g_payment += ($products_google_payment_product == 1)?0:(tep_add_tax($products_price, $products_tax) * $qty);
// /prevent GCIPN payment option
6) Find:
$this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
6) Replace with:
$this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
// prevent GCIPN payment option
$this->g_payment += ($products_google_payment_product == 1)?0:($qty * tep_add_tax($attribute_price['options_values_price'], $products_tax));
// /prevent GCIPN payment option
7) Find:
$this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
7) Replace with:
$this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
// prevent GCIPN payment option
$this->g_payment -= ($products_google_payment_product == 1)?0:($qty * tep_add_tax($attribute_price['options_values_price'], $products_tax));
// /prevent GCIPN payment option
----------------------------
added sql:
ALTER TABLE `products` ADD `products_google_payment_product` TINYINT( 1 ) DEFAULT '1' NOT NULL;
END