Jump to content
Latest News: (loading..)
Zappo

[Contribution] Option Types v2

Recommended Posts

all the time i say 99.9% the people in front the computer is the bug! :wink: So me too...
A lot people have problem to get the products in the cart or there not add the product separat to the shoping cart. After a long night of searching the bug, i find out, that i didn't change the function in /catalog/includes/function/general.php correct.

So i like to share that info. You have to be shure, that you change the two function tep_get_uprid and tep_get_prid like the follow:

////
// 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)) {
        $uprid = $uprid . '{' . $option . '}' . htmlspecialchars(stripslashes(trim($value)), ENT_QUOTES);
      }
    } else {
      $uprid = htmlspecialchars(stripslashes($uprid), ENT_QUOTES);
    }
    if ( (is_array($params)) && (!strstr($prid, '{')) ) {
      while (list($option, $value) = each($params)) {
        $uprid = $uprid . '{' . $option . '}' . $value;
      }
    }
		return $uprid;
	}
	
////
	function tep_get_prid($uprid) {
		$pieces = explode('{', $uprid);
    return $pieces[0];
  }

After that everythings works fine in osC 2.3.4 Bootstrap Responsive and in an unofficial version of me. Someone interessted for the unofficial version just send PM to me.

Edited by mcmannehan

  • The clever one learn from everything and from everybody
  • The normal one learn from his experience
  • The silly one knows everything better

[socrates, 412 before Christ]

Computers help us with the problems we wouldn't have without them!
99.9% of the bugs sit in front of the computer!
My programmed add-ons: WDW EasyTabs 1.0.3, WDW Facebook Like 1.0.0

if(isset($this) || !isset($this)){ // that's the question...

 

Share this post


Link to post
Share on other sites

Dear Community:

I'm doing a new clean install of Oscommerce 2.3.4BS Edge, and I just added the Option Types for 2.3.4 BS contribution. But when I go into my administration tools and click on "Catalog" and then "Products Attributes", I get the following error message on the admin/products_attributes.php page:

Quote

1366 - Incorrect integer value: 'OPTIONS_VALUES_TEXT_ID' for column 'products_options_values_id' at row 1

insert into products_options_values (products_options_values_id, language_id, products_options_values_name) values ('OPTIONS_VALUES_TEXT_ID', '1', 'CUSTOMER-INPUT')

Apparently, the database expects an integer value but is getting 'Options_Values_Text_ID' instead.

I thought that the error could be due to me having installed admin/products_attributes.php incorrectly, but both of the files that came with the add-on gave me the same error. I even tried carefully installing one-by-one the changes in the products_attributes.php file, but I still got the same error.

Has anybody encountered this error before? If so, is there a known fix?

I suspect that the problem is that Options_Values_Text_ID is being treated as a literal when it is actually a variable that has an integer value. If I find the fix, I'll post it here.

Howard

Edited by HowardR

Share this post


Link to post
Share on other sites

I found and fixed a couple of bugs in the Bootstrap version and I think things are working now:

1. I added the following to both configuration files (includes/configure.php & admin/includes/configure.php):

    define('DIR_WS_INCLUDES', 'includes/');

2. I couldn't find the error that I posted about above in the /admin/products_attributes.php file. So I commented off the line that was causing the database error. In other words, I inserted // at the beginning of the line. (It's near the beginning of the file -- about line 29.) If anybody can find the error in this line please post here. I may run into problems as a result of commenting it off. It has to do with the names of attributes in each language:

      //tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . OPTIONS_VALUES_TEXT_ID . "', '" . (int)$languages[$i]['id'] . "', '" . TEXT_UPLOAD_NAME . "')");
 

 

 

Edited by HowardR

Share this post


Link to post
Share on other sites

Here's something else to add to the admin/includes/configure.php file if you are using the boot strap 2.3.4 version:

 define('FILENAME_PRODUCTS_ATTRIBUTES', 'products_attributes.php');
 

Share this post


Link to post
Share on other sites

@HowardR,

 

These are no bugs.

