Jump to content



Latest News: (loading..)

* * * * * 2 votes

[Contribution] Option Types v2


  • Please log in to reply
914 replies to this topic

#21   jkenfield

jkenfield
  • Members
  • 13 posts
  • Real Name:Jessica

Posted 24 June 2009 - 03:12 PM

View PostZappo, on Jun 24 2009, 10:37 AM, said:

I recommend uninstalling the "Old" Option Type Feature, and installing Option Types v2...   :lol:
Simply "Merging" the two is impossible. There are too many differences...

However, I have used the "Old" Option Type Feature a long time ago, and if it's just the Character limit, I believe that option is available via Admin, in "product_attributes" (Option Value Length)
It SHOULD work as it does in Option Types v2....


In that case, at least the standard osCommerce behavior is kept.
You'll be able to count the attributes already connected to a product...
BUT, as I stated in an earlier post, this is not going to be a simple change!! You'll need at least SOME php skills...


I am an idiot...I swear that I had read that the max length was 32 characters for some reason and never tried to go beyond that, even with the ability to set max in admin.  Oh well...if I hadn't gone down the path already with the older version, I would for sure install your contribution.  It looks much nicer and easier to use.  I wish I could just install the sorting abillity for the options...that is all I need at this point now that I got the char restriction figured out.  :blush:

#22   smoothgift

smoothgift
  • Members
  • 51 posts
  • Real Name:Richard

Posted 04 July 2009 - 12:05 PM

Hello,

Compliments to Zappo for the great work!

I do have a little problem using this contribution though. The file name uploaded is not passed on and shown in the Cart. All other chosen options show up correctly in the Cart. The file however is uploaded in both the temp dir and the upload dir.

I suspected that I might have got the admin configuration (upload option values) messed up somehow but I could not see where I went wrong after comparing my configuration with the screenshots you attached with the contribution.

I wonder - where did you define "- Your picture:" ? (this is the cart output value for upload on your website) This might give me an idea how the text and upload values differs.

Thank you.
Rich

#23   Zappo

Zappo
  • Members
  • 201 posts
  • Real Name:Albert van Osch
  • Gender:Male
  • Location:the Netherlands, Asten

Posted 04 July 2009 - 01:11 PM

View Postsmoothgift, on Jul 4 2009, 02:05 PM, said:

-1: Compliments to Zappo for the great work!
-2: The file however is uploaded in both the temp dir and the upload dir.
-3: I wonder - where did you define "- Your picture:" ?
Hello Rich.
-1: Thanx!
-2: The upload destination is set in application_top. This is done by checking for a registered session.
  It's VERY strange the files end up in both! Does this happen when logged in (registered customer), as a guest, or both?!?
-3a: Please Note: crystalcopy.nl is NOT using Option Types v2!! (Basic functionality is the same however)
-3b: The text used in the cart is the same define as the text in product_info ("Option Name" is used, just like with other types)

I'm guessing something is wrong in application_top.php (case 'add_product'  around Line: 370)
Have you merged with other contributions there?

Edited by Zappo, 04 July 2009 - 01:12 PM.

Check out my website! shop.crystalcopy.nl


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

#24   smoothgift

smoothgift
  • Members
  • 51 posts
  • Real Name:Richard

Posted 04 July 2009 - 01:48 PM

View PostZappo, on Jul 4 2009, 02:11 PM, said:

Hello Rich.
-1: Thanx!
-2: The upload destination is set in application_top. This is done by checking for a registered session.
  It's VERY strange the files end up in both! Does this happen when logged in (registered customer), as a guest, or both?!?
-3a: Please Note: crystalcopy.nl is NOT using Option Types v2!! (Basic functionality is the same however)
-3b: The text used in the cart is the same define as the text in product_info ("Option Name" is used, just like with other types)

I'm guessing something is wrong in application_top.php (case 'add_product'  around Line: 370)
Have you merged with other contributions there?

Zappo, thanks for your quick response.
The files are saved correctly in their respective directory. There is no problem here at all.
Text input in product_info is also passed on to the cart correctly. No problem here either.
I understand that Option types functionality are basically the same but my problem is that I can't define upload-option values in admin's option value type because it has been taken off the drop down list of values available.  So I guess it has to be defined somewhere for it to show up.

Yes, I did merged with other contributions, e.g QPBPP,  SPPC

