Jump to content
Zappo

[Contribution] Option Types v2

Recommended Posts

No word about the attribute id.

Headache's next chapter: I think I was on the totally wrong way. Even using the attributes id cause the same mix up.

 

In detail: In file attributeManagerInstant.class.php I did following where it is the case " * Updates the price and prefix in the products attribute table" starting at line about 240

 

1) I added one query to get the attributes id

$mmAqueryString = "select products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id= '" . $this->intPID . "' and options_id='" . $optionId . "' and options_values_id='" . $optionValueId . "' ";
$mmAquery = amDB::query($mmAqueryString);

while($res = amDB::fetchArray($mmAquery)) 
	$attrId = $res['products_attributes_id'];

 

2) I changed this

amDB::perform(TABLE_PRODUCTS_ATTRIBUTES,$data, 'update',"products_id='$this->intPID' and options_id='$optionId' and options_values_id='$optionValueId'");

to this

amDB::perform(TABLE_PRODUCTS_ATTRIBUTES,$data, 'update',"products_attributes_id='$attrId'");

So all selection go according to attribute id

 

3) To test that it picks the correct line I also write the attribute id into an other additional line of table products_attributes, so the array looks like this (just for testing)

	$data = array( 
		'options_values_price' => $price,
		'price_prefix' => $prefix,
		'options_price_calc' => $attrId
	);

 

What is the result?

1) Every price (or prefix update) goes to the correct line (I see always the matching attributes id written into my test field)

2) For all multi option options everything works perfectly

3) For text options it works only for the first option (of ie 3). When making changes to the second (according to option_id) then doesn't matter what I enter, the settings from previous option are copied into the next: price, prefix and sort order. It is not mixing the product_id's, but for sure the option id's

 

Honestly I have no idea what to do now

Edited by multimixer

Share this post


Link to post
Share on other sites

Honestly I have no idea what to do now

Maybe we should circumvent the problem:

How about detecting the CUTOMER-INPUT attribute, and make the input field behave like it does in products_attributes.php?

We could steal the code from products_attributes, and the only downside would be (one I would find a BIG downside) that the prices wouldn't get updated through AJAX.

I mostly use the Attribute Manager without submitting changes to the product itself (edit attributes, click BACK button), and that won't work in this situation...

But I believe if you would echo the price input fields with the correct names, they will get posted with the rest of the product information (And then be processed the same way as they would in the products_attributes.php file...)

Again, not really a solution. More like a workaround...

Edited by Zappo

Like Eek said... It never hurts to help!
----------------------------------------

Share this post


Link to post
Share on other sites

Again, not really a solution. More like a workaround...

 

Good news: I think I have the solution

Bad news: Not known (yet)

 

This was a headache: I could echo the correct attributes id everywhere and write it to any field of products attributes table, I could write anything to that table and to the correct line, just the price and prefix not. That brought me to the thought that the issue has nothing to do with database functions, but with the fact that the form does not recognize the input field correctly. How else is it possible that I have always the correct attributes id echoed beside the input field but wrong data goes to the DB?

 

And yes, of course: In attribute_manager.php (lines 235 - 245) we have

                   <span style="margin-right: 30px;">
                   <?php echo drawDropDownPrefix('id="prefix_'.$optionValueId.'" style="margin:3px 0px 3px 0px;" onChange="return amUpdate(\''.$optionId.'\',\''.$optionValueId.'\',\'prefix\');"',$optionValueInfo['prefix']);
                         echo tep_draw_input_field("price_$optionValueId",$optionValueInfo['price'],' style="margin:3px 0px 3px 0px;" id="price_'.$optionValueId.'" size="7" onfocus="amF(this)" onblur="amB(this)" onChange="return amUpdate(\''.$optionId.'\',\''.$optionValueId.'\',\'price\');"');
// - Zappo - Option Types v2 - Placed Back & Adjusted Sort order from original AttributeManager (Needed this after all ;D)
                         echo tep_draw_input_field("sortOrder_$optionValueId",$optionValueInfo['sortOrder'],' style="margin:3px 0px 3px 0px;" id="sortOrder_'.$optionValueId.'" size="3" onChange="return amUpdate(\''.$optionId.'\',\''.$optionValueId.'\');"'); ?>
				</span>

 

We see that 2 selectors are used, $optionId and $optionValueId, the id for the field is set by $optionValueId. In text options the $optionValueId is not unique (always 0) thats why the mess. And what is the only unique thing? the attributes ID ! So, why not to use it?

 

First I set (about line 190)

<?php
		if(0 < $numValues){
			foreach($optionInfo['values'] as $optionValueId => $optionValueInfo) {
	// BOF fix priceupdate for text options multimixer 18 4 10
			$ProductsAttributesid = $optionValueInfo['products_attributes_id'];
	// EOF fix priceupdate for text options multimixer 18 4 10
?>

Then In lines 235 - 245 I use the attribute id instead (and additional) to the options values id

                   <span style="margin-right: 30px;">
                   <?php 
				// BOF fix priceupdate for text options multimixer 18 4 10 use attributes id instead of option values id
				echo drawDropDownPrefix('id="prefix_'.$ProductsAttributesid.'" style="margin:3px 0px 3px 0px;" onChange="return amUpdate(\''.$optionId.'\',\''.$optionValueId.'\',\''.$ProductsAttributesid.'\',\'prefix\');"',$optionValueInfo['prefix']);
                                      echo tep_draw_input_field("price_$ProductsAttributesid",$optionValueInfo['price'],' style="margin:3px 0px 3px 0px;" id="price_'.$ProductsAttributesid.'" size="7" onfocus="amF(this)" onblur="amB(this)" onChange="return amUpdate(\''.$optionId.'\',\''.$optionValueId.'\',\''.$ProductsAttributesid.'\',\'price\');"');
// - Zappo - Option Types v2 - Placed Back & Adjusted Sort order from original AttributeManager (Needed this after all ;D)
                                     echo tep_draw_input_field("sortOrder_$ProductsAttributesid",$optionValueInfo['sortOrder'],' style="margin:3px 0px 3px 0px;" id="sortOrder_'.$ProductsAttributesid.'" size="3" onChange="return amUpdate(\''.$optionId.'\',\''.$optionValueId.'\',\''.$ProductsAttributesid.'\');"'); 
				// EOF fix priceupdate for text options multimixer 18 4 10
					  ?>
				</span>

 

Now, the last thing is to update the attributeManager.js file to use the right selector, so, lines 103 - 144 look now like this

// multimixer 18 4 10 fix priceupdate for text options, use attributes id instead of option values id
function amUpdate(optionId, optionValueId, ProductsAttributesid, optionSender) { // mm 18 4 10 added ProductsAttributesid
if (typeof optionSender=="undefined") {
	optionSender='na';
}
prefix=getDropDownValue('prefix_'+ProductsAttributesid); // mm 18 4 10 replaced optionValueId by ProductsAttributesid
price=getDropDownValue('price_'+ProductsAttributesid); // mm 18 4 10 replaced optionValueId by ProductsAttributesid
if((optionSender=='prefix')&&((prefix=='')||(prefix==' '))){
	price='0';
}
if(price.indexOf('-')==0){
	prefix='-';
	setDropDownValue('prefix_'+ProductsAttributesid,'-','s'); // mm 18 4 10 replaced optionValueId by ProductsAttributesid
	price=price.substr(1);
}
price=parseFloat(price);
if(isNaN(price)){
	price=0;
}else{
	price*=10000;
	price=Math.round(price);
	price=price/10000;
}
price=price+'';
if(price.indexOf(".")<0){
	price+='.';
}
while(price.length-price.indexOf(".")<5){
	price+='0';
}
setDropDownValue('price_'+ProductsAttributesid,price,'i'); // mm 18 4 10 replaced optionValueId by ProductsAttributesid

if((price!='0.0000')&&((prefix=='')||(prefix==' '))){
	setDropDownValue('prefix_'+ProductsAttributesid,'%2B','s');//+ // mm 18 4 10 replaced optionValueId by ProductsAttributesid
}

amSendRequest('amAction=update&option_id='+optionId+'&option_value_id='+optionValueId+'&price='+getDropDownValue('price_'+ProductsAttributesid)+'&prefix='+getDropDownValue('prefix_'+ProductsAttributesid)+'&sortOrder='+getDropDownValue('sortOrder_'+ProductsAttributesid),'',false);
getElement('price_'+ProductsAttributesid).blur();
var el = getElement('sortOrder_'+ProductsAttributesid); // mm 18 4 10 replaced optionValueId by ProductsAttributesid 5 times
if(el != null) el.blur();
return false;
}

 

The result? Everything works very smooth now I tested a little around and could not find any issues.

 

It would be great anyway if somebody could apply this changes and test a bit more. I did everything on a modified rc2a with many changes also to option types, like sppc integration and some other homemade changes, some of them I posted already, some will follow

 

Now I go for a beer !

Share this post


Link to post
Share on other sites

Good news: I think I have the solution

........

Now I go for a beer !

That's great!

I currently have no time for testing (let alone updating, and releasing a new version), but I hope I can do this in the following weeks...

 

You go get that beer, you deserved it!

 

One step closer to perfection.

Thanks George!


Like Eek said... It never hurts to help!
----------------------------------------

Share this post


Link to post
Share on other sites

I have installed this contribution on my website. Eveything is working fine so far but when I am setting value length for textarea option its not working. After setting value length to text area its still taking unlimited characters...Why??? Please advice me how to make it work.

 

Thanks in Advance!!!

Share this post


Link to post
Share on other sites

After setting value length to text area its still taking unlimited characters...Why???

Good question.

- What does the % bar on product_info page say? Also unlimited?

- Is this also the case with normal text?

Could [edit] most likely [/edit] be a Javascript problem...

Edited by Zappo

Like Eek said... It never hurts to help!
----------------------------------------

Share this post


Link to post
Share on other sites

... but I hope I can do this in the following weeks...

 

Don't hurry with a new release. There are some more things that I did that could be included into a new release like:

1) Full sts integration (could be like a separate optional install folder)

2) Option calculation way per item or per unit

