Jump to content
Sign in to follow this  
Chandra

Option Type Feature v1.6 (for osc 2.2 MS2)

Recommended Posts

I'll help you out kapearl, I just hope i can explain it clearly enough for you, as I tend to ramble.

 

First things first, create your product, for this instructional purpose we will call this imaginary object "memopad".

 

So we want to set text attributes for Memopad.

 

1- Go into the admin panel -> Catalog -> Product Attributes and look for product options(should be on the upper left quarter of the page

 

Now we need to setup an attribute before we can apply the attribute to the product, So we want to give our customer an option to have their name printed on the stationary memopad, that would call for a textbox.

 

2- Under the en:(short for english)[or whatever language you're setup for] type in what you want to call this attribute, we'll write in "Custom Header Text"

i.- in the box below titled "Comment" we can write, "enter your memopad's headline here"

ii.- in the box to the right called length we'll type in a MAXIMUM amount of letters they can type for this title, [ our imaginary memopad is only 4"W x 6"L, so they can't fit much] we'll give it a number value of 12

iii.- We select "text" from the dropdown list to the right of the "length" box

 

3.- now we click "insert"

 

Now we have the attribute setup, thats just one textbox attribute for our memopad product, if we want more like a space for an address and a space for a phone number, we just go through the same process but title them differently. BUT before I go on and show you how to apply the attribute, let me just tell you that if you wanted all that information from the customer, instead of 5 seperate textboxes, we can just create a textarea instead. Following the same steps as before except you'd change the length value to something a bit higher, I tend to use 128 in a textarea for my customers to give me placement instructions on custom clothing, and select "Textarea" instead of text. Now lets give our attribute some values.

 

On the right side of the attribtue page, upper right quarter, there is a section called "Option values".

 

4.- Select "Customer Header Text" from the first dropdown list.

i.- Under the langauage textbox area(i.e. en:) merely type in how you'd liek to refer to it, i'd call it something like, "Headertext"

 

5.- click "insert"

 

Now let's apply our attribute to our product. Down below, on the lower half of the attribute page, is an area titled, "Product Attributes" this is where we will be working. Now let's get to it:

 

6.- Locate the dropdown list below and find our product, "memopad"

i.- Next to that dropdown list is another called "Option Name", we want to select, "Custom Header Text"(thats the title we gave the attribute we created)

ii.- next to that is a drop list for "Option Values" and we'll select,"HeaderText"

(optional)iii.- Under value Price we can charge for this customization, I'll place 1.00, meaning we're charging a buck to add this custom text for our customer. If this is a free feature, leave blank or put in 0.

a.- if we're charging for this feature, we want to put a "+" under the "Prefix" column.

 

7. - Click insert and we're done! :)

 

very wordy, but when you have to explain it, but as you can see by doing it, it's really simple. I hope this helped you, if not.... well you didn't pay for my advice :) Any other questions I'm sure these guys can help you out. Goodluck.


We must be the change we wish to see in the world.

------------------------------------------------------------

p.s. BACKUP!

Share this post


Link to post
Share on other sites

Thanks jacenstuff... that was super clear. I am still not getting a text box, just a drop down menu that now says "headertext!" I installed this on a fresh install, but I am guessing I just have it installed wrong.

Share this post


Link to post
Share on other sites
Thanks jacenstuff... that was super clear. I am still not getting a text box, just a drop down menu that now says "headertext!" I installed this on a fresh install, but I am guessing I just have it installed wrong.

 

Can I delete the fields in the database and redo the database part of this? Which fields would I delete? I think product_options, product_option_values, and product_option_values_to_product_options seem to be related to this contribution. Do I delete those 3 and run the database part again?

 

And also this part: "IMPORTANT: You should create *exactly one* TEXT Option Value.? Once you create this value, you should not change it." Is that something for the manual creation or if you use the enclosed sql file. I still cant get a text box... just a drop down menu with the word text!

Share this post


Link to post
Share on other sites

I'm not that great with the technical backend. I know very little about PHP,javascript and even LESS about database stuff. I just followed directions to the T, but the directions I downloaded seperately from the contrib, and after I followed those, I ran the SQL file that came with the contrib ONCE. I'm about to paste the manual instructions I used, I know there is one typo, and I think it's in the list of which files to modify(think it says product_attribute.php rather than product_attributes.php[notice the plural of attribute]). So try these instructions while installing 1.7.2 of the Option Type Feature, and run the sql file included with that. Mine worked out of the box. I hope it does for you too if you try this. l8er :

 

Product Attributes - Option Type Feature (manual installation)

 

 

 

This file was created to allow the manual addition of "Product Attributes - Option Type Feature" Contribution for

 

OsCommerce. The original contribution was created by Chandra Roukema <chandra@OpenStoreSolutions.com>

 

 

 

