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

[Contribution] Option Types v2

Recommended Posts

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) 

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

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

Edited by burt
remove external link

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

Share this post


Link to post
Share on other sites
It works like a charm and was exactly what i needed!!!!! Thank you! Thank you!Thank you! :D

 

Thanks for your post!

 

After my initial post, I was hoping to edit the post later to change the link to the contribution, but that wasn't possible anymore...

So, here it is: http://addons.oscommerce.com/info/6818


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

Share this post


Link to post
Share on other sites

What a cool contribution!

 

I had experienced one problem but i solved it really easy.

Each time i reloaded the page there was an empty field added to the attributes.

 

So in line products_attributes.php comment out line 31.

 

Cheers!

Share this post


Link to post
Share on other sites
Each time i reloaded the page there was an empty field added to the attributes.

 

So in line products_attributes.php comment out line 31.

 

That should not happen...

I am also unable to reproduce that behavior...

 

You say an empty field is added to the attributes.

What do you mean? Product Attributes, Option Values or Options?

Since the particular code involves only Option Values, and should only trigger when Option Value Text is not (yet) correctly set, I don't understand what's going wrong here...

BUT, since the code is only a "safety measure", everything should work normally.

If you ARE going to comment out that line, you can comment out the lines 25 - 34. (- Zappo - Option Types v2 - Check if the option_value TEXT_UPLOAD_NAME is in place, and insert if not found)

These are unnecessary when line 31 is commented out...

 

Is anyone else able to reproduce this behavior?


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

Share this post


Link to post
Share on other sites

HTTP Server: Microsoft-IIS/6.0

PHP Version:5.2.3 (Zend: 2.2.0)

Databas: MySQL 5.0.45

PHPMyAdmin 3.1.3.1

It says : Temporary Uploads folder is automatically cleaned. How old the files must be for deletion, can be set via Admin.

 

When i go in Admin and open Option Types ther is nothing there to be set. Title, Value, Action. Everything is emty.

Whot i did wrong ??? Help ""

 

Contribution is just beutiful. Great Thanks !!!

Share this post


Link to post
Share on other sites
When i go in Admin and open Option Types ther is nothing there to be set. Title, Value, Action. Everything is emty.

Whot i did wrong ??? Help ""

 

I have no idea what went wrong, but I'm guessing the SQL file wasn't (properly) executed...

Go into your phpMyAdmin, and check the table "configuration_group" for the Option Types entry, and note the "configuration_group_id" number.

Then check the table "configuration", and find the Option Type values (use progress bars?, Upload File Prefix, Delete Uploads older than, upload directory and temporary directory)

These probably don't have the correct configuration_group_id... Set it to the value found in configuration_group

 

Lat me know if it works out.

We'll try another fix if it doesn't.

Edited by Zappo

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

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

This Is Really Excellent Post ........ It is working perfect But I ahve need this for v2.2rc2.

Plz Help Me for it. Thanks

Share this post


Link to post
Share on other sites
This Is Really Excellent Post ........ It is working perfect But I ahve need this for v2.2rc2.

Plz Help Me for it. Thanks

 

The difference between osCommerce 2.2rc2a and 2.2rc2 is VERY minimal: http://www.oscommerce.com/about/news,130

There are some bugs fixed in 2.2rc2a, but the rest is exactly the same! (2.2rc2a REPLACES 2.2rc2)

 

Option Types v2 should even be usable in older versions (like 2.2ms2)


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

Share this post


Link to post
Share on other sites

I downloaded this to peek at the files and visited your site to see it live - got to say it is a marked improvement on the buggy original Option Types contribution.

 

I have not used it in a store yet but intend to. Many thanks for sharing it.


Upon receiving fixes and advice, too many people don't bother to post updates informing the forum of how it went. Until of course they need help again on other issues and they come running back!

 

Why receive the information you require in good faith for free, only to then have the attitude to ignore the people who gave it to you?

 

There's no harm in saying, 'Thanks, it worked'. On the contrary, it creates a better atmosphere.

 

CHOOCH

Share this post


Link to post
Share on other sites
got to say it is a marked improvement on the buggy original Option Types contribution.

Thanks for the reply.

That's exactly the reason I created it!


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

Share this post


Link to post
Share on other sites
Thanks for the reply.

That's exactly the reason I created it!

 

Have you thought about linking your attributes to stock, or stock via QTPro?