3) More optinos for image options (like preview, admin on/off and settings etc) + div based display

 

and some more small things that I don't remember. Even I have all running here at me, it all need still some ironing before posting.

Share this post


Link to post
Share on other sites

1) Full sts integration (could be like a separate optional install folder)

2) Option calculation way per item or per unit

3) More options for image options (like preview, admin on/off and settings etc) + div based display

Wow.

You've been busy!

Good stuff!


Like Eek said... It never hurts to help!
----------------------------------------

Share this post


Link to post
Share on other sites

Here we go with a new spicy thing for option types. As we all know, the option price is getting added to the products unit price and then multiplied by the chosen quantity. This makes sense for most of the cases but not for following

 

The case: There is a store than sells printed advertising pens. There are various options to choose from, colors, fonts etc etc. All of the options go per unit (pen) except one: the printed color proof. For this the customer needs to pay ie $10. Obviously not for each unit but just once per product.

 

So we have to cases of option price calculation

 

1) Per unit (product price:5 + option price:1 = 6 x quantity: 500 = total: 3000)

2) Per item (product price:5 x quantity: 500 = 2500 + option price:1 = total:2501)

 

To achieve this I made a solution where the option calculation way can be set (or changed) in the same way as you to for the option type in admin. There is also a text filed to insert a (optional) calculation way description such as per item, per meter, per beer, so that customers know whats going on

 

if you are interested read how to set the option calculation way per unit or per item

 

Involved files are:

admin/products_attributes.php

admin/orders.php

admin/invoice.php

admin/includes/local/configure.php

admin/includes/classes/order.php

admin/includes/languages/english/product_attributes.php

admin/attributeManager/classes/attributeManagerInstant.class.php (in case you use this)

 

account_history_info.php

checkout_confirmation.php

checkout_process.php

shopping_cart.php

 

includes/classes/shopping_cart.php

includes/classes/order.php

includes/classes/currencies.php

includes/modules/option_types.php

 

product_info.php

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

Add some more fields to the database

# osCommerce, Open Source E-Commerce Solutions
# http://www.oscommerce.com
#
# Database Changes for Option Types v2
#
# created by multimixer for http://multimixer.gr
#
# Released under the GNU General Public License


# Add choice for options price to be calculated per item (once) or per unit

# Add calculation way and name to the products_options table
ALTER TABLE products_options
  ADD products_options_price_calc INT( 1 ) DEFAULT '0' NOT NULL ,
  ADD products_options_per_name VARCHAR( 32 ) DEFAULT 'per unit'  NULL;

# Add calculation way to the products_attributes table
ALTER TABLE products_attributes
  ADD options_price_calc INT( 1 ) DEFAULT '0' NOT NULL;

# Add calculation name to the orders_products_attributes table
ALTER TABLE orders_products_attributes
  ADD options_per_name VARCHAR( 32 ) DEFAULT 'per unit'  NULL;

 

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

1. file admin/products_attributes.php

 

FIND (case 'add_product_options)

 
        $option_order = $_POST['option_order'];

ADD BELOW             

// BOF set price per unit / per item multimixer 15 4 10         
        $option_price_calculation = $_POST['option_price_calc'];
        $option_price_per_name_array = $_POST['option_per_name'];
// EOF set price per unit / per item multimixer 15 4 10        

 

FIND

         

 $option_comment = tep_db_prepare_input($option_cmmnt_array[$languages[$i]['id']]);

ADD BELOW              

// BOF set price per unit / per item multimixer 15 4 10         
          $option_price_per_name = tep_db_prepare_input($option_price_per_name_array[$languages[$i]['id']]);
// EOF set price per unit / per item multimixer 15 4 10 

 

FIND        

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, products_options_order) values ('" . (int)$products_options_id . "', '" . tep_db_input($option_name) . "', '" . (int)$languages[$i]['id'] . "', '" . $option_type . "', '" . $option_length . "', '" . tep_db_input($option_comment) . "', '" . $option_order . "')");

REPLACE WITH             

// mm set price per unit / per item 15 4 10 added products_options_price_calc, products_options_per_name AND '" . tep_db_input($option_price_calculation) . "', '" . tep_db_input($option_price_per_name) . "'
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, products_options_order, products_options_price_calc, products_options_per_name) values ('" . (int)$products_options_id . "', '" . tep_db_input($option_name) . "', '" . (int)$languages[$i]['id'] . "', '" . $option_type . "', '" . $option_length . "', '" . tep_db_input($option_comment) . "', '" . $option_order . "', '" . tep_db_input($option_price_calculation) . "', '" . tep_db_input($option_price_per_name) . "')");

 

FIND (case 'add_product_attributes')     