This file is dated 28th August 2006 and was created with OsCommerce 2.2 Milestone 2 060817 by PD_Steve

 

 

 

Files to modify

 

 

 

/catalog/checkout_process.php

 

/catalog/product_info.php

 

/catalog/shopping_cart.php

 

/catalog/stylesheet.css

 

/catalog/includes/configure/php

 

/catalog/includes/classes/order.php

 

/catalog/includes/classes/shopping_cart.php

 

/catalog/includes/functions/general.php

 

/catalog/admin/product_attibutes.php

 

/catalog/admin/includes/languages/english/product_attributes.php

 

 

 

(where 'catalog' is your install directory)

 

 

 

NOTE: AT THIS POINT YOU SHOULD BACK UP YOUR COMPLETE DATABASE AND ALL OSCOMMERCE FILES. THIS IS A VERY COMPLEX INSTALLATION AND THINGS MAY GO WRONG.

 

 

 

----------------------------------------------------------------

 

INSTALLATION

 

----------------------------------------------------------------

 

Open /catalog/checkout_process.php

 

 

 

-----------------------

 

FIND: (around line 199)

 

 

 

'products_options_values' => $attributes_values['products_options_values_name'],

 

 

 

REPLACE with

 

 

 

'products_options_values' => $order->products[$i]['attributes'][$j]['value'],

 

 

 

-----------------------

 

FIND: (around line 211)

 

 

 

$products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . $attributes_values['products_options_values_name'];

 

 

 

REPLACE with

 

 

 

$products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . tep_decode_specialchars($order->products[$i]['attributes'][$j]['value']);

 

 

 

----------------------------------------------------------------

 

Open /catalog/product_info.php

 

 

 

----------------------

 

FIND: (around line 27)

 

 

 

<script language="javascript">

 

function popupWindow(url) {

 

window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res

izable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,le

ft=150')

 

}

 

 

 

ADD BELOW:

 

 

 

/* DDB - 041031 - Form Field Progress Bar */

 

/***********************************************

 

* Form Field Progress Bar- By Ron Jonk- http://www.euronet.nl/~jonkr/

 

* Modified by Dynamic Drive for minor changes

 

* Script featured/ available at Dynamic Drive- http://www.dynamicdrive.com

 

* Please keep this notice intact

 

***********************************************/

 

function textCounter(field,counter,maxlimit,linecounter) {

 

// text width//

 

var fieldWidth = parseInt(field.offsetWidth);

 

var charcnt = field.value.length;

 

// trim the extra text

 

if (charcnt > maxlimit) {

 

field.value = field.value.substring(0, maxlimit);

 

} else {

 

// progress bar percentage

 

var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit);

 

document.getElementById(counter).style.width = parseInt((fieldWidth*percentage)/100)+"px";

 

document.getElementById(counter).innerHTML="Limit: "+percentage+"%"

 

// color correction on style from CCFFF -> CC0000

 

setcolor(document.getElementById(counter),percentage,"background-color");

 

}

 

}

 

function setcolor(obj,percentage,prop){

 

obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";

 

}

 

 

 

----------------------

 

FIND: (around line 157)

 

 

 

<?php

 

$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name 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 . "' order by popt.products_options_name");

 

while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {

 

 

 

REPLACE with:

 

 

 

<?php

 

//clr 030714 update query to pull option_type

 

$products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_type, popt.products_options_length, popt.products_options_comment 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 . "' order by popt.products_options_name");

 

while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {

 

//clr 030714 add case statement to check option type

 

switch ($products_options_name['products_options_type']) {

 

case PRODUCTS_OPTIONS_TYPE_TEXT:

 

//CLR 030714 Add logic for text option

 

$products_attribs_query = tep_db_query("select distinct patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'");

 

$products_attribs_array = tep_db_fetch_array($products_attribs_query);

 

$tmp_html = '<input type="text" name ="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']" size="' . $products_options_name['products_options_length'] .'" maxlength="' . $products_options_name['products_options_length'] . '" value="' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name['products_options_id']] .'"> ' . $products_options_name['products_options_comment'];

 

if ($products_attribs_array['options_values_price'] != '0') {

 

$tmp_html .= '(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .')';

 

}

 

?>

 

<tr>

 

<td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>

 

<td class="main"><?php echo $tmp_html; ?></td>

 

</tr>

 

<?php

 

break;

 

 

 

case PRODUCTS_OPTIONS_TYPE_TEXTAREA:

 

//CLR 030714 Add logic for text option

 

$products_attribs_query = tep_db_query("select distinct patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'");

 

$products_attribs_array = tep_db_fetch_array($products_attribs_query);

 

$tmp_html = '<textarea onKeyDown="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')"

 