Filenames and Paths are now hardcoded in 2.3.4 Bootstrap and most path definitions in configure.php and the file filenames.php with the filename definitions have been removed.

So you are going the wrong way, instead to re-add the definitions to configure.php, you should update the add-ons which have not yet been updated.

To get older Add-Ons which are still using filename and path constants to work, you have 2 possibilities:

1. Update all filename constants in the add-on files from Example: FILENAME_DEFAULT to the real filenames Example: 'index.php'

  Update all path constants in the add-on files from Example: require(DIR_WS_INCLUDES . 'database_tables.php'); to the real path: require('includes/database_tables.php');

or

2. Install the compatibility add-on: Add-On Compatibility for 2.3.4 EDGE

1 is the preferred method

 

Please Google or search the forum about these subjects. You'll find many posts for clearance.

rgds

Rainer

Share this post


Link to post
Share on other sites

Thank you Naiwa,

But the line that I had to comment off does appear to contain a bug. The database is getting the string 'Options_Values_Text_ID' for a value that requires an integer.

Howard

Share this post


Link to post
Share on other sites

Hmmm... and I thought I had everything fixed to run with Edge. I haven't tested this addon with the latest Edge version but I'll do that tonight and see if I can recreate that error.

As raiwa already said instead of adding those definitions try to replace them with the correct paths.

I'll report back asap.


When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

Tsimi,

Thank you. You guys are the best! I very much appreciate your fast responses to my questions. And your add-on is the best! I wouldn't use OSCommerce without it!

The compatibility link that Raiwa posted was very easy to install, and it solved all of my other "bugs".

By the way, I don't think that commenting off that one line has affected my store. Option types appears to be working fine without it.

Howard

Edited by HowardR

Share this post


Link to post
Share on other sites
13 hours ago, HowardR said:

Dear Community:

... But when I go into my administration tools and click on "Catalog" and then "Products Attributes", I get the following error message on the admin/products_attributes.php page:

Apparently, the database expects an integer value but is getting 'Options_Values_Text_ID' instead.

I thought that the error could be due to me having installed admin/products_attributes.php incorrectly, but both of the files that came with the add-on gave me the same error. I even tried carefully installing one-by-one the changes in the products_attributes.php file, but I still got the same error.

Has anybody encountered this error before? If so, is there a known fix?

I suspect that the problem is that Options_Values_Text_ID is being treated as a literal when it is actually a variable that has an integer value. If I find the fix, I'll post it here.

Howard

Add (int) like this : 

$textoptions_query = tep_db_query("select products_options_values_name from products_options_values where products_options_values_id = " . (int)OPTIONS_VALUES_TEXT_ID . " and language_id = '" . $languages_id . "'");

and :

    tep_db_query("delete from products_options_values where products_options_values_id = " . (int)OPTIONS_VALUES_TEXT_ID);

and :

          tep_db_query("insert into 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 . "')");

and :

        $optionType_query = tep_db_query("select products_options_type from products_options where products_options_id = '" . (int)$option_id . "' and language_id = '" . $languages_id . "'");

 


Live   : OsC 2.2, php 5.4 & UTF-8  |  Local : OsC 234BS Edge for future shop

Share this post


Link to post
Share on other sites

@HowardR

So I installed it into the latest osC EDGE version and I cannot recreate your error.
My test shop runs on MySQL 5.5.5-10 and PHP version 5.6.21.

I must say the addon was not up to date. It contained a lot old code. I will upload a new version after this and I hope it will work also for the latest EDGE from now on.
Please try bonbecs solution once and report back.


When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

@Tsimi

I had the same problems and add (int) resolved this. But I have no idea why this happened. I agree with you when you said " It contained a lot old code.".

 


Live   : OsC 2.2, php 5.4 & UTF-8  |  Local : OsC 234BS Edge for future shop

Share this post


Link to post
Share on other sites

@bonbec

Thanks for your feedback and help.
Maybe it happens with certain MySQL versions?
You and Howard are the first ones to mention this bug. If more people should have the same issue I will include your fix into the next addon update.


When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

Bonbec's solution worked! I have now uncommented the error-causing line and I don't get an error when I click on "Products Attributes" after clicking on "Catalog" while using the administration tool (/admin/index.php). In my code, the line (about line 29) of /admin/products_attributes.php now reads:

Quote

tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)OPTIONS_VALUES_TEXT_ID . "', '" . (int)$languages[$i]['id'] . "', '" . TEXT_UPLOAD_NAME . "')");