$products_options_query = tep_db_query("select products_options_type from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $_POST['options_id'] . "'");

REPLACE WITH

// mm set price per unit / per item 15 4 10 added products_options_price_calc
$products_options_query = tep_db_query("select products_options_type, products_options_price_calc from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $_POST['options_id'] . "'");

 

FIND   

     

   $value_order = tep_db_prepare_input($_POST['value_order']);

ADD BELOW        

// BOF set price per unit / per item multimixer 15 4 10 
        $option_price_calculation = $products_options_array['products_options_price_calc'];
// BOF set price per unit / per item multimixer 15 4 10

       

 

FIND  

tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values (null, '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . (float)tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "', '" . (int)$value_order . "')");

REPLACE WITH              

// mm set price per unit / per item 15 4 10 added '" . (int)$option_price_calculation . "'
tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values (null, '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . (float)tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "', '" . (int)$value_order . "',  '" . (int)$option_price_calculation . "' )");

 

FIND (case 'update_option_name')

       

 $option_id = tep_db_prepare_input($_POST['option_id']);

ADD BELOW          

// BOF set price per unit / per item multimixer 15 4 10         
        $option_price_calculation = $_POST['option_price_calc'];
        $option_price_per_name_array = $_POST['option_per_name'];
// EOF set price per unit / per item multimixer 15 4 10  

     

 

FIND

         

$option_comment = tep_db_prepare_input($option_cmmnt_array[$languages[$i]['id']]);

ADD BELOW              

// BOF set price per unit / per item multimixer 15 4 10         
          $option_price_per_name = tep_db_prepare_input($option_price_per_name_array[$languages[$i]['id']]);
// EOF set price per unit / per item multimixer 15 4 10 

 

FIND        

tep_db_query("update " . TABLE_PRODUCTS_OPTIONS . " set products_options_name = '" . tep_db_input($option_name) . "', products_options_comment = '" . tep_db_input($option_comment) . "', products_options_type = '" . $option_type . "', products_options_length = '" . $option_length . "', products_options_order = '" . $option_order . "' where products_options_id = '" . (int)$option_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");

REPLACE WITH              

// mm set price per unit / per item 15 4 10 added , products_options_price_calc = '" . tep_db_input($option_price_calculation) . "', products_options_per_name = '" . tep_db_input($option_price_per_name) . "'
tep_db_query("update " . TABLE_PRODUCTS_OPTIONS . " set products_options_name = '" . tep_db_input($option_name) . "', products_options_comment = '" . tep_db_input($option_comment) . "', products_options_type = '" . $option_type . "', products_options_length = '" . $option_length . "', products_options_order = '" . $option_order . "', products_options_price_calc = '" . tep_db_input($option_price_calculation) . "', products_options_per_name = '" . tep_db_input($option_price_per_name) . "' where products_options_id = '" . (int)$option_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
                  
// BOF set price per unit / per item multimixer 15 4 10         
tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . "  set options_price_calc = '" . tep_db_input($option_price_calculation) . "' where options_id = '" . (int)$option_id . "'");
// EOF set price per unit / per item multimixer 15 4 10 

 

FIND (case 'update_product_attribute')     

$products_options_query = tep_db_query("select products_options_type from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $_POST['options_id'] . "'");

REPLACE WITH      

// mm set price per unit / per item 15 4 10 added products_options_price_calc
$products_options_query = tep_db_query("select products_options_type, products_options_price_calc from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $_POST['options_id'] . "'");

 

FIND

       

$attribute_id = tep_db_prepare_input($_POST['attribute_id']);

ADD BELOW          

// BOF set price per unit / per item multimixer 15 4 10 
        $option_price_calculation = $products_options_array['products_options_price_calc'];
// EOF set price per unit / per item multimixer 15 4 10

       

 

FIND       

tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set products_id = '" . (int)$products_id . "', options_id = '" . (int)$options_id . "', options_values_id = '" . (int)$values_id . "', options_values_price = '" . (float)tep_db_input($value_price) . "', price_prefix = '" . tep_db_input($price_prefix) . "', products_options_sort_order = '" . tep_db_input($value_order) . "' where products_attributes_id = '" . (int)$attribute_id . "'");

REPLACE WITH               

// mm set price per unit / per item 15 4 10 added options_price_calc = '" . (int)$option_price_calculation . "'
tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set products_id = '" . (int)$products_id . "', options_id = '" . (int)$options_id . "', options_values_id = '" . (int)$values_id . "', options_values_price = '" . (float)tep_db_input($value_price) . "', price_prefix = '" . tep_db_input($price_prefix) . "', products_options_sort_order = '" . tep_db_input($value_order) . "', options_price_calc = '" . (int)$option_price_calculation . "' where products_attributes_id = '" . (int)$attribute_id . "'");

 

FIND

  return isset($products_options_types_list[$opt_type]) ? $products_options_types_list[$opt_type] : 'Error ' . $opt_type;
}
//EOF - Zappo - Option Types v2 - Define Option Types List

ADD BELOW

//BOF multimixer set price per unit / per item 15 4 10 - Define Calculation way list
  $products_options_calc_way[OPTIONS_PER_UNIT] = OPTIONS_PER_UNIT_NAME;
  $products_options_calc_way[OPTIONS_PER_ITEM] = OPTIONS_PER_ITEM_NAME;
// Draw a pulldown for calculation way
function draw_calcway_pulldown($name, $default = '') {
  global $products_options_calc_way;
  $values = array();
  foreach ($products_options_calc_way as $id => $text) {
    $values[] = array('id' => $id, 'text' => $text);
  }
  return tep_draw_pull_down_menu($name, $values, $default);
}
// Translate calculation way values to english string
function translate_type_to_name1($calc_way) {
  global $products_options_calc_way;
  return isset($products_options_calc_way[$calc_way]) ? $products_options_calc_way[$calc_way] : 'Error ' . $calc_way;
}
//EOF multimixer set price per unit / per item 15 4 10 - Define Calculation way list

 

FIND (in the html part)

               

<td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_COMMENT; ?> </td>

ADD BELOW

               

 <!-- BOF multimixer set price per unit / per item add 2 columns for calculation way and per name -->
                <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_CALC; ?> </td>
                <td class="dataTableHeadingContent"> <?php echo TABLE_HEADING_OPT_PER; ?> </td>
                <!-- EOF multimixer set price per unit / per item add 2 columns for calculation way and per name -->

 

You can also set the colspan from 7 to 9 to have the blackline expanding over the total header width

 

FIND

     

   $CommentInput = '';

ADD BELOW

       

$PerInput = ''; // multimixer 15 4 10 set price per unit / per item

 

FIND       

$option_name = tep_db_query("select products_options_name, products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $options_values['products_options_id'] . "' and language_id = '" . $languages[$i]['id'] . "'");

REPLACE WITH               

// multimixer set price per unit / per item 15 4 10 added products_options_per_name
$option_name = tep_db_query("select products_options_name, products_options_comment, products_options_per_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $options_values['products_options_id'] . "' and language_id = '" . $languages[$i]['id'] . "'");

 

FIND

         

 $CommentInput .= tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '   ' . TABLE_HEADING_OPT_COMMENT . '<br><input type="text" name="option_comment[' . $languages[$i]['id'] . ']" size="24" value="' . $option_name['products_options_comment'] . '"><br>';

ADD BELOW

         

// BOF multimixer 15 4 10 set price per unit / per item
          $PerInput .= tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '   ' . TABLE_HEADING_OPT_PER . '<br><input type="text" name="option_per_name[' . $languages[$i]['id'] . ']" size="24" value="' . $option_name['products_options_per_name'] . '"><br>';
          // EOF multimixer 15 4 10 set price per unit / per item

 

FIND

               

<td class="smallText"><?php echo $NameInput; ?></td>
                <td class="smallText"><?php echo $CommentInput; ?></td>
                <td class="smallText" colspan="3"><?php echo TABLE_HEADING_OPT_LENGTH . ': <input type="text" name="option_length" size="4" value="' . $options_values['products_options_length'] . '"><br>' . 
                                                             TABLE_HEADING_OPT_ORDER . ': <input type="text" name="option_order" size="3" value="' . $options_values['products_options_order'] . '"><br>' . 
                                                             TABLE_HEADING_OPT_TYPE . ': ' . draw_optiontype_pulldown('option_type', $options_values['products_options_type']); ?></td>

REPLACE WITH

               

 <td class="smallText"><?php echo $NameInput; ?></td>
                 <td class="smallText"><?php echo  TABLE_HEADING_OPT_TYPE . ': ' . draw_optiontype_pulldown('option_type', $options_values['products_options_type']); ?></td>
                <td class="smallText"><?php echo TABLE_HEADING_OPT_ORDER . ': <input type="text" name="option_order" size="3" value="' . $options_values['products_options_order'] . '">' ; ?></td>
                <td class="smallText"><?php echo TABLE_HEADING_OPT_LENGTH . ': <input type="text" name="option_length" size="4" value="' . $options_values['products_options_length'] . '">' ; ?></td> 
                <td class="smallText"><?php echo $CommentInput; ?></td>
                <!-- BOF multimixer add 2 columns for calculation way and per name -->
                <td class="smallText"><?php echo TABLE_HEADING_OPT_CALC . ': ' . draw_calcway_pulldown('option_price_calc', $options_values['products_options_price_calc']) ; ?></td>
                <td class="smallText"><?php echo $PerInput; ?></td>
                <!-- EOF multimixer add 2 columns for calculation way and per name -->

This will give also a new structure to the table when pressing "update" for an option

 

FIND

               

<td class="smallText"><?php echo $options_values["products_options_comment"]; ?></td>

ADD BELOW

               

<!-- BOF multimixer set price per unit / per item add 2 columns for calculation way and per name -->
                <td class="smallText" align="center"><?php echo translate_type_to_name1($options_values["products_options_price_calc"]); ?></td>
                <td class="smallText"><?php echo $options_values["products_options_per_name"]; ?></td>
                <!-- EOF multimixer set price per unit / per item add 2 columns for calculation way and per name -->

 

FIND (again)

     

  $CommentInput = '';

ADD BELOW

     

   $PerInput = ''; // multimixer 15 4 10 set price per unit / per item

 

FIND

         

 $CommentInput .= tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '   ' . TABLE_HEADING_OPT_COMMENT . ':<br><input type="text" name="option_comment[' . $languages[$i]['id'] . ']" size="24"><br>';

ADD BELOW

       

   // BOF multimixer 15 4 10 add calculation way and per name
          $PerInput .= tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '   ' . TABLE_HEADING_OPT_PER . ':<br><input type="text" name="option_per_name[' . $languages[$i]['id'] . ']" size="24"><br>';
          // EOF multimixer 15 4 10 add calculation way and per name

 

FIND

               

<td align="center" class="smallText"> <?php echo $next_id; ?> </td>
                <td class="smallText"><?php echo $NameInput; ?></td>
                <td class="smallText"><?php echo $CommentInput; ?></td>
                <td class="smallText" colspan="3"><?php echo TABLE_HEADING_OPT_LENGTH . ': <input type="text" name="option_length" size="4"><br>' . 
                                                             TABLE_HEADING_OPT_ORDER . ': <input type="text" name="option_order" size="3"><br>' . 
                                                             TABLE_HEADING_OPT_TYPE . ': ' . draw_optiontype_pulldown('option_type'); ?></td>
                <td align="center" class="smallText"> <?php echo tep_image_submit('button_insert.gif', IMAGE_INSERT); ?> </td>

REPLACE WITH

             

   <td align="center" class="smallText"> <?php echo $next_id; ?> </td>
                <td class="smallText"><?php echo $NameInput; ?></td>
                <td class="smallText"><?php echo TABLE_HEADING_OPT_TYPE . ': ' . draw_optiontype_pulldown('option_type'); ?></td>
                <td class="smallText"><?php echo TABLE_HEADING_OPT_ORDER . ': <input type="text" name="option_order" size="3">' ; ?></td>
                <td class="smallText"><?php echo TABLE_HEADING_OPT_LENGTH . ': <input type="text" name="option_length" size="4">' ; ?></td> 
                <td class="smallText"><?php echo $CommentInput; ?></td>
                <!-- BOF multimixer set price per unit / per item add 2 columns for calculation way and per name -->
                <td class="smallText"><?php echo TABLE_HEADING_OPT_CALC . ': ' . draw_calcway_pulldown('option_price_calc'); ?></td>
                <td class="smallText"><?php echo $PerInput; ?></td>
                <!-- EOF multimixer set price per unit / per item add 2 columns for calculation way and per name -->
                <td align="center" class="smallText"> <?php echo tep_image_submit('button_insert.gif', IMAGE_INSERT); ?> </td>

Again you will see a new table structure in the "insert" area for options, I think it looks nicer

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

2. file admin/orders.php

 

FIND        

if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')';

REPLACE WITH               

 

// set price per unit / per item multimixer 15 4 10 added . ' ' . $order->products[$i]['attributes'][$j]['pername'] commented * $order->products[$i]['qty']
 if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] /** $order->products[$i]['qty']*/, true, $order->info['currency'], $order->info['currency_value']) . ' ' . $order->products[$i]['attributes'][$j]['pername'] . ')';

 

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

3. file admin/invoice.php

 

FIND        

if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')';

REPLACE WITH                 

// set price per unit / per item multimixer 15 4 10 added . ' ' . $order->products[$i]['attributes'][$j]['pername'] commented * $order->products[$i]['qty']
if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] /** $order->products[$i]['qty']*/, true, $order->info['currency'], $order->info['currency_value']) . ' ' . $order->products[$i]['attributes'][$j]['pername'] . ')';

 

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

4. file admin/includes/local/configure.php

 

ADD before the last ?>

//BOF multimixer set price per unit / per item 15 4 10 - Define Calculation way list
  define('OPTIONS_PER_UNIT', 0);
  define('OPTIONS_PER_UNIT_NAME', 'Per Unit'); //  (Names are just for displaying on admin side)
  define('OPTIONS_PER_ITEM', 1);
  define('OPTIONS_PER_ITEM_NAME', 'Per Item'); //  (Names are just for displaying on admin side)
//BOF multimixer set price per unit / per item 15 4 10 - Define Calculation way list

 

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

5 file admin/includes/classes/order.php

 

FIND     

$attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'")

;

REPLACE WITH

// set price per unit / per item multimixer 15 4 10     added , options_per_name        
$attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix, options_per_name from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");

 

FIND

'prefix' => $attributes['price_prefix'],

ADD BELOW

'pername' => $attributes['options_per_name'],
// set price per unit / per item multimixer 15 4 10 (line above added)

 

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

6 file admin/includes/languages/english/product_attributes.php

 

ADD before the last ?>

// BOF multimixer add defines for calculation way and per name
define('TABLE_HEADING_OPT_CALC', 'Calculation way');
define('TABLE_HEADING_OPT_PER', 'Calculation Description');
// EOF multimixer add defines for calculation way and 

per name

 

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

7 file admin/attributeManager/classes/attributeManagerInstant.class.php (if you use this)

 

FIND (function addAttributeToProduct($get))

               

 if(empty($prefix)){
                        $prefix=' ';
                }

ADD BELOW

 

// BOF set price per unit / per item multimixer 15 4 10
                        $mmqueryString = "select products_options_price_calc from ".TABLE_PRODUCTS_OPTIONS." where products_options_id='" . $optionId . "'";
                        $mmquery = amDB::query($mmqueryString);

                        while($res = amDB::fetchArray($mmquery))
                                $calcWay = $res['products_options_price_calc'];
  // EOF set price per unit / per item multimixer 15 4 10      

       

 

FIND

                       

 'price_prefix' => $prefix

 

REPLACE WITH

 

 // BOF set price per unit / per item multimixer 15 4 10       
                        'price_prefix' => $prefix,
                        'options_price_calc' => $calcWay
  // EOF set price per unit / per item multimixer 15 4 10      

 

Now go to your products attributes page in admin. You should see a new drop down with the calculation way options and a text input field for the description. If this is so, then go on

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

8 file account_history_info.php

 

FIND        

echo ' - (' . $order->products[$i]['attributes'][$j]['price_prefix'] . $currencies->display_price($order->products[$i]['attributes'][$j]['price'], tep_get_tax_rate($order->products[$i]['tax'])) . ')';

REPLACE WITH         

echo ' - (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->display_price($order->products[$i]['attributes'][$j]['price'], tep_get_tax_rate($order->products[$i]['tax'])) . ' ' . $order->products[$i]['attributes'][$j]['pername'] . ')';
// set price per unit / per item multimixer 15 4 10 added to line above . ' ' . $order->products[$i]['attributes'][$j]['pername']

 

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

9 file checkout_confirmation.php

 

FIND         

echo ' - (' . $order->products[$i]['attributes'][$j]['price_prefix'] . $currencies->display_price($order->products[$i]['attributes'][$j]['price'], tep_get_tax_rate($order->products[$i]['tax'])) . ')';

REPLACE WITH

echo '  (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->display_price($order->products[$i]['attributes'][$j]['price'], tep_get_tax_rate($order->products[$i]['tax'])) . ' ' . $order->products[$i]['attributes'][$j]['pername'] .')';
// set price per unit / per item multimixer 15 4 10 added to line above . ' ' . $order->products[$i]['attributes'][$j]['pername']

 

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

