Home Documentation Technical FAQ Integrating PAPs With osCommerce Add-ons
Integrating PAPs With osCommerce Add-ons


Q) How do I install PAPs if I've already got the QTPro stock tracking contribution installed in osCommerce?


The PAPs installation method is slightly different if you want get PAPs working with QTPro. If you have already made changes to your product_info.php file as part of PAPs installation, roll back to your version of product_info.php as it was before you attempted to install PAPs, i.e. undo all PAPs-related changes to that file, and follow the instructions below:



Step 1 - Open the file catalog/product_info.php

Find the line:$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
and place these lines immediately BEFORE it:

//BOF Product Attribute Pictures
require_once(DIR_WS_CLASSES . 'paps_delegate.php');
$paps_delegate = new paps_delegate();
$arr_globals = $paps_delegate->getProductGlobals((int)$HTTP_GET_VARS['products_id']);
//EOF Product Attribute Pictures


Place the following line:

<?php include(DIR_WS_MODULES . '/paps.php'); ?>

At the point in the file at which you would like the Product Attribute Pictures to be displayed. When placing this line, please bear in mind the following points:
  • placement should be within an existing table - the display begins and ends with <tr></tr> tags
  • placement should be anywhere after the line: $products_attributes = tep_db_fetch_array($products_attributes_query);
If you are unsure of where to place this line, we would suggest initially putting it around line 205, immediately before a <tr> tag or immediately after a </tr> tag.



Step 2 - Open the file catalog/includes/classes/pad_base.php

Replace the entire function called function _build_attributes_array($build_stocked, $build_nonstocked)

With the replacement function below:


function _build_attributes_array($build_stocked, $build_nonstocked) {
global $languages_id;
global $currencies;
global $cart;
global $paps_delegate;

if (!($build_stocked | $build_nonstocked)) return null;

if ($build_stocked && $build_nonstocked) {
$stocked_where='';
}
elseif ($build_stocked) {
$stocked_where="and popt.products_options_track_stock = '1'";
}
elseif ($build_nonstocked) {
$stocked_where="and popt.products_options_track_stock = '0'";
}
$products_options_name_query = tep_db_query("select distinct popt.products_options_id,
popt.products_options_name, popt.products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS .
" popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" .
(int)$this->products_id . "' and patrib.options_id = popt.products_options_id and
popt.language_id = '" . (int)$languages_id . "' " . $stocked_where . " order by
popt.products_options_name");
$attributes=array();
while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
/////////////////////////////////////////////////////////////////
//BOF Product Attribute Pictures
$heading_conf =
$paps_delegate->getAttributeHeaderDisplaySettings($products_options_name['products_options_name']
, (int)$this->products_id);
if((!$heading_conf['aas']) || ($arr_globals['unlink'])){
//EOF Product Attribute Pictures
/////////////////////////////////////////////////////////////////
$products_options_array = array();
$products_options_query = tep_db_query("select pov.products_options_values_id,
pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " .
TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id
= '" . (int)$this->products_id . "' and pa.options_id = '" .
(int)$products_options_name['products_options_id'] . "' and pa.options_values_id =
pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
while ($products_options = tep_db_fetch_array($products_options_query)) {
$products_options_array[] = array('id' =>
$products_options['products_options_values_id'], 'text' =>
$products_options['products_options_values_name']);
if ($products_options['options_values_price'] != '0') {
$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' .
$products_options['price_prefix'] .
$currencies->display_price($products_options['options_values_price'],
tep_get_tax_rate($this->products_tax_class_id)) .')';
}
}
if (isset($cart->contents[$this->products_id]['attributes']
[$products_options_name['products_options_id']]))
$selected = $cart->contents[$this->products_id]['attributes']
[$products_options_name['products_options_id']];
else
$selected = 0;
$attributes[]=array('oid'=>$products_options_name['products_options_id'],
'oname'=>$products_options_name['products_options_name'],
'ovals'=>$products_options_array,
'default'=>$selected);
//////////////////////////////////////////////////////////////////
//BOF Product Attribute Pictures
}
//EOF Product Attribute Pictures
///////////////////////////////////////////////////////////////////
}
return $attributes;
}

All other installation steps should be followed as per your osCommerce installation guide. Let us know if you have any problems completing this integration.

 
Share

Copyright © 2012 Product Attribute Pictures. All Rights Reserved.