Bonbec, you are brilliant!  I should have thought of that solution myself! I should have been tipped off by the fact that (int) appears before the $languages variable in the very same command.

Tsimi, I love your idea of updating the code and uploading a new add-on. When you do so, *please* put up the updated files also; you would save everyone hours and hours of time! 

For the record (in case the bug was due to MySQL version), my version is 5.6.35.

Howard

Edited by HowardR

Share this post


Link to post
Share on other sites
56 minutes ago, HowardR said:

your idea of updating the code and uploading a new add-on. When you do so, *please* put up the updated files also; you would save everyone hours and hours of time! 

Done!
Uploaded new package (Option Types BS v1.2) which includes the (int) fix by bonbec.

Edited by Tsimi

When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

I wonder if anybody else has encountered this weird bug?  If so, I would be interested in hearing how you solved it.

The problem occurred in my second store, for which I upgraded my 2.3.3 store database (which used Option Types) to Edge using the attached file. The weird bug is that in my 2.3.3. store, my database allowed Option Values (for the "select" option type) to be at least 40 characters long, but my new Edge store only allows them to be 32 characters long or less. If I go over 32 characters, I get the following database error from checkout_process.php *after* successful processing of the customer's credit card:

Quote

insert into orders_products_attributes (orders_id, orders_products_id, products_options, products_options_values, options_values_price, price_prefix)
1406 - Data too long for column 'products_options_values' at row 1

At first I thought that all I would have to do was change the "Value Length" for my option names from the transferred in value "0" to "40". But that didn't affect anything. So I "solved" the problem by abbreviating the names of all of my option values that were longer than 32 characters so that they would be 32 characters or less.

Howard

233_to_234BS.sql

Share this post


Link to post
Share on other sites

Take a look to these posts here


Live   : OsC 2.2, php 5.4 & UTF-8  |  Local : OsC 234BS Edge for future shop

Share this post


Link to post
Share on other sites

Hello,

I’m trying to install ‘Option Types vs for 2.3.4 Bugfix (8th March 2016)' into OSC 2.3.4 and encountering a problem when trying to run the SQL file on the database.

On running the SQL file I get a message “Import has been successfully finished, 7 queries executed. (OptionTypes v2 SQL.sql)” and an error message “#1062 - Duplicate entry '0' for key 'PRIMARY'”.

When I check in phpMyAdmin the alterations to tables have not been made. I would welcome any pointers or solutions where as to where I’m going wrong – please be mindful that my knowledge of working with databases is very limited!

Many thanks, Maz

Share this post


Link to post
Share on other sites

@mickamber

Hi Maz

I guess you're trying to insert the database entries using the Import feature via phpMyAdmin? Which means you click on the Browse... button and select the sql file.
First you need to remove the new field inside the configuration_group table. Browse to the configuration_group table and look for the Option Types field. Delete it.
Once that is done try to upload the sql file again but this time uncheck/ the checkbox of the following option.

Do not use AUTO_INCREMENT for zero values

 


When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites

Lambros, thank you for your quick reply - followed your instructions and OptionTypes v2 SQL.sql is now successfully installed into the database. Yes, I was using using the import feature via phpMyAdmin.

I would never have worked it out without your help, so very many thanks, Maz.

Share this post


Link to post
Share on other sites

Hello all,

is this possible with option types?

I need a way for ms smith to enter dimensions in text fields, then add them together, then multiply by product price.

Example:

Product = wool= $1.00 per square inch

Lenght=[text field input] = 10.5"

Width=[text field input] = 6"