10 file checkout_process.php

 

FIND        

$attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename 

REPLACE WITH                     

// set price per unit / per item multimixer 15 4 10     added , popt.products_options_per_name  
$attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename, popt.products_options_per_name 

! attention not to mess up the query, I didn't post it all, just the part that change

 

FIND         

$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");

 

REPLACE WITH                      

// set price per unit / per item multimixer 15 4 10     added , popt.products_options_per_name  
$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, popt.products_options_per_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $languages_id . "' and poval.language_id = '" . $languages_id . "'");

 

FIND                             

'price_prefix' => $attributes_values['price_prefix']);

REPLACE WITH

'price_prefix' => $attributes_values['price_prefix'],
'options_per_name' => $attributes_values['products_options_per_name']);
// set price per unit / per item multimixer 15 4 10 (line above added

)

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

11 file shopping_cart.php

 

FIND     

$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix

REPLACE WITH

// set price per unit / per item multimixer 15 4 10	added , popt.products_options_per_name	
$attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, popt.products_options_per_name

 

Again: attention not to mess up the query, just the relevant part got posted here

   

FIND       

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

ADD BELOW

 $products[$i][$option]['products_options_per_name'] = $attributes_values['products_options_per_name']; 
// set price per unit / per item multimixer 15 4 10 (line above added)

 

FIND      

$Option_Price = ($products[$i][$option]['options_values_price'] != '0') ? ' - (' . $products[$i][$option]['price_prefix'] . $currencies->display_price($products[$i][$option]['options_values_price'], tep_get_tax_rate($products[$i]['tax_class_id'])) . ')' : '';

REPLACE WITH

$Option_Price = ($products[$i][$option]['options_values_price'] != '0') ? ' - (' . $products[$i][$option]['price_prefix'] . $currencies->display_price($products[$i][$option]['options_values_price'], tep_get_tax_rate($products[$i]['tax_class_id'])) . ' ' . $products[$i][$option]['products_options_per_name'] . ')' : '';
// set price per unit / per item multimixer 15 4 10: line above added ' ' . $products[$i][$option]['products_options_per_name']

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