onKeyUp="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')"

 

onFocus="textCounter(this,\'progressbar' . $products_options_name['products_options_id'] . '\',' . $products_options_name['products_options_length'] . ')"

 

wrap="soft"

 

name="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']"

 

rows=5

 

id="id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']"

 

value="' . $cart->contents[$HTTP_GET_VARS['products_id']]['attributes_values'][$products_options_name['products_options_id']] . '"></textarea>

 

<div id="progressbar' . $products_options_name['products_options_id'] . '" class="progress"></div>

 

<script>textCounter(document.getElementById("id[' . TEXT_PREFIX . $products_options_name['products_options_id'] . ']"),"progressbar' . $products_options_name['products_options_id'] . '",' . $products_options_name['products_options_length'] . ')</script>';?> <!-- DDB - 041031 - Form Field Progress Bar //-->

 

<tr>

 

<?php

 

if ($products_attribs_array['options_values_price'] != '0') {

 

?>

 

<td class="main"><?php echo $products_options_name['products_options_name'] . '<br>(' . $products_options_name['products_options_comment'] . ' ' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . ')'; ?></td>

 

<?php } else {

 

?>

 

<td class="main"><?php echo $products_options_name['products_options_name'] . '<br>(' . $products_options_name['products_options_comment'] . ')'; ?></td>

 

<?php }

 

?>

 

<td class="main"><?php echo $tmp_html; ?></td>

 

</tr>

 

<?php

 

break;

 

 

 

case PRODUCTS_OPTIONS_TYPE_RADIO:

 

//CLR 030714 Add logic for radio buttons

 

$tmp_html = '<table>';

 

$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)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");

 

$checked = true;

 

while ($products_options_array = tep_db_fetch_array($products_options_query)) {

 

$tmp_html .= '<tr><td class="main">';

 

$tmp_html .= tep_draw_radio_field('id[' . $products_options_name['products_options_id'] . ']', $products_options_array['products_options_values_id'], $checked);

 

$checked = false;

 

$tmp_html .= $products_options_array['products_options_values_name'];

 

$tmp_html .=$products_options_name['products_options_comment'];

 

if ($products_options_array['options_values_price'] != '0') {

 

$tmp_html .= '(' . $products_options_array['price_prefix'] . $currencies->display_price($products_options_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

 

}

 

$tmp_html .= '</tr></td>';

 

}

 

$tmp_html .= '</table>';

 

?>

 

<tr>

 

<td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>

 

<td class="main"><?php echo $tmp_html; ?></td>

 

</tr>

 

<?php

 

break;

 

case PRODUCTS_OPTIONS_TYPE_CHECKBOX:

 

//CLR 030714 Add logic for checkboxes

 

$products_attribs_query = tep_db_query("select distinct patrib.options_values_id, patrib.options_values_price, patrib.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = '" . $products_options_name['products_options_id'] . "'");

 

$products_attribs_array = tep_db_fetch_array($products_attribs_query);

 

echo '<tr><td class="main">' . $products_options_name['products_options_name'] . ': </td><td class="main">';

 

echo tep_draw_checkbox_field('id[' . $products_options_name['products_options_id'] . ']', $products_attribs_array['options_values_id']);

 

echo $products_options_name['products_options_comment'];

 

if ($products_attribs_array['options_values_price'] != '0') {

 

echo '(' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

 

}

 

echo '</td></tr>';

 

break;

 

default:

 

//clr 030714 default is select list

 

//clr 030714 reset selected_attribute variable

 

$selected_attribute = false;

 

 

 

----------------------

 

FIND: (around line 264)

 

 

 

<td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>

 

</tr>

 

<?php

 

}

 

?>

 

 

 

REPLACE with

 

 

 

<td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . $products_options_name['products_options_comment']; ?></td>

 

</tr>

 

<?php

 

} //clr 030714 end switch

 

} //clr 030714 end while

 

?>

 

 

 

----------------------------------------------------------------

 

Open catalog/shopping_cart.php

 

 

 

----------------------

 

FIND: (around line 81)

 

 

 

echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);

 

 

 

REPLACE with (comment out)

 

 

 

//clr 030714 move hidden field to if statement below

 

//echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);

 

 

 

----------------------

 

FIND: (around line 92)

 

 

 

$attributes_values = tep_db_fetch_array($attributes);

 

 

 

ADD BELOW:

 

 

 

//clr 030714 determine if attribute is a text attribute and assign to $attr_value temporarily

 

if ($value == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {

 

echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . TEXT_PREFIX . $option . ']', $products[$i]['attributes_values'][$option]);

 

$attr_value = $products[$i]['attributes_values'][$option];

 

} else {

 

echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);

 

$attr_value = $attributes_values['products_options_values_name'];

 

}

 

 

 