she adds to cart (10.5+6=16.5" x $1.00 per square) cart shows $16.50

Not sure if this should be done in product_info, option_types or maybe application_top.

Reading through all these forums, it looks like the text field is a temporary called [CUSTOMER INPUT], but my html calls the field like this:

<div id="textboxsm"><input type="text" class="form-control" required aria-required="true" name="id[txt_7]" id="id[txt_7]" size="10" maxlength="10" value=""></div>

So, maybe it is a simple version of this in product_info:

<div id="textboxsm"><input type="text" class="form-control" required aria-required="true" name="id[txt_7]" id="id[txt_7]" size="10" maxlength="10" value=""></div>

+

<div id="textboxsm"><input type="text" class="form-control" required aria-required="true" name="id[txt_8]" id="id[txt_8]" size="10" maxlength="10" value=""></div>

*products_price?

Your thoughts would be greatly appriciated

 

osc v 2.3.4
addons
Option types for 2.3.4 v2
attribute prefix
 

Share this post


Link to post
Share on other sites
Posted (edited)

@2skys

Very interesting scenario.

First thing I did was take a look at various other fabric online stores to see how they sell their products. And it turns out most of them sell by the meter or yard with a predefined width. Width is in most cases 150cm.

Another thing to consider is stock tracking. With option types you add attributes and therefore you don't have the possibility to track stock of your fabric. What if you have only 10 square inch in stock but the customer wants 20 and can place an order in your shop even you don't have enough available?

To your question if it would be possible, i guess yes it is. It would take some research into the option types code but it should be doable.

Is this something you want for a certain product only or do you need this for most or even all products in your store?

Edited by Tsimi

When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

Share this post


Link to post
Share on other sites
16 hours ago, 2skys said:

is this possible with option types?

Any type of custom price calculation based on options is possible, you just need to be clear how exactly the final price is "constructed"

Example

https://www.upnorthprint.com/product_info.php/a4-booklet-with-double-sided-cover-and-double-sided-bw-inners-on-white-paper-p-472

 

Share this post


Link to post
Share on other sites

Wow, thank you for your time and quick response!

To answer, it is a specific product.

It is custom embroidered boarders and trims for wall hangings, rugs, ornate table cloths, etc. They are sold by the linear inch. They will be offered in different color combinations, stitch patterns, embedded stones and widths.

The Product will be the material and boarder width (base price) then lenght + width (customer input) total x options (attribute prefix allows to multiply). 

Example:

Product = Silk = $1.00 per inch

Dimension1 = (customer input) = 10

Dimension2 = (customer input) = 15

Dimension3 = (customer input) = 10

adds to cart and shows $35.00 (or maybe can't show till all are picked?)

she picks options

1 color = Blue = 35 inches x .10 per inch ($3.50)

pattern#4 = egg&dart = 35 inches x 1.00 per inch ($35.00)

she adds to cart and totals all and shows $73.50 for this item before shipping

These are all custom so, no stock.

Not all are square shapes so maybe need dimension1, dimension2, dimension3, etc. for hex, oct, etc and maybe fractions (2 1/2").

Is this making sense?

 

Share this post


Link to post
Share on other sites
Posted (edited)

Yep making sense.
Not sure option types is the app to use though, at least not as is. The text input was made more for t-shirt or mug cup printing kinda feature. What you probably need is a quantity input field and not just one but 3 of them for dimensions 1,2 and 3 and then add additional attributes for the total of quantity 1-3.

Maybe someone can custom code it for you. Perhaps multimixer is  up for the task?
Or you can ask once in the commercial support section?

Something else... isn't square inch calculated length x width ? Just ask because in your first example you have

(10.5+6=16.5" x $1.00 per square) cart shows $16.50

shouldn't it be

(10.5x6=63" x $1.00 per square) = $63

Then again I am not really good at math so...

Edited by Tsimi

When you ask for help/support:

  • Always state your osCommerce version
  • If possible, list up installed add-ons
  • 3rd party templates are not supported in the forum

Latest osC: osCommerce CE (Community Edition aka. v2.3.4.1 Frozen)

 

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

×