Or in essence just giving your created attributes 'stock' so they get deducted as per sale?


Upon receiving fixes and advice, too many people don't bother to post updates informing the forum of how it went. Until of course they need help again on other issues and they come running back!

 

Why receive the information you require in good faith for free, only to then have the attitude to ignore the people who gave it to you?

 

There's no harm in saying, 'Thanks, it worked'. On the contrary, it creates a better atmosphere.

 

CHOOCH

Share this post


Link to post
Share on other sites
Have you thought about linking your attributes to stock, or stock via QTPro?

Or in essence just giving your created attributes 'stock' so they get deducted as per sale?

Actually, Yes, I have.

 

However, I use accounting software that's linked to osCommerce. (osFinancials)

Because of this, I have no use for QTPro. (I need to track real products for stock updating)

I'll actually be creating an entirely new contrib: Products as Options.

With that contrib, you'll be able to "group" products together as another product's Options:

For example: Main product = Shirt, Option products = Red Shirt, Blue Shirt, Green Shirt

When adding the product to the cart, it will use the selected Option Product as Main product...

 

The big difference: products attributes are no "real products", and have no stock-tracking (inside my accounting software)

Adding the Options as real products solves this problem...


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

Share this post


Link to post
Share on other sites

Is it possible to have a "one-time" fee per attribute no matter the quantity, and a second recurring fee, that gets multiplied based on the quantity?

 

Thanks

Share this post


Link to post
Share on other sites
Is it possible to have a "one-time" fee per attribute no matter the quantity, and a second recurring fee, that gets multiplied based on the quantity?

That Should be possible, however you'll have to be willing to do some programming of your own...

As I'm thinking of how to do this, I realize this isn't a very easy task...

It would involve having a second price field for attributes, and different attribute handling (in application_top) when adding products.

I'm not sure what you meant by quantity, but if you want the second fee to be used independent on the products selected, that would make things even harder...


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

Share this post


Link to post
Share on other sites
I'm not sure what you meant by quantity, but if you want the second fee to be used independent on the products selected, that would make things even harder...

 

"

I mean that if you by 25 of an item, there will be for example a "one-time fee" of $.75 per attribute, and a $.25 fee per attribute that gets multiplied by 25.

Share this post


Link to post
Share on other sites
I mean that if you by 25 of an item, there will be for example a "one-time fee" of $.75 per attribute, and a $.25 fee per attribute that gets multiplied by 25.

Ok, I get that, but with "an item" do you mean 25x the same product, OR 10x 'Product A', 10x 'Product B' and 5x 'Product C'?!?

That makes a big difference, as attributes are (separately) linked to products.

To osCommerce, 'Product A' with attribute 'Green' is not the same as 'Product A' with attribute 'Red'.... (which makes counting the number of added attributes somewhat difficult)


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

Share this post


Link to post
Share on other sites

I currently have the older "Product Attributes - Option Type Feature" installed and working on my site but I really need to get passed the 32 max char limit for textboxes. How do you recommend I go about incorporating this contribution when I already have the other one installed?

Edited by jkenfield

Share this post


Link to post
Share on other sites
Ok, I get that, but with "an item" do you mean 25x the same product, OR 10x 'Product A', 10x 'Product B' and 5x 'Product C'?!?

That makes a big difference, as attributes are (separately) linked to products.

To osCommerce, 'Product A' with attribute 'Green' is not the same as 'Product A' with attribute 'Red'.... (which makes counting the number of added attributes somewhat difficult)

Ill give an example:

 

We have a Birthday card.

The birthday card base price is $1 per card, with a one time $2 design fee. The base birthday card is in black and white.

There is an extra $.50 charge per color, with an extra $.10 design fee per color.

 

So if someone orders 25 birthday cards in black and white, the total will be $27 ($25 cards + $2 design fee)

If he orders 25 with two extra colors, then the price will be $52.20 ($50 cards + $2.20)

 

Is this the first way or second way you mentioned

 

Thank You

Share this post


Link to post
Share on other sites
I currently have the older "Product Attributes - Option Type Feature" installed and working on my site but I really need to get passed the 32 max char limit for textboxes. How do you recommend I go about incorporating this contribution when I already have the other one installed?

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

 

Ill give an example:

............

Is this the first way or second way you mentioned

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


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

Share this post


Link to post
Share on other sites
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:

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
-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

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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)

 

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

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

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

×