Here is my case 'add_product'
      case 'add_product' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
//BOF - Zappo - Option Types v2 - File uploading: save uploaded files with unique file names, in the proper folder
          $purgeDir = opendir(TMP_DIR) or die ('Could not open '.TMP_DIR);
          while ($file = readdir($purgeDir)) {
            if ($file != ('.htaccess') && filemtime(TMP_DIR . $file) < strtotime(OPTIONS_TYPE_PURGETIME)) {
              unlink(TMP_DIR . $file);  // Delete file from server...
              tep_db_query("delete from " . TABLE_FILES_UPLOADED . " where files_uploaded_name = '" . $file . "'"); // Remove File's database entry....
            }
          }
          closedir($purgeDir);
          $real_ids = $HTTP_POST_VARS['id'];
          if ($HTTP_POST_VARS['number_of_uploads'] > 0) {
            require(DIR_WS_CLASSES . 'upload.php');
            for ($i = 1; $i <= $HTTP_POST_VARS['number_of_uploads']; $i++) {
              if (tep_not_null($_FILES['id']['tmp_name'][TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]]) and ($_FILES['id']['tmp_name'][TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]] != 'none')) {
                $products_options_file = new upload('id');
                //BOF - Zappo - Option Types v2 - Set Upload directory (Registered customers in Uploads, other in Temporary folder)
                if (tep_session_is_registered('customer_id')) {  // IF the customer is registered, use Upload Dir
                  $products_options_file->set_destination(UPL_DIR);
                } else { // If the customer is not registered, use Temporary Dir
                  $products_options_file->set_destination(TMP_DIR);
                }
                //EOF - Zappo - Option Types v2 - Set Upload directory (Registered customers in Uploads, other in Temporary folder)
                if ($products_options_file->parse(TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i])) {
                  if (tep_session_is_registered('customer_id')) {
                    tep_db_query("insert into " . TABLE_FILES_UPLOADED . " (sesskey, customers_id, files_uploaded_name, date) values('" . tep_session_id() . "', '" . $customer_id . "', '" . tep_db_input($products_options_file->filename) . "', '" . date("d-m-y") . "')");
                  } else {
                    tep_db_query("insert into " . TABLE_FILES_UPLOADED . " (sesskey, files_uploaded_name, date) values('" . tep_session_id() . "', '" . tep_db_input($products_options_file->filename) . "', '" . date("d-m-y") . "')");
                  }
                  //BOF - Zappo - Option Types v2 - Set File Prefix
                  if (OPTIONS_TYPE_FILEPREFIX == 'Database') {  //  Database ID as File prefix
                    $insert_id = tep_db_insert_id() . '_';
                  } else {  //  Date, time or both as File prefix (Change date formatting here)
                    if (OPTIONS_TYPE_FILEPREFIX == 'Date' || OPTIONS_TYPE_FILEPREFIX == 'DateTime') {
                      $insert_id = 'D'.date("d-m-y_");
                    }
                    $insert_id .= (OPTIONS_TYPE_FILEPREFIX == 'DateTime' || OPTIONS_TYPE_FILEPREFIX == 'Time') ? 'T'.date("H-i_") : '';
                  }
                  //EOF - Zappo - Option Types v2 - Set File Prefix
                  // Update filename in Database with correct prefix (For comparing database names with real files)
                  tep_db_query("update " . TABLE_FILES_UPLOADED . " set files_uploaded_name = '" . tep_db_input($insert_id . $products_options_file->filename) . "' where sesskey = '" . tep_session_id() . "' and files_uploaded_name = '" . tep_db_input($products_options_file->filename) . "' and date = '" . date("d-m-y") . "'");
                  $real_ids[TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]] = $insert_id . $products_options_file->filename;
                  $products_options_file->set_filename($insert_id . $products_options_file->filename);
                  if (!($products_options_file->save())) {
                    break 2;
                  }
                } else {
                  break 2;
                }
              } else { // No file uploaded -- use previously uploaded file
                $real_ids[TEXT_PREFIX . $HTTP_POST_VARS[UPLOAD_PREFIX . $i]] = $HTTP_POST_VARS[TEXT_PREFIX . UPLOAD_PREFIX . $i];
              }
            }
          }
        