FIND: (around line 95)

 

 

 

$products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name'];

 

 

 

REPLACE with:

 

 

 

//clr 030714 assign $attr_value

 

$products[$i][$option]['products_options_values_name'] = $attr_value;

 

 

 

----------------------------------------------------------------

 

Open catalog/stylesheet.css

 

 

 

ADD AT END OF FILE:

 

 

 

/* DDB - 041031 - Form Field Progress Bar */

 

.progress{

 

width: 1px;

 

height: 14px;

 

color: white;

 

font-size: 12px;

 

overflow: hidden;

 

background-color: navy;

 

padding-left: 5px;}

 

}

 

 

 

----------------------------------------------------------------

 

Open catalog/includes/configure.php

 

 

 

ADD BEFORE ENDING ?>

 

 

 

// CLR 020605 defines needed for Product Option Type feature.

 

define('PRODUCTS_OPTIONS_TYPE_SELECT', 0);

 

define('PRODUCTS_OPTIONS_TYPE_TEXT', 1);

 

define('PRODUCTS_OPTIONS_TYPE_RADIO', 2);

 

define('PRODUCTS_OPTIONS_TYPE_CHECKBOX', 3);

 

define('PRODUCTS_OPTIONS_TYPE_TEXTAREA', 4);

 

define('TEXT_PREFIX', 'txt_');

 

define('PRODUCTS_OPTIONS_VALUE_TEXT_ID', 0); //Must match id for user defined "TEXT" value in db table TABLE_PRODUCTS_OPTIONS_VALUES

 

 

 

----------------------------------------------------------------

 

Open catalog/includes/class/order.php

 

 

 

-----------------------

 

FIND: (around line 232)

 

 

 

$attributes = tep_db_fetch_array($attributes_query);

 

 

 

ADD BELOW:

 

 

 

//clr 030714 Determine if attribute is a text attribute and change products array if it is.

 

if ($value == PRODUCTS_OPTIONS_VALUE_TEXT_ID){

 

$attr_value = $products[$i]['attributes_values'][$option];

 

} else {

 

$attr_value = $attributes['products_options_values_name'];

 

}

 

 

 

-----------------------

 

FIND: (around line 240)

 

 

 

'value' => $attributes['products_options_values_name'],

 

 

 

REPLACE with

 

 

 

'value' => $attr_value,

 

 

 

----------------------------------------------------------------

 

Open catalog/includes/class/shopping_cart.php

 

 

 

----------------------

 

FIND: (around line 36)

 

 

 

tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");

 

 

 

REPLACE with

 

 

 

//clr 031714 udate query to include attribute value. This is needed for text attributes.

 

$attr_value = $this->contents[$products_id]['attributes_values'][$option]; tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");

 

 

 

----------------------

 

FIND: (around line 52)

 

 

 

$attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");

 

 

 

REPLACE with

 

 

 

//CLR 020606 update query to pull attribute value_text. This is needed for text attributes.

 

$attributes_query = tep_db_query("select products_options_id, products_options_value_id, products_options_value_text from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");

 

 

 

----------------------

 

FIND: (around line 54)

 

 

 

while ($attributes = tep_db_fetch_array($attributes_query)) {

 

$this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];

 

 

 

ADD BELOW

 

 

 

//CLR 020606 if text attribute, then set additional information

 