12 file includes/classes/shopping_cart.php

 

FIND       

$attribute_price_query = tep_db_query("SELECT products_attributes_id, options_values_price, price_prefix FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . (int)$products_id . "'" . $where ."");

REPLACE WITH       

// BOF set price per unit / per item multimixer 15 4 10 added options_price_calc        
$attribute_price_query = tep_db_query("SELECT products_attributes_id, options_values_price, price_prefix, options_price_calc FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . (int)$products_id . "'" . $where ."");
// EOF set price per unit / per item multimixer 15 4 10

       

 

FIND

       

     if ($attribute_price[$n]['price_prefix'] == '+') {
              $this->total += $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax, $qty);
            } else {
              $this->total -= $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax, $qty);
        }

REPLACE WITH

       

 // BOF set price per unit / per item multimixer 15 4 10         
        if ($attribute_price[$n]['options_price_calc'] == '0') {
        // EOF set price per unit / per item multimixer 15 4 10         
            if ($attribute_price[$n]['price_prefix'] == '+') {
              $this->total += $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax, $qty);
            } else {
              $this->total -= $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax, $qty);
                }
        // BOF set price per unit / per item multimixer 15 4 10         
        } else {
            if ($attribute_price[$n]['price_prefix'] == '+') {
              $this->total += $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax);
            } else {
              $this->total -= $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax);
                }
        }               
        // EOF set price per unit / per item multimixer 15 4 10 

       

 

FIND (again)      