//EOF - Zappo - Option Types v2 - File uploading: save uploaded files with unique file names, in the proper folder

                                // BOF QPBPP for SPPC
                                $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);
// EOF QPBPP for SPPC
                              }
                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;

Is this ok? or would you rather I post the whole application_top.php

Thanks again.
Rich

#25   Zappo

Zappo
  • Members
  • 201 posts
  • Real Name:Albert van Osch
  • Gender:Male
  • Location:the Netherlands, Asten

Posted 04 July 2009 - 03:05 PM

View Postsmoothgift, on Jul 4 2009, 03:48 PM, said:

Is this ok?
Nope. That's not ok...  :D
That great contribution isn't too hard to merge. You missed one line:
You need to change your $cart->add_cart() (Where QPBPP changes are also made)
FROM:
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);

TO:
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $real_ids))+$HTTP_POST_VARS['cart_quantity'], $real_ids);

That should do it...

(Explanation: $HTTP_POST_VARS['id'] contains the attributes array, which is replaced by $real_ids so that the uploads can be added to this array)

View Postsmoothgift, on Jul 4 2009, 03:48 PM, said:

I can't define upload-option values in admin's option value type because it has been taken off the drop down list of values available.
This is because the Upload (and Text) option VALUES are input by the customer! (The value is the given text, or the file)
You just need the Options for Text, Textarea and Uploads. (However, the Option-Value "0 - CUSTOMER-INPUT" has to be set! (Should be done automatically))

Edited by Zappo, 04 July 2009 - 03:17 PM.

Check out my website! shop.crystalcopy.nl


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

#26   smoothgift

smoothgift
  • Members
  • 51 posts
  • Real Name:Richard

Posted 04 July 2009 - 03:45 PM

View PostZappo, on Jul 4 2009, 04:05 PM, said:

Nope. That's not ok...  :D
That great contribution isn't too hard to merge. You missed one line:
You need to change your $cart->add_cart() (Where QPBPP changes are also made)
FROM:
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);

TO:
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $real_ids))+$HTTP_POST_VARS['cart_quantity'], $real_ids);

That should do it...

(Explanation: $HTTP_POST_VARS['id'] contains the attributes array, which is replaced by $real_ids so that the uploads can be added to this array)


This is because the Upload (and Text) option VALUES are input by the customer! (The value is the given text, or the file)
You just need the Options for Text, Textarea and Uploads. (However, the Option-Value "0 - CUSTOMER-INPUT" has to be set! (Should be done automatically))

Nice one Zappo!

What I have done since your last suggestion was to go back and strip the case 'add_product' of other contributions. Just left it with your code as it was and it worked! Now, uploaded files are correctly displayed in the Cart and with the eye link. Thanks for the lead!

I will go and make your suggested changes and see how it goes. Many many thank Zappo!

Rich

#27   Terrible Terry

Terrible Terry
  • Members
  • 104 posts
  • Real Name:Terry

Posted 05 July 2009 - 05:42 PM

Problem with Previous files if using more than one upload field
2nd drop down list is doubled.

I am using the original code supplied with contribution,
Anyone know how to correct this?

[img]http://transfertown.com/catalog.jpg[/img]
Listen Everyone!
Just be Calm,  Cooperate and this will all be over in a minute

#28   Zappo

Zappo
  • Members
  • 201 posts
  • Real Name:Albert van Osch
  • Gender:Male
  • Location:the Netherlands, Asten

Posted 06 July 2009 - 09:26 AM

View PostTerrible Terry, on Jul 5 2009, 07:42 PM, said:

Problem with Previous files if using more than one upload field
2nd drop down list is doubled.
I forgot to add a line (resetting the dropdown)...

Here's what to do:
in catalog/includes/modules/option_types.php
FIND:
//BOF - Zappo - Option Types v2 - Added dropdown with previously uploaded files (around line 110)
beneath it ADD:
if ($old_uploads == true) unset($uploaded_array);

That should to the trick!

(This will of course be added to the next OptionTypes release)

Edited by Zappo, 06 July 2009 - 09:27 AM.

Check out my website! shop.crystalcopy.nl


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

#29   Terrible Terry

Terrible Terry
  • Members
  • 104 posts
  • Real Name:Terry

Posted 06 July 2009 - 11:31 AM

View PostZappo, on Jul 6 2009, 09:26 AM, said:

I forgot to add a line (resetting the dropdown)...

Here's what to do:
in catalog/includes/modules/option_types.php
FIND:
//BOF - Zappo - Option Types v2 - Added dropdown with previously uploaded files (around line 110)
beneath it ADD:
if ($old_uploads == true) unset($uploaded_array);

That should to the trick!

(This will of course be added to the next OptionTypes release)

Thanks for your quick response and this contribution.
Your fix above works like a charm
Thanks again
Listen Everyone!
Just be Calm,  Cooperate and this will all be over in a minute

#30   smoothgift

smoothgift
  • Members
  • 51 posts
  • Real Name:Richard

Posted 06 July 2009 - 01:30 PM

View PostZappo, on Jul 4 2009, 04:05 PM, said:

Nope. That's not ok...  :D
That great contribution isn't too hard to merge. You missed one line:
You need to change your $cart->add_cart() (Where QPBPP changes are also made)
FROM:
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);

TO:
$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $real_ids))+$HTTP_POST_VARS['cart_quantity'], $real_ids);

That should do it...

(Explanation: $HTTP_POST_VARS['id'] contains the attributes array, which is replaced by $real_ids so that the uploads can be added to this array)


This is because the Upload (and Text) option VALUES are input by the customer! (The value is the given text, or the file)
You just need the Options for Text, Textarea and Uploads. (However, the Option-Value "0 - CUSTOMER-INPUT" has to be set! (Should be done automatically))
I applied the change and it worked beautifully!
Further up this page, I read that you are working or planned on working on a new contribution "Products as Options" which will enable tracking product options as products. Sounds great. Myself and a lot more people than you can imagine will appreciate such a contribution, if you can pull it off. I can imagine it will be a great task.

Zappo, once again Thanks.

#31   Zappo

Zappo
  • Members
  • 201 posts
  • Real Name:Albert van Osch
  • Gender:Male
  • Location:the Netherlands, Asten

Posted 06 July 2009 - 06:02 PM

View Postsmoothgift, on Jul 6 2009, 03:30 PM, said:

1 - I applied the change and it worked beautifully!
2 - I read that you are working or planned on working on a new contribution "Products as Options"
3 - Myself and a lot more people than you can imagine will appreciate such a contribution, if you can pull it off. I can imagine it will be a great task.
4 - Zappo, once again Thanks.
1 - Nice! I'll be using SPPC/QPBPP myself (When I'm done with the rest)
2 - I'm ALMOST done... Need some (ok... a lot of) cleaning up, and some kind of readme... Then I'll release it.
3 - Good to know it'll probably be appreciated!
4 - My pleasure.
Check out my website! shop.crystalcopy.nl


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

#32   kenz

kenz
  • Members
  • 157 posts
  • Real Name:kensley

Posted 07 July 2009 - 02:17 PM

View PostZappo, on Jun 16 2009, 08:56 AM, said:

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


Hello,
Is there a installation guide this contribution. I already have other contributions installed.

Thanks

#33   Zappo

Zappo
  • Members
  • 201 posts
  • Real Name:Albert van Osch
  • Gender:Male
  • Location:the Netherlands, Asten

Posted 07 July 2009 - 02:23 PM

View Postkenz, on Jul 7 2009, 04:17 PM, said:

Is there a installation guide this contribution. I already have other contributions installed.
No, Sorry...
You'll have to use a comparison software like kDiff3 to compare your installation with Option Types v2
(I really can't imagine merging contributions without file comparison!)
All changes are very well commented throughout the files...
Check out my website! shop.crystalcopy.nl


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

#34   kenz

kenz
  • Members
  • 157 posts
  • Real Name:kensley

Posted 07 July 2009 - 02:26 PM

View PostZappo, on Jul 7 2009, 10:23 AM, said:

No, Sorry...
You'll have to use a comparison software like kDiff3 to compare your installation with Option Types v2
(I really can't imagine merging contributions without file comparison!)
All changes are very well commented throughout the files...

ok,
I did a drop on top installation for a clean install just to test it out.  But I received an error when trying to create a new option...

1054 - Unknown column 'products_options_type' in 'field list'
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 ('6', 'blueshade', '1', '3', '1', 'this is a blueshade', '6')

any clue where I went wrong?
thanks

#35   kenz

kenz
  • Members
  • 157 posts
  • Real Name:kensley

Posted 07 July 2009 - 02:42 PM

View Postkenz, on Jul 7 2009, 10:26 AM, said:

ok,
I did a drop on top installation for a clean install just to test it out.  But I received an error when trying to create a new option...

1054 - Unknown column 'products_options_type' in 'field list'
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 ('6', 'blueshade', '1', '3', '1', 'this is a blueshade', '6')

any clue where I went wrong?
thanks

Zappo I believe I fixed it.  The error and answer are pretty clear in that statment I posted. So I just created the columns.

Nice contribution by the way, very cool.

kenz

Edited by kenz, 07 July 2009 - 02:43 PM.


#36   kenz

kenz
  • Members
  • 157 posts
  • Real Name:kensley

Posted 07 July 2009 - 02:51 PM

View Postkenz, on Jul 7 2009, 10:42 AM, said:

Zappo I believe I fixed it.  The error and answer are pretty clear in that statment I posted. So I just created the columns.

Nice contribution by the way, very cool.

kenz

I received an error stating the function for TMP_DIR is missing because its needed on application_top.php on line 372.

please help,
thanks

#37   Zappo

Zappo
  • Members
  • 201 posts
  • Real Name:Albert van Osch
  • Gender:Male
  • Location:the Netherlands, Asten

Posted 07 July 2009 - 02:59 PM

View Postkenz, on Jul 7 2009, 04:51 PM, said:

I received an error stating the function for TMP_DIR is missing because its needed on application_top.php on line 372.
1- Did you run the SQL file included with the installation?
2- Did you copy the file catalog/includes/local/configure.php?
3- Check in application_top.php, Line 25, (Set the local configuration parameters) if includes/local/confige.php is included (Default = enabled)
4- Did you copy/create the folders images/temp and images/uploads?

If all above are answered 'yes', I'll need more info on your problem... That should not occur...
Check out my website! shop.crystalcopy.nl


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

#38   kenz

kenz
  • Members
  • 157 posts
  • Real Name:kensley

Posted 07 July 2009 - 03:24 PM

View PostZappo, on Jul 7 2009, 10:59 AM, said:

1- Did you run the SQL file included with the installation?
2- Did you copy the file catalog/includes/local/configure.php?
3- Check in application_top.php, Line 25, (Set the local configuration parameters) if includes/local/confige.php is included (Default = enabled)
4- Did you copy/create the folders images/temp and images/uploads?

If all above are answered 'yes', I'll need more info on your problem... That should not occur...

I did all the following except for number one - there is no SQL file in the package.  if so, please explain where it is. I looked in multiple folders.

thanks

#39   Zappo

Zappo
  • Members
  • 201 posts
  • Real Name:Albert van Osch
  • Gender:Male
  • Location:the Netherlands, Asten

Posted 07 July 2009 - 03:35 PM

View Postkenz, on Jul 7 2009, 05:24 PM, said:

there is no SQL file in the package.
Option Types v2 SQL.sql
It's in the root of the zip file (when you open the zip, it's right there!)
along with the index.html

I don't see how you could miss it!!

Run it (via phpMyAdmin), and you should be fine.
It could be that because you manually added fields to the dB, the script will fail.
Maybe it's best to remove those manual dB changes before running the sql...

Edited by Zappo, 07 July 2009 - 03:37 PM.

Check out my website! shop.crystalcopy.nl


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

#40   kenz

kenz
  • Members
  • 157 posts
  • Real Name:kensley

Posted 07 July 2009 - 03:59 PM

View PostZappo, on Jul 7 2009, 11:35 AM, said:

Option Types v2 SQL.sql
It's in the root of the zip file (when you open the zip, it's right there!)
along with the index.html

I don't see how you could miss it!!

Run it (via phpMyAdmin), and you should be fine.
It could be that because you manually added fields to the dB, the script will fail.
Maybe it's best to remove those manual dB changes before running the sql...


Zappo i see what you mean.  but when you extract the pacakage with winzip onto a desktop, it only shows the following folders...

admin
includes
images

and the following files...

checkout_confirmation.php
product_info.php
stylesheet.css
account_history_info.php
checkout_process.php
shopping_cart.php


I had to literately drag the sql file out of the winzip gui and drag it to my desktop

-kenz