if ($attributes['products_options_value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {

 

$this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text'];

 

}

 

 

 

----------------------

 

FIND: (around line 88)

 

 

 

$products_id_string = tep_get_uprid($products_id, $attributes);

 

$products_id = tep_get_prid($products_id_string);

 

 

 

if (is_numeric($products_id) && is_numeric($qty)) {

 

$check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");

 

$check_product = tep_db_fetch_array($check_product_query);

 

 

 

if (($check_product !== false) && ($check_product['products_status'] == '1')) {

 

 

 

REPLACE with

 

 

 

$products_id = tep_get_uprid($products_id, $attributes);

 

 

 

----------------------

 

FIND: (around line 97)

 

 

 

if ($this->in_cart($products_id_string)) {

 

$this->update_quantity($products_id_string, $qty, $attributes);

 

} else {

 

$this->contents[$products_id_string] = array('qty' => $qty);

 

 

 

REPLACE with

 

 

 

if ($this->in_cart($products_id)) {

 

$this->update_quantity($products_id, $qty, $attributes);

 

} else {

 

$this->contents[] = array($products_id);

 

$this->contents[$products_id] = array('qty' => $qty);

 

 

 

----------------------

 

FIND: (around line 99)

 

 

 

if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$qty . "', '" . date('Ymd') . "')");

 

 

 

REPLACE with

 

 

 

if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

 

 

 

-----------------------

 

FIND: (around line 105)

 

 

 

$this->contents[$products_id_string]['attributes'][$option] = $value;

 

 

 

REPLACE with

 

 

 

//CLR 020606 check if input was from text box. If so, store additional attribute information

 

//CLR 020708 check if text input is blank, if so do not add to attribute lists

 

//CLR 030228 add htmlspecialchars processing. This handles quotes and other special chars in the user input.

 

$attr_value = NULL;

 

$blank_value = FALSE;

 

if (strstr($option, TEXT_PREFIX)) {

 

if (trim($value) == NULL)

 

{

 

$blank_value = TRUE;

 

} else {

 

$option = substr($option, strlen(TEXT_PREFIX));

 

$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);

 

$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;

 

$this->contents[$products_id]['attributes_values'][$option] = $attr_value;

 

}

 

}

 

 

 

if (!$blank_value)

 

{

 

$this->contents[$products_id]['attributes'][$option] = $value;

 

 

 

-----------------------

 

FIND: (around line 106)

 

 

 

if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "')");

 

 

 

REPLACE with

 

 

 

//CLR 020606 update db insert to include attribute value_text. This is needed for text attributes.

 

//CLR 030228 add tep_db_input() processing

 

if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");

 

}

 

 

 

-----------------------

 

FIND: (around line 117)

 

 

 

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure

 

$this->cartID = $this->generate_cart_id();

 

}

 

}

 

}

 

 

 

REPLACE with

 

 

 

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure

 

$this->cartID = $this->generate_cart_id();

 

}

 

 

 

-----------------------

 

FIND: (around line 123)

 

 

 

$products_id_string = tep_get_uprid($products_id, $attributes);

 

$products_id = tep_get_prid($products_id_string);

 

 

 

REPLACE with

 

 

 

if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

 

 

 

-----------------------

 

FIND: (around line 126)

 

 

 

if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity)) {

 

$this->contents[$products_id_string] = array('qty' => $quantity);

 

 

 

REPLACE with

 

 

 

$this->contents[$products_id] = array('qty' => $quantity);

 

 

 

-----------------------

 

FIND: (around line 128)

 

 

 

if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

 

 

 

REPLACE with

 

 

 

if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

 

 

 

-----------------------

 

FIND: (around line 133)

 

 

 

$this->contents[$products_id_string]['attributes'][$option] = $value;

 

 

 

REPLACE with

 

 

 

//CLR 020606 check if input was from text box. If so, store additional attribute information

 

//CLR 030108 check if text input is blank, if so do not update attribute lists

 

//CLR 030228 add htmlspecialchars processing. This handles quotes and other special chars in the user input.

 

$attr_value = NULL;

 

$blank_value = FALSE;

 

if (strstr($option, TEXT_PREFIX)) {

 

if (trim($value) == NULL)

 

{

 

$blank_value = TRUE;

 

} else {

 

$option = substr($option, strlen(TEXT_PREFIX));

 

$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);

 

$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;

 

$this->contents[$products_id]['attributes_values'][$option] = $attr_value;

 

}

 

}

 

 

 

if (!$blank_value)

 

{

 

$this->contents[$products_id]['attributes'][$option] = $value;

 

 

 

-----------------------

 

FIND: (around line 135)

 

 

 

if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "' and products_options_id = '" . (int)$option . "'");

 

 

 

REPLACE with

 

 

 

//CLR 020606 update db insert to include attribute value_text. This is needed for text attributes.

 

//CLR 030228 add tep_db_input() processing

 

if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");

 

 

 

-----------------------

 

FIND: (around line 186)

 

 

 

global $customer_id;

 

 

 

ADD BELOW:

 

 

 

//CLR 030228 add call tep_get_uprid to correctly format product ids containing quotes

 

$products_id = tep_get_uprid($products_id, $attributes);

 

 

 

-----------------------

 

FIND: (around line 305)

 

 

 

'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));

 

 

 

REPLACE with

 

 

 

'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),

 

'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''));

 

 

 

----------------------------------------------------------------

 

Open catalog/includes/functions/general.php

 

 

 

---------------------

 

FIND: (around line 25)

 

 

 

function tep_redirect($url) {

 

if ( (strstr($url, "\n") != false) || (strstr($url, "\r") != false) ) {

 

tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false));

 

}

 

 

 

REPLACE with

 

 

 