$attribute_price_query = tep_db_query("SELECT products_attributes_id, options_values_price, price_prefix FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . (int)$products_id . "'" . $where ."");

REPLACE WITH       

// BOF set price per unit / per item multimixer 15 4 10 added options_price_calc        
$attribute_price_query = tep_db_query("SELECT products_attributes_id, options_values_price, price_prefix, options_price_calc FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . (int)$products_id . "'" . $where ."");
// EOF set price per unit / per item multimixer 15 4 10

       

 

FIND(again)

       

    if ($attribute_price[$n]['price_prefix'] == '+') {
              $attributes_price += $attribute_price[$n]['options_values_price'];
            } else {
              $attributes_price -= $attribute_price[$n]['options_values_price'];
            }

REPLACE WITH

     

   // BOF set price per unit / per item multimixer 15 4 10         
        if ($attribute_price[$n]['options_price_calc'] == '0') {
        // EOF set price per unit / per item multimixer 15 4 10         
            if ($attribute_price[$n]['price_prefix'] == '+') {
              $attributes_price += $attribute_price[$n]['options_values_price'];
            } else {
              $attributes_price -= $attribute_price[$n]['options_values_price'];
            }
        // BOF set price per unit / per item multimixer 15 4 10         
        } else {
            if ($attribute_price[$n]['price_prefix'] == '+') {
              $attributes_price += $attribute_price[$n]['options_values_price'] / $this->contents[$products_id]['qty'];
            } else {
              $attributes_price -= $attribute_price[$n]['options_values_price'] / $this->contents[$products_id]['qty'];
            }
        }               
        // EOF set price per unit / per item multimixer 15 4 10         

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

13 file includes/classes/order.php

 

FIND       

$attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");

REPLACE WITH               

// set price per unit / per item multimixer 15 4 10     added , options_per_name        
$attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix, options_per_name from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'");

 

FIND

'prefix' => $attributes['price_prefix'],

ADD BELOW                                                                     

'pername' => $attributes['options_per_name'],
// set price per unit / per item multimixer 15 4 10 (line above added)

 

FIND (again)           

$attributes_query = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'");

REPLACE WITH                      

// set price per unit / per item multimixer 15 4 10     added , popt.products_options_per_name  
$attributes_query = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, popt.products_options_per_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'");

 

FIND (again)                                                                   

 'prefix' => $attributes['price_prefix'],

ADD BELOW                                                                     

'pername' => $attributes['products_options_per_name'],
// set price per unit / per item multimixer 15 4 10 (line above added)

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

14 file includes/classes/currencies.php

 

FIND    

return tep_round(tep_add_tax($products_price, $products_tax), $this->currencies[$currency]['decimal_places']) * $quantity;

 

REPLACE WITH        

// BOF set price per unit / per item multimixer 15 4 10         
//return tep_round(tep_add_tax($products_price, $products_tax), $this->currencies[$currency]['decimal_places']) * $quantity;
return tep_round(tep_add_tax($products_price, $products_tax), 10) * $quantity;
// EOF set price per unit / per item multimixer 15 4 10  

     

 

This here is not necessary to do if you don't have very large order quantities (ie 1000 pcs) and very low options prices per item (not unit) (ie 0,05)

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

15 file includes/modules/option_types.php

 

FIND      

$ProdOpt_Length = $products_options_name['products_options_length'];

ADD BELOW      

// BOF set price per unit / per item multimixer 15 4 10 
$ProdOpt_perName = $products_options_name['products_options_per_name'];
// EOF set price per unit / per item multimixer 15 4 10 

       

 

FIND

   

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

REPLACE WITH

   

$tmp_html_price = ' (' . $products_attribs_array['price_prefix'] . $currencies->display_price($products_attribs_array['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . ' ' . $ProdOpt_perName . ') '; // set price per unit / per item multimixer added $ProdOpt_perName

 

FIND

         

$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'])) .') ';

REPLACE WITH

         

$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'])) . ' ' . $ProdOpt_perName .')'; // set price per unit / per item multimixer added $ProdOpt_perName

 

FIND

         

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

REPLACE WITH

       

  $option_price = ' (' . $products_options['price_prefix'] . ' ' . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . ' ' . $ProdOpt_perName .') '; // set price per unit / per item multimixer added $ProdOpt_perName

 

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

16 file product_info.php

 

FIND     

$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)$product_info['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'  order by popt.products_options_order, popt.products_options_name");

REPLACE WITH

// BOF set price per unit / per item multimixer 15 4 10	added , popt.products_options_per_name	     
$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, popt.products_options_per_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$product_info['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'  order by popt.products_options_order, popt.products_options_name");

 

FIND          

$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; 

REPLACE WITH         

$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . ' ' . $products_options_name['products_options_per_name'] .') '; // set price per unit / per item multimixer 15 4 10 $products_options_name['products_options_per_name']

 

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

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

Thats it people, try it out

Share this post


Link to post
Share on other sites

Help! I got the following error after running the sql file:

 

INSERT INTO configuration VALUES ('', 'Use Progress Bars?', 'OPTIONS_TYPE_PROGRESS', 'Both', 'Set to use the Progress bar for Text Options

None = No Progress Bars

Text = Textfields only

TextArea = TextAreas only

Both = Both Text Fields and Areas', last_insert_id(), '4', now(), now(), NULL, 'tep_cfg_select_option(array(\'None\', \'Text\', \'TextArea\', \'Both\'),'), ('', 'Upload File Prefix', 'OPTIONS_TYPE_FILEPREFIX', 'Database', 'The prefix that is used to generate unique filenames for uploads.

Database = insert id from database

Date = the upload Date

Time = the upload Time

DateTime = Upload Date and Time', last_insert_id(), '5', now(), now(), NULL, 'tep_cfg_select_option(array(\'Database\', \'Date\', \'Time\', \'DateTime\'),'), ('', 'Delete Uploads older than', 'OPTIONS_TYPE_PURGETIME', '-2 weeks', 'Uploads in the Temporary folder are automatically deleted when older than this setting.

Us[...]

 

MySQL said:

 

#1062 - Duplicate entry '0' for key 'PRIMARY'

 

 

I have no idea what that means! I'm new to all this! It took me forever just to figure out what phpMyAdmin was!!!! Then it took me forever to figure out how to run the file! What is it telling me I need to do?!

Share this post


Link to post
Share on other sites

As the error says, the column for option comments does not exist.

You probably didn't execute the SQL file...

I get the error:

1054 - Unknown column 'products_options_order' in 'order clause'

 

select * from products_options where language_id='1' order by products_options_order

 

[TEP STOP]

 

When you say "execute" the .sql file....Do you mean that I click on "import" and import the .sql file? I get an error message....

SQL query:

 

# osCommerce, Open Source E-Commerce Solutions

# http://www.oscommerce.com

#

# Database Changes for Option Types v2

#

# created by AvanOsch for http://Shop.CrystalCopy.nl

#

# Released under the GNU General Public License

# Add Option Types configuration menu in Admin

INSERT INTO `configuration_group`

VALUES (

 

'', 'Option Types', 'Configure Option Types and Upload settings.', '17', '1'

);

 

 

 

MySQL said:

 

#1062 - Duplicate entry '0' for key 'PRIMARY'

 

 

I'm TOTALLY lost!

Share this post


Link to post
Share on other sites

Help! I got the following error after running the sql file:

 

INSERT INTO configuration VALUES ('', 'Use Progress Bars?', 'OPTIONS_TYPE_PROGRESS', 'Both', 'Set to use the Progress bar for Text Options

None = No Progress Bars

Text = Textfields only

TextArea = TextAreas only

Both = Both Text Fields and Areas', last_insert_id(), '4', now(), now(), NULL, 'tep_cfg_select_option(array(\'None\', \'Text\', \'TextArea\', \'Both\'),'), ('', 'Upload File Prefix', 'OPTIONS_TYPE_FILEPREFIX', 'Database', 'The prefix that is used to generate unique filenames for uploads.

Database = insert id from database

Date = the upload Date

Time = the upload Time

DateTime = Upload Date and Time', last_insert_id(), '5', now(), now(), NULL, 'tep_cfg_select_option(array(\'Database\', \'Date\', \'Time\', \'DateTime\'),'), ('', 'Delete Uploads older than', 'OPTIONS_TYPE_PURGETIME', '-2 weeks', 'Uploads in the Temporary folder are automatically deleted when older than this setting.

Us[...]

 

MySQL said:

 

#1062 - Duplicate entry '0' for key 'PRIMARY'

 

 

I have no idea what that means! I'm new to all this! It took me forever just to figure out what phpMyAdmin was!!!! Then it took me forever to figure out how to run the file! What is it telling me I need to do?!

 

This query is adding some more lines, values, to the table "configuration" of your database. The value for each field is separated by a comma ","

 

So it says for example

('', 'Use Progress Bars?', 'OPTIONS_TYPE_PROGRESS', 'Both', 'Set to use the Progress bar for Text Options ......................

The field names of table configuration are:

configuration_id, configuration_title, configuration_key, configuration_value , configuration_description ...................

Each value is getting written into each field in the same order

 

You see that the first value (for the field "configuration_id") is empty. This is so, because that field is supposed to be "auto increment", so it doesn't need a value to be specified, it adds it by it self, adding +1 to the latest record.

 

For some reason your DB isn't doing that. So it adds the value "0". It's trying to do the same for the second entry, but because this field can have only unique entries, the error appears, telling you that there is a duplicate entry of 0

 

You can go to your database, table configuration to see the entries for all previous settings. If you order the table by "configuration_id (do this by clicking on the name in the "browse" view), you will find out what the highest latest id is. Lets say it is 726.

 

The next should be 727, then 728, 729 etc etc

 

You can add this numbers manually to the query, so the above posted would look like

('727', 'Use Progress Bars?', 'OPTIONS_TYPE_PROGRESS', 'Both', 'Set to use the Progress bar for Text Options ......................

You see that I entered into the empty first fiel ('') the value '727'. This you can do for all other fields for the query

# Add Option Types configuration menu in Admin
INSERT INTO configuration VALUES ('727', 'Use Progress Bars?', 'OPTIONS_TYPE_PROGRESS', 'Both', 'Set to use the Progress bar for Text Options<br>None = No Progress Bars<br>Text = Textfields only<br>TextArea = TextAreas only<br>Both = Both Text Fields and Areas', last_insert_id(), '4', now(), now(), NULL, 'tep_cfg_select_option(array(\'None\', \'Text\', \'TextArea\', \'Both\'),'),
                                ('728', 'Upload File Prefix', 'OPTIONS_TYPE_FILEPREFIX', 'Database', 'The prefix that is used to generate unique filenames for uploads.<br>Database = insert id from database<br>Date = the upload Date<br>Time = the upload Time<br>DateTime = Upload Date and Time', last_insert_id(), '5', now(), now(), NULL, 'tep_cfg_select_option(array(\'Database\', \'Date\', \'Time\', \'DateTime\'),'),
                                ('729', 'Delete Uploads older than', 'OPTIONS_TYPE_PURGETIME', '-2 weeks', 'Uploads in the Temporary folder are automatically deleted when older than this setting.<br>Usage: -2 weeks/-5 days/-1 year/etc.', last_insert_id(), '6', now(), now(), NULL, NULL),
                                ('730', 'Upload Directory', 'UPL_DIR', 'images/uploads/', 'The directory to store uploads from registered customers.', last_insert_id(), '7', now(), now(), NULL, NULL),
                                ('731', 'Temporary Directory', 'TMP_DIR', 'images/temp/', 'The directory to store temporary uploads (from guests) which is automatically cleaned.', last_insert_id(), '8', now(), now(), NULL, NULL),
                                ('732', 'Option Type Image - Images Directory', 'OPTIONS_TYPE_IMAGEDIR', 'images/options/', 'What directory to look for Option Type Images.<br>This is where the Images should be stored.', last_insert_id(), '9', now(), now(), NULL, NULL),
                                ('733', 'Option Type Image - Images Prefix', 'OPTIONS_TYPE_IMAGEPREFIX', 'Option_', 'What prefix to use when looking for Option Type Images.<br>This is what the Image\'s name should begin with.', last_insert_id(), '10', now(), now(), NULL, NULL),
                                ('734', 'Option Type Image - Images Name', 'OPTIONS_TYPE_IMAGENAME', 'Name', 'What Option Value item to use as Name for the Option Type Images.<br>When set to "Name", the images should be named: "PREFIX"-"Option value name"-"LanguageID".jpg (Option_RedShirt_1.jpg)<br>When set to "ID", the images should be named: "PREFIX"-"Option value ID"-"LanguageID".jpg (Option_5_1.jpg)', last_insert_id(), '11', now(), now(), NULL, 'tep_cfg_select_option(array(\'Name\', \'ID\'),'),
                                ('735', 'Option Type Image - Use Language ID', 'OPTIONS_TYPE_IMAGELANG', 'Yes', 'Use language ID in Option Type Images Names?<br>This is only needed if different images are used per Language (images with text for example).', last_insert_id(), '12', now(), now(), NULL, 'tep_cfg_select_option(array(\'Yes\', \'No\'),');

Of course you need to replace the numbers (727 etc) with your numbers. Then you run the query again. Before doing this, best is you restore the database you had before running the option types query

Share this post


Link to post
Share on other sites

 

You see that the first value (for the field "configuration_id") is empty. This is so, because that field is supposed to be "auto increment", so it doesn't need a value to be specified, it adds it by it self, adding +1 to the latest record.

 

For some reason your DB isn't doing that. So it adds the value "0". It's trying to do the same for the second entry, but because this field can have only unique entries, the error appears, telling you that there is a duplicate entry of 0

 

 

You said "For some reason...." and I have to laugh so I won't cry that I spent 7 hours trying to figure something out that I don't even slightly understand (although, I did self-teach myself HTML). The reason is that the box, "Do not use AUTO_INCREMENT for zero values" was checked in phpMyAdmin and, since I'm not familiar with all of this, I had no idea what that meant so I didn't uncheck it. After your (life-saving) post I restored my original database (thank God I took the advice to back it up before I made any changes) and ran the sql file with the box UNCHECKED and it worked like a charm!

 

THANK YOU! THANK YOU! THANK YOU!

 

I know this is off-topic but you might find some humor in this as I do. The first part isn't humorous but the end is....

 

My husband died about a year-and-a-half ago at the age of 31. (An accident in our driveway) Well, he was a Systems Administrator (did networking on computers) for a living. We always argued (in a joking way) over who's job was harder (I'm a nurse). Well, I know that what I'm trying to do with our website and what he did with computers (networking) are two totally different things but I still see what a pain in the a** computers can be now and I'd love to talk to him right now and give him credit for all of the evenings he came home and said that he just "needed some peace and quiet". I have to sit back, shake my head, laugh, and say to myself, "Maybe he was right! Maybe his job was harder! Computers suck!!!!" LOL Sometimes I picture him up there laughing at all the trouble I'm having building our website. You just wait til I see him again!! :-D

Share this post


Link to post
Share on other sites

This contribution is built on top of osCommerce 2.2rc2a.

It is an update/upgrade/revision/compilation of the following contributions:

* Option Type Feature v3 (Originally by Chandra Roukema)

* Option Type File Feature v.8 (Originally by Matt Fletcher)

* AJAX Attribute Manager v2.8.6 ((Almost unchanged) Originally by Sam West)

* Improvements by me (AvanOsch aKa Zappo the Wizard of Osch) for http://shop.crystalcopy.nl

 

Please post questions, comments, request, etc. right here!

 

The Contribution Page can be found here: http://www.oscommerce.com/community/contributions,xxxx

 

The contribution is really fantastic as it gives great flexibility to display various options for a product. Really nice work!

 

I've it implemented on my oscommerce copy but having a little problem when I checkout.

 

I can't see the 'text' options value on the orders page after the checkout when I select PAYPAL standard payment method. It works perfectly for COD payment method.

 

When I saw the database table 'orders_products_attributes' it has an entry but the following columns are empty for the said order:

products_options products_options_values options_values_price

 

Please be noted that the checkout process shows the values perfectly its only after the order has been confirmed by the customer that this mess is created. Simple to say is that the options value for the text option are not getting into the 'orders_products_attributes' table of the DB.

 

Please let me know if there is a solution to it.

 

Regards,

Muhammad Mahd

Share this post


Link to post
Share on other sites

Wondering if anyone has figured out how to add attributes as quantities or get something similar working with this contribution? For example, need to charge 2 bucks for each letter in a name that is entered in the text field....Thanks!!

Share this post


Link to post
Share on other sites

I have a HEAVILY Modified osCommerce shop which includes SPPC which had many conflicts with Option Types during compare. I thought I had it all working fine until I noticed that:

 

When I add a new product no problem.

When I add the same product again but change the options it adds to the cart as quantity of 2 and only holds the attributes of the later item (rather than making it a new line item with a quantity of 1)

 

Can you please look at the site and let me know what I am missing? www.statkids.com/store

 

Thanks,

Share this post


Link to post
Share on other sites

Hi all - hoping someone out there can help me with this. I've just installed (or tried to at least) this great contribution but when I try to add a text box to a product, it will only show up as a dropdown with (CUSTOMER-INPUT) as the only option. I've tried for several hours and can't seem to figure out what the issue is. I have the contribution, Attribute Sets Plus installed as well but I have it disabled for my test product and still can't get Option Types to work right. Here's a link to my store where I'm having the issue: http://freshfashionz.com/catalog/product_info.php?products_id=938

 

I read through the forum and saw that another user was having the same issue (back on page 15) but she was able to figure the problem out and didn't post the solution. Since so many people have successfully installed this, I'm sure it's something small that I'm overlooking. If anyone out there could possibly help, I would GREATLY appreciate it. Let me know if you need me to post any code or screenshot.

 

Thanks in advance!

Share this post


Link to post
Share on other sites

Hello everybody and what a contribution this is. Nice one..

 

I have installed complete as the instructions and everything works fine apart from 2 things on the product attribute page.

 

I have noticed that youcannot edit SORT ORDER or VALUE LENGTH.

 

OK what it does is this.. I click on edit, the options are available to edit.. I changed them.

 

When i click update the values for SORT ORDER & VALUE LENGTH revert back to the old settings.

 

Can anybody please help with this as i am not sure what is happening.

 

Thank You

Share this post


Link to post
Share on other sites

Hi people.

 

There are news about merging SPPC and Option Types v2. I have it working !. I will post my results here in the hope that somebody will take a look at them and make something more "sophisticated" of it:). I did following changes:

 

1) in file modules/option_types.php

 

1.1) After

  	$ProdOpt_Length = $products_options_name['products_options_length'];

I placed

// BOF SPPC multimixer 13 1 10
   $aid = tep_db_query("select pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)tep_db_input($product_info['products_id']) . "' and pa.options_id = '" . $ProdOpt_ID . "'");
 	$aid_result = tep_db_fetch_array($aid);
 	$ProdAtr_ID = $aid_result['products_attributes_id']; // SPPC
// EOF SPPC multimixer 13 1 10

so I have the attributes id available for a particular product/option combination

 

1.2) After

  
$products_attribs_query = tep_db_query("select distinct options_values_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . (int)tep_db_input($product_info['products_id']) . "' and options_id = '" . $ProdOpt_ID . "' order by products_options_sort_order");

I placed

// BOF SPPC multimixer 13 1 10
// forum http://forums.oscommerce.com/topic/338661-contribution-option-types-v2/page__view__findpost__p__1473708
     if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
	// check if something in table attributes groups for this product/customer group/ attributes id
  	 	$cid_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_id = '" . (int)tep_db_input($product_info['products_id']) . "' and customers_group_id = '" . $customer_group_id . "' and products_attributes_id = '" . $ProdAtr_ID . "'");
   	$cid_result = tep_db_fetch_array($cid_query);
	if ($cid_result['total'] > 0) { // if there is something, use this table (importand attribute id)
		  $products_attribs_query = tep_db_query("select distinct pa.options_values_id, pag.options_values_price, pag.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag where pa.products_attributes_id = '" . $ProdAtr_ID . "' and pa.products_attributes_id = pag.products_attributes_id and pag.customers_group_id = '" . $customer_group_id . "' and pag.products_id='" . (int)tep_db_input($product_info['products_id']) . "' order by products_options_sort_order");
		} // end if ($cid_result['total'] > 0)
} // end if ($customer_group_id > 0)
// EOF SPPC multimixer 13 1 10

so I'm getting the data for customer groups in case they exist and they have defined options. This cover all option cases exept of drop down (covered by product info) and radio/images see below

 

1.3) In both cases (OPTIONS_TYPE_RADIO and OPTIONS_TYPE_IMAGE) I replaced this

      
$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)$product_info['products_id'] . "' and pa.options_id = '" . $ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' order by pa.products_options_sort_order");

by this

// BOF SPPC multimixer 13 1 10
// forum http://forums.oscommerce.com/topic/338661-contribution-option-types-v2/page__view__findpost__p__1473708
    if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
	// check if something in table attributes groups for this product/customer group/ 
  	 	$cid_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_id = '" . (int)$product_info['products_id'] . "' and customers_group_id = '" . $customer_group_id . "'");
   	$cid_result = tep_db_fetch_array($cid_query);
	if ($cid_result['total'] > 0) { // if there is something, use this table (importand attribute id)
     		$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name,  pag.options_values_price, pag.price_prefix, pag.products_attributes_id 
  		from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag
   		where pa.products_id = '" . (int)$product_info['products_id'] . "' 
   		and pa.options_id = '" . $ProdOpt_ID . "' 
   		and pa.options_values_id = pov.products_options_values_id 
   		and pov.language_id = '" . (int)$languages_id . "' 
   		and pa.products_attributes_id = pag.products_attributes_id 
   		and pag.customers_group_id = '" . $customer_group_id . "' 
   		and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 
   		order by pa.products_options_sort_order");

		} else { //if ($cid_result['total'] > 0) // reqular query	

    		$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)$product_info['products_id'] . "' and pa.options_id = '" . $ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by pa.products_options_sort_order");

			} // end if ($cid_result['total'] > 0) 

	} else { //if ($customer_group_id > 0)	// reqular query	

    		$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)$product_info['products_id'] . "' and pa.options_id = '" . $ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by pa.products_options_sort_order");

		} // end if ($customer_group_id > 0)
// EOF SPPC multimixer 13 1 10

 

I know this looks not elegant at all, but I just didn't succeed to get the "replacement" logic of SPPC, like it is done in product_info.php into this file here. Anyway, it works at least

 

2) in shopping_cart.php (the main file, not the /classes/ one)

 

I replaced this

          $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
                                     from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                     where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                      and pa.options_id = '" . (int)$option . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" . (int)$value . "'
                                      and pa.options_values_id = poval.products_options_values_id
                                      and popt.language_id = '" . (int)$languages_id . "'
                                      and poval.language_id = '" . (int)$languages_id . "'");

 

by this

// BOF SPPC	multimixer 13 1 09
if ($customer_group_id > 0) { // only need to check if customer is not retail
	// mm get the attributes_id
       $aid = tep_db_query("select pa.products_attributes_id from  " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_values_id = '" . (int)$value . "'");
       $aid_result = tep_db_fetch_array($aid);
	// check if something in table attributes groups for this product/customer group
	$cid_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag, " . TABLE_PRODUCTS_ATTRIBUTES . " pa  where pag.products_id = '" . (int)$products[$i]['id'] . "' and pag.customers_group_id = '" . $customer_group_id . "' and pag.products_attributes_id = '" . $aid_result['products_attributes_id'] . "' and pa.options_values_id = '" . (int)$value . "'");
	$cid_result = tep_db_fetch_array($cid_query);

	if ($cid_result['total'] > 0) { // if there is something, use this table (importand attribute id and option value id)

         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pag.options_values_price, pag.price_prefix
                                     from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag,  " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                     where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                      and pa.options_id = '" . (int)$option . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" . (int)$value . "'
                                      and pa.options_values_id = poval.products_options_values_id
								   and pag.customers_group_id = '" .(int)$customer_group_id . "'
   						and pa.products_attributes_id = pag.products_attributes_id 
                                      and popt.language_id = '" . (int)$languages_id . "'
                                      and poval.language_id = '" . (int)$languages_id . "'");

		} else {// if ($cid_result['total'] > 0) // if nohing use reqular query	

         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
                                     from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                     where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                      and pa.options_id = '" . (int)$option . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" . (int)$value . "'
                                      and pa.options_values_id = poval.products_options_values_id
                                      and popt.language_id = '" . (int)$languages_id . "'
                                      and poval.language_id = '" . (int)$languages_id . "'");

		} // end if ($cid_result['total'] > 0)

	} else { //if ($customer_group_id > 0)	// reqular query	

	// BOF original Zappo - Option Types v2
         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
                                     from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                     where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                      and pa.options_id = '" . (int)$option . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" . (int)$value . "'
                                      and pa.options_values_id = poval.products_options_values_id
                                      and popt.language_id = '" . (int)$languages_id . "'
                                      and poval.language_id = '" . (int)$languages_id . "'");
	// EOF original Zappo - Option Types v2

	} // end if ($customer_group_id > 0)
// EOF SPPC	multimixer 13 1 09

 

Again: not very elegant maybe, but it works

 

Thats all ! Preposition is of course a correct merging of the other files, valid for both contributions (SPPC and Option Types v2). There could be a confusion in files product_info.php and classes/shopping cart.php, so, here are some tips about how I did it

 

3) File product_info.php

 

I will post the 3 queries related to product attributes as they look after the merging

    $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 find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 ");

      $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)$product_info['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_order, popt.products_options_name");

        $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by pa.products_options_sort_order");

 

4) File classes/shopping_cart.php

 

There is nothing that could cause a problem except of one thing that is resulting to text and image options not to be added to the cart properly.

 

In the SPPC instructions it says to replace this

        $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')) {

 

by this

// BOF SPPC attribute hide check, original query expanded to include attributes
			$check_product_query = tep_db_query("select p.products_status, options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_ATTRIBUTES . " using(products_id) where p.products_id = '" . (int)$products_id . "'");
			while ($_check_product = tep_db_fetch_array($check_product_query)) {
				$check_product[] = $_check_product;
			} // end while ($_check_product = tep_db_fetch_array($check_product_query))
			$no_of_check_product = count($check_product);

 if (is_array($attributes)) {
			foreach($attributes as $attr_option => $attr_option_value) {
				$valid_option = '0';
				for ($x = 0; $x < $no_of_check_product ; $x++) {
					if ($attr_option == $check_product[$x]['options_id'] && $attr_option_value == $check_product[$x]['options_values_id']) {
						$valid_option = '1';
						if ($check_product[$x]['hide_attr_status'] == '1') {
						// delete hidden attributes from array attributes
						unset($attributes[$attr_option]);
						}
					} // end if ($attr_option == $check_product[$x]['options_id']....
				} // end for ($x = 0; $x < $no_of_check_product ; $x++)
				if ($valid_option == '0') {
					// after having gone through the options for this product and not having found a matching one
					// we can conclude that apparently this is not a valid option for this product so remove it
					unset($attributes[$attr_option]);
				}
			} // end foreach($attributes as $attr_option => $attr_option_value)
} // end if (is_array($attributes))
// now attributes have been checked and hidden and invalid ones deleted make the $products_id_string again
			$products_id_string = tep_get_uprid($products_id, $attributes);

       if ((isset($check_product) && tep_not_null($check_product)) && ($check_product[0]['products_status'] == '1')) {
// EOF SPPC attribute hide check

 

If you leave the original code in place, then everything works fine. Would be great ofcourse if somebody could help in transforming the SPPC part to be option types compatible

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

Thats all people, it works, everything gets displayed and calculated correctly. As I said, I posting this in the hope that somebody will put an eye on it and make all necessary corrections.

 

 

If you add a product with text attributes, then go back and try to add the same product with different text attributes......does it work? Cause mine gives the product a quantity of 2 in the shopping cart with only the last text attributes added. Let me know if yours works!! Thanks,

Share this post


Link to post
Share on other sites

Hi there,

I'm looking for a contribution that will make it really easy for customers to add accessories to a product.

 

Ideally I'd like the optional accessories to be shown at checkboxes and the price dynamically updated when the checkboxes are selected. It would be perfect if these options could be actual products which are added to the basket separately when they are selected and have their stock adjusted accordingly.

 

I've had a look at Zappo's Linked Products addon which looks perfect, but in the support thread he advised against using it in a live shop.

 

Does Option Types offer any of the functionality I need? I'm also using QTpro, so would be interested to hear if anyone has that working with Option Types.

 

Thanks for your help!

Tim. :thumbsup:

Share this post


Link to post
Share on other sites

First of all i would like to say that this contribution is brilliant and works like a charm.

 

However i have a problem that i am hoping this support can help with..

 

Here is the scenario..

 

I have a t-shirt printing website and deal with 7 styles of t-shirts. eg baseball style, hoodie, v-neck, ladyfit

Each style has differant colours. eg v-neck (23 clours) hoodie (6 colours)

 

So what i need is this..

 

They select the style of t-shirt that they want.

This selection determines the colours available.

 

Is there any way that this can be done with this contribution and if so how...

 

Any help would be very much appreciated..

 

Thank You

 

Dean

Share this post


Link to post
Share on other sites

Hi,

 

I seem to have developed a problem with Option Types V2.

 

When I originally installed it everything worked fine.

 

However, I now find that when a customer makes an order, his Customer Inputs for the chosen optionns are displayed on the Order Confirmation page, but are not passed through with the order.

 

The options do not appear in the customers order history either.

 

Eg - all that is passed through is the name of the option and the words "CUSTOMER INPUT" as follows:

 

CPH Number: CUSTOMER-INPUT

Flock Mark (UK) CUSTOMER-INPUT

Consecutive No. (from) CUSTOMER-INPUT

Consecutive No. (to) CUSTOMER-INPUT

Colour Required Light Blue

 

The same happens on the order email.

 

I have no idea when this happened and have only just noticed.

 

Any assistange would be great thanks.

 

I have just found out that this only happens when one of the available payment options are used (Barclaycard EPDQ) when the other payment options (paypal & Cheque) are selected everything works as it should.

 

Thanks


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

In The paypal IPN Code I have the following :

 

                $attributes_values = tep_db_fetch_array($attributes);

// BOF - Zappo - Option Types v2 - Correction for Text Option Values
               $attr_name = $attributes_values['products_options_name'];
               if ($attributes_values['products_options_id'] == OPTIONS_VALUE_TEXT_ID) {
                 $attr_name_sql_raw = 'SELECT po.products_options_name FROM ' . TABLE_PRODUCTS_OPTIONS . ' po, ' . TABLE_PRODUCTS_ATTRIBUTES . ' pa WHERE ' .
                                                       ' pa.products_id="' . tep_get_prid($order->products[$i]['id']) . '" AND ' .
                                                       ' pa.options_id="' . $order->products[$i]['attributes'][$j]['option_id'] . '" AND ' .
                                                       ' pa.options_id=po.products_options_id AND ' .
                                                       ' po.language_id="' . $languages_id . '" ';
                 $attr_name_sql = tep_db_query($attr_name_sql_raw);
                 if ($arr = tep_db_fetch_array($attr_name_sql)) {
                   $attr_name = $arr['products_options_name'];
                 }
               }
               $sql_data_array = array('orders_id' => $insert_id,
                                       'orders_products_id' => $order_products_id,
                                       // 'products_options' => $attributes_values['products_options_name'],
                                       // 'products_options_values' => $attributes_values['products_options_values_name'],
                                       'products_options' => $attr_name,
                                       'products_options_values' => $order->products[$i]['attributes'][$j]['value'],
                                       'options_values_price' => $attributes_values['options_values_price'],
                                       'price_prefix' => $attributes_values['price_prefix']);
// EOF - Zappo - Option Types v2 - Correction for Text Option Values

               tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);

 

But if I copy this to the EPDQ.php payment module it does not solve the problem.

 

Help Please......


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

OK - Please ignore my last post - the fix above does work in the EPDQ File.

 

Many Thanks


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

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

×