Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Option Types v2


Zappo

Recommended Posts

@@dani

 

I see what you mean. It does indeed add another product to the cart with the corrected text and the previous product stays in the cart.

Maybe an edit button with a redirect and delete function could be build in? So that it will remove the current product from the cart and at the same time redirect you to the product_info.php page.

Never did something like this but let me see what I can come up with.

Link to comment
Share on other sites

@@dani

 

I added an edit button to my test store that redirects the customer to the products page and at the same time it removes the product from the shopping cart.

The downside is; no matter if the customer edited the text again or not he has to click on the "add to cart button" again. Another issue could be that if a customer clicks on the edit button by mistake and then clicks on the back button in the browser or on a mouse the product is not in the shopping cart anymore.

 

If you want to test this once add the following to your (test)store. Backup your files (application_top.php + shopping_cart.php)

 

application_top.php

 

FIND:

switch ($HTTP_GET_VARS['action']) {

ADD RIGHT AFTER IT:

// BOF OPTION TYPES ACTION FOR EDIT BUTTON
	  case 'edit_option' : if (isset($HTTP_GET_VARS['products_id'])) {
				$cart->remove($HTTP_GET_VARS['products_id']);
			       }
                              tep_redirect(tep_href_link('product_info.php', 'products_id=' . $HTTP_GET_VARS['products_id']));
                              break;
// EOF OPTION TYPES ACTION FOR EDIT BUTTON

shopping_cart.php

 

FIND:

          $products_name .= '<br /><small>- ' . $products[$i][$option]['products_options_name'] . ': <i>' . $image_link . $products[$i][$option]['products_options_values_name'] . '</a></i>' . $Option_Price . '</small>';
        }
      }

REPLACE WITH THIS:

          $products_name .= '<br /><small>- ' . $products[$i][$option]['products_options_name'] . ': <i>' . $image_link . $products[$i][$option]['products_options_values_name'] . '</a></i>' . $Option_Price . '</small>';
        }
          $products_name .= '<br>' . tep_draw_button(SMALL_IMAGE_BUTTON_EDIT, 'fa fa-pencil', tep_href_link('product_info.php', 'products_id=' . $products[$i]['id'] . '&action=edit_option'), NULL, NULL, 'btn-default btn-xs') . '<br>';
      }

Try it once and decide for yourself if this is something you think customer could handle.

Edited by Tsimi
Link to comment
Share on other sites

  • 4 months later...

I'm having an issue with this mod where on my confirmation e-mails, invoice, packing slip and on the checkout confirmation page it still says "CUSTOMER-INPUT" instead of the text value that the customer assigned.  I checked all of the files that were to be updated and everything is there.  What is missing and why isn't the data there?

 

EDIT: I checked the database and it's going to the database as CUSTOMER-INPUT as well.

Edited by duckydan
Link to comment
Share on other sites

@@duckydan

 

What osC version are you using?

Which Option Types version are you using?

What payment method was used for that order that shows the CUSTOM_INPUT text?

Did you check a few posts back in this thread, especially page 53 and 54. Lary_an had the same problem and I posted some solutions for it.

Link to comment
Share on other sites

@@Tsimi, thanks for the reply... I hadn't logged in in a few days.  I went back and found I missed one line in one off the class files.  Fixed that and it worked.  Should have updated this thread but I had posted in a ton with the number of errors I experienced and couldn't remember them all.

 

Thanks!

Link to comment
Share on other sites

  • 1 month later...

@Tsimi

You did a very great work, but here the posting have a lot answers and i didn't found some right answer for my problem:

Let say:

I have product 'A' with text feld content = 'aaaaa' 1 each and add this to the cart
I have product 'A' with text feld content = 'bbbbb' 1 each and add this to the cart

Normaly there should be two products inside the cart, because the attributes are differnt, but in the shoping cart are one product with 2 each and text content is 'bbbbb'.

How is the solution for to have two differnt products inside the shoping cart?
Thanks in advance for the answer.

  • 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...

 

Link to comment
Share on other sites

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...

 

Link to comment
Share on other sites

  • 3 weeks later...

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
Link to comment
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
Link to comment
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

Link to comment
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.

Link to comment
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
Link to comment
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 . "'");

 

with OsC 2.2 since 2006 ...

Link to comment
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.

Link to comment
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.".

 

with OsC 2.2 since 2006 ...

Link to comment
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.

Link to comment
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
Link to comment
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
Link to comment
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...