function tep_redirect($url) {

 

 

 

----------------------

 

FIND: (around line 970)

 

 

 

////

 

// Return a product ID with attributes

 

function tep_get_uprid($prid, $params) {

 

if (is_numeric($prid)) {

 

$uprid = $prid;

 

 

 

if (is_array($params) && (sizeof($params) > 0)) {

 

$attributes_check = true;

 

$attributes_ids = '';

 

 

 

reset($params);

 

while (list($option, $value) = each($params)) {

 

if (is_numeric($option) && is_numeric($value)) {

 

$attributes_ids .= '{' . (int)$option . '}' . (int)$value;

 

} else {

 

$attributes_check = false;

 

break;

 

}

 

}

 

 

 

if ($attributes_check == true) {

 

$uprid .= $attributes_ids;

 

}

 

}

 

} else {

 

$uprid = tep_get_prid($prid);

 

 

 

if (is_numeric($uprid)) {

 

if (strpos($prid, '{') !== false) {

 

$attributes_check = true;

 

$attributes_ids = '';

 

 

 

// strpos()+1 to remove up to and including the first { which would create an empty array element in explode()

 

$attributes = explode('{', substr($prid, strpos($prid, '{')+1));

 

 

 

for ($i=0, $n=sizeof($attributes); $i<$n; $i++) {

 

$pair = explode('}', $attributes[$i]);

 

 

 

if (is_numeric($pair[0]) && is_numeric($pair[1])) {

 

$attributes_ids .= '{' . (int)$pair[0] . '}' . (int)$pair[1];

 

} else {

 

$attributes_check = false;

 

break;

 

}

 

}

 

 

 

if ($attributes_check == true) {

 

$uprid .= $attributes_ids;

 

}

 

}

 

} else {

 

return false;

 

}

 

}

 

 

 

return $uprid;

 

}

 

 

 

REPLACE with

 

 

 

////

 

// Return a product ID with attributes

 

function tep_get_uprid($prid, $params) {

 

$uprid = $prid;

 

if ( (is_array($params)) && (!strstr($prid, '{')) ) {

 

while (list($option, $value) = each($params)) {

 

//CLR 030714 Add processing around $value. This is needed for text attributes.

 

$uprid = $uprid . '{' . $option . '}' . htmlspecialchars(stripslashes(trim($value)), ENT_QUOTES);

 

}

 

//CLR 030228 Add else stmt to process product ids passed in by other routines.

 

} else {

 

$uprid = htmlspecialchars(stripslashes($uprid), ENT_QUOTES);

 

}

 

return $uprid;

 

}

 

 

 

 

 

ADD before ending >?

 

 

 

// Decode string encoded with htmlspecialchars()

 

function tep_decode_specialchars($string){

 

$string=str_replace('>', '>', $string);

 

$string=str_replace('<', '<', $string);

 

$string=str_replace(''', "'", $string);

 

$string=str_replace('"', "\"", $string);

 

$string=str_replace('&', '&', $string);

 

 

 

return $string;

 

}

 

 

 

----------------------------------------------------------------

 

Open catalog/admin/product_attributes.php

 

 

 

----------------------

 

FIND: (around line 30)

 

 

 

$option_name_array = $HTTP_POST_VARS['option_name'];

 

 

 

for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {

 

$option_name = tep_db_prepare_input($option_name_array[$languages[$i]['id']]);

 

 

 

tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, products_options_name, language_id) values ('" . (int)$products_options_id . "', '" . tep_db_input($option_name) . "', '" . (int)$languages[$i]['id'] . "')");

 

 

 

 

 

REPLACE with

 

 

 

$option_name_array = $HTTP_POST_VARS['option_name'];

 

$option_type = $HTTP_POST_VARS['option_type']; //clr 030714 update to add option type to products_option

 

$option_length = $HTTP_POST_VARS['option_length']; //clr 030714 update to add option length to products_option

 

 

 

for ($i=0, $n=sizeof($languages); $i<$n; $i ++) {

 

$option_name = tep_db_prepare_input($option_name_array[$languages[$i]['id']]);

 

$option_comment = $HTTP_POST_VARS['option_comment']; //clr 030714 update to add option comment to products_option

 

 

 

tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, products_options_name, language_id, products_options_type, products_options_length, products_options_comment) values ('" . (int)$products_options_id . "', '" . tep_db_input($option_name) . "', '" . (int)$languages[$i]['id'] . "', '" . $option_type . "', '" . $option_length . "', '" . $option_comment[$languages[$i]['id']] . "')");

 

if($option_type != 0 && $option_type != 2){

 

 


We must be the change we wish to see in the world.

------------------------------------------------------------

p.s. BACKUP!

Share this post


Link to post
Share on other sites
(emandell @ Jul 17 2006, 09:07 AM)

 

Has anyone seem a problem with this contribution with it creating duplicate Option Values?

 

I added the three option values in via the database script insert_text_option.sql

I created a product option for Custom Name with a type of text

Now every time I add another product attribute of Custom Name to a product it adds another Option Value with id=0 Option Name=Custom Name Option Value=TEXT

 

It all seems to work ok, but if its going to create 3 option values for every product attribute with a type of text then its going to get pretty polluted

 

Is this how its meant to work?

 

 

Did anyone ever find a solution to this? I am having the same problem.

 

Thanks!

 

 

Anyone??? :-"

Edited by ugh

Share this post


Link to post
Share on other sites
When this happened to me, I went into my database with phpmyadmin and edited the product_options_type_select. Some of those values were incorrectly "0" (dropdown), when they should be "1" (text field).

 

I know this is an older post, but when I go to my database, I don't have the "product_options_type_select" line in the database?! Because that would solve my problem. Basicly, everything is a dropdown menu. Buttons, checkboxes, text area, etc.. are all just dropdown menus! Which is great if I am using a dropdown menu, but I mostly need text fields. I have re-installed this a couple times, on a fresh install and manually. So, I am guessing my problem is a database problem. Anyone have any ideas. I am not great with the database part (I have phpmyadmin).

phpmyadmin.gif

I think this pic includes all the attribute fields... are there any missing like the one stated above where the values were incorrect?

 

Sorry for asking about this so much... but I just can't get it fixed!

Share this post


Link to post
Share on other sites

I was jsut looking voer the .sql files I used to install the contrib and I did not notice sucha field to be created int he database. However, pouring over the instructions I posted earlier for you, you'll notice it in there, but it's not referring to the database as it's a value within the PHP code. Here is the SQL scripts I used for the contrib, psoted below. Compare them to yours to see if there are any differences:

 

ALTER TABLE products_options

 ADD products_options_type INT( 5 ) NOT NULL ,

 ADD products_options_length SMALLINT( 2 ) DEFAULT '32' NOT NULL ,

 ADD products_options_comment VARCHAR( 32 );



ALTER TABLE customers_basket_attributes

 ADD products_options_value_text text;

 

INSERT INTO products_options_values (products_options_values_id, language_id, products_options_values_name) VALUES (0, 1, 'TEXT');

INSERT INTO products_options_values (products_options_values_id, language_id, products_options_values_name) VALUES (0, 2, 'TEXT');

INSERT INTO products_options_values (products_options_values_id, language_id, products_options_values_name) VALUES (0, 3, 'TEXT');

 

those are what iw as working with. I hope this helps you, even if it's just a little bit.


We must be the change we wish to see in the world.

------------------------------------------------------------

p.s. BACKUP!

Share this post


Link to post
Share on other sites

Hello there. I'm triying to install this on the very last OScommerce release, that fixes some SQL injection problems in classes-shopping_cart, but I cannot seem to be able to merge the files with the manual instalation. There are lines from the newer edition that make me think that actually the contribution was not really updated for the latest security fixes and the manual instalation is not really made for the last august release of OSC. I would appreciate any help with the merging of this last release of Osc with the last release of this contribution, specially on that file that is the only one giving me trouble. Thanks

Share this post


Link to post
Share on other sites

Is it possible to make the price of the product change based on what the customer types in the text field?

The customer chooses how many meters of fabric they want to purchase, but the price is the same, even though they typed 10meters..

 

I have added all the possible choices of length in the attributes database, but I dont like to have a drop down box for choosing length, thats why I tried this contrib.

 

So if the price either can be calculated based on $products_price multiplied by length or if it can use the text the user types in to query the mysql database and find the product option price based on the product option name they just typed in.

 

Is is possible to modify the code to do this? How, where?

Share this post


Link to post
Share on other sites
Can I delete the fields in the database and redo the database part of this? Which fields would I delete? I think product_options, product_option_values, and product_option_values_to_product_options seem to be related to this contribution. Do I delete those 3 and run the database part again?

 

And also this part: "IMPORTANT: You should create *exactly one* TEXT Option Value.? Once you create this value, you should not change it." Is that something for the manual creation or if you use the enclosed sql file. I still cant get a text box... just a drop down menu with the word text!

 

OK, so I figured out why I was only getting drop down menus.. just in case anyone else had this problem too! I also installed the STS v4.2 (simple template) that was messing it up. Once I disabled the product info template, it was just fine!

Share this post


Link to post
Share on other sites

I use this and contrib and was planning on using Options as Images as well, However when I turn on options as images, the Option Type Feature ceases to work, giving me dropdown list rather then text boxes. Why would this occur? I highly doubt that one could affect the other.


We must be the change we wish to see in the world.

------------------------------------------------------------

p.s. BACKUP!

Share this post


Link to post
Share on other sites
OK, so I figured out why I was only getting drop down menus.. just in case anyone else had this problem too! I also installed the STS v4.2 (simple template) that was messing it up. Once I disabled the product info template, it was just fine!

 

 

 

I have this problem too. I installed on a fresh install so I don't have anyother contributions but this one and I still get only a drop down menu. do you have any advice?

Share this post


Link to post
Share on other sites

Hello.

 

Great contribution ! However I got one problem. When using the text field it will not remember the text to the left of the box as the original attributte logic does. Example:

 

Original logic looks like this:

Size: X-large

 

The text "Size: X-large" will be shown in cart, order confirmation etc.

 

This contribution with text box:

Name: Peter

 

Only "Peter" will be shown in cart, order confirmation etc.

 

What is wrong ?

Share this post


Link to post
Share on other sites

Hello,

 

can anyone tell me to how to add a field to an already created Attribute Set and have that field appear on all the products that use that set? basically i have a drop down with 4 choices and i want to add a fifth choice. if i go into my admin section, select attribute sets and the click to edit a set i see an option to remove a set element but nothing to add one.

 

can this be done through mysql? if so what do i need to change?

 

thanks

Share this post


Link to post
Share on other sites
I have this problem too. I installed on a fresh install so I don't have anyother contributions but this one and I still get only a drop down menu. do you have any advice?

 

 

Sorry no. For me it was the the template contribution I added (sts). When I disabled it, it worked. I tried another (imprint text options) thinking it was that I installed it wrong, but had the same problem. Best of luck, I feel your pain.

Share this post


Link to post
Share on other sites
Sorry no. For me it was the the template contribution I added (sts). When I disabled it, it worked. I tried another (imprint text options) thinking it was that I installed it wrong, but had the same problem. Best of luck, I feel your pain.

 

 

I also do not get it to work; fresh install of oscommerce?!

Is it possible to send screenshots of your database where the changes are maid??

I think that there is the prblem, because i had difficulties understanding the "Readme.html" related to the database.

Share this post


Link to post
Share on other sites
I also do not get it to work; fresh install of oscommerce?!

Is it possible to send screenshots of your database where the changes are maid??

I think that there is the prblem, because i had difficulties understanding the "Readme.html" related to the database.

 

I didn't make any changes to the database, again, I just disabled my sts contribution.

Share this post


Link to post
Share on other sites
I have the exact same problem. What is interesting to me, is that the text area is perfect when viewed in FireFox, super skinny in Internet Explorer, and non-existant in Opera.

 

I could sure use some help also, because this contribution is exactly what I need. I need it to work on at least IE6 and Firefox though.

 

Please, someone help us!!

 

Thanks.

 

I am having the same problem! Looking through the code on product_info.php I see that it sets the number of rows, but not the width. How do we add that? I tried just adding COLS=20 below where it says rows=5, but that did nothing. How can I define the width of the textarea box using php code, which I know little about!?!

 

Thanks, Karen

Share this post


Link to post
Share on other sites
I didn't make any changes to the database, again, I just disabled my sts contribution.

 

I do not have STS-contribution installed: just a fresh install of oscommerce.

That is way: please screenshots of your database the tables:

 

table products_options

table customer_basket_attributes

table products_options_values

 

Than i ( and others ) can take a look of waht we are doing wrong!

Share this post


Link to post
Share on other sites
I do not have STS-contribution installed: just a fresh install of oscommerce.

That is way: please screenshots of your database the tables:

 

table products_options

table customer_basket_attributes

table products_options_values

 

Than i ( and others ) can take a look of waht we are doing wrong!

 

 

 

Figured it out:

when uploading it failed on configure.php was the permission was set to 444!!! Duh !!

 

Thanks eveybody for there help

Share this post


Link to post
Share on other sites
OK, so I figured out why I was only getting drop down menus.. just in case anyone else had this problem too! I also installed the STS v4.2 (simple template) that was messing it up. Once I disabled the product info template, it was just fine!

 

I am not using any product templates and I am still only getting drop down menus. Any suggestions?


~Aleena

Share this post


Link to post
Share on other sites
Figured it out:

when uploading it failed on configure.php was the permission was set to 444!!! Duh !!

 

Thanks eveybody for there help

 

 

Well, double DUH!

 

That fixed my problem, too :blush:


~Aleena

Share this post


Link to post
Share on other sites
I do not have STS-contribution installed: just a fresh install of oscommerce.

That is way: please screenshots of your database the tables:

 

table products_options

table customer_basket_attributes

table products_options_values

 

Than i ( and others ) can take a look of waht we are doing wrong!

 

Glad you figured it out and posted your sollution for others with the same problem!!

Edited by kapearl

Share this post


Link to post
Share on other sites
Glad you figured it out and posted your sollution for others with the same problem!!

 

That is what the forum is all about !!

Share this post


Link to post
Share on other sites

Thanks for all the solutions posted so far!

 

One last problem: I am trying to set my text area input area (where the customer types) so that it is one line with 28 available characters.

 

Any suggestions?


~Aleena

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×