Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Option Types v2


Zappo

Recommended Posts

I am having a problem with Option Types V2. I have created a product which contains both drop down selection boxes and text boxes. When I enter text in the box, the text appears in my shopping cart. Then when I login, when I get to the order confirmation screen, the drop down selections are OK but the text I entered is gone and it says CUSTOMER-INPUT. After I'm logged in, if I order a product going from shopping cart to order confirmation works fine. What would cause the text I entered to disappear going from shopping cart, logging in, and going to confirmation? Thanks for your help.

Link to comment
Share on other sites

  • 2 weeks later...

Hi there,

I actually designed the checkboxes to be a one-choice option (Example: you want giftwrapping? Yes/No)

As you can only select ONLY ONE Attribute per Option, Multiple checkboxes will not work!

(Color: Red, Blue, Green or Yellow ---> You CAN NOT select Red AND Green, just 1 at a time...)

I recommend you use Radio's instead....

 

This is confusing because radio buttons are for only one selection while checkboxes are used for multiple selections.

 

I understand the way OSCommerce works, but there is a contribution that allows multiple "Product Options" selections.

And another contribution that adds checkboxes for multiple "Product Options" selections. If you do some research you can find them in the contributions.

 

But this contribution can work wonderfully for any possible scenario you have and it is easy to understand.

 

The scenario is pizza with product options' toppings...

OSCommerce's structure is...

1. Product Options

2. Option Types

3. Product Attributes

 

So a "Product Option" (1) would be a topping like "Pepperoni"

Then Option Types (2) would be "Yes" ("Yes" can be used over and over with other different "Product Options")

Then your Product Attribute (3) would be "Pepperoni" with "Yes" and fill in the price

 

On the front end it will look like --- "Pepperoni: []" a checkbox without title AND it doesn't matter how many Option Types assigned to Pepperoni with checkbox it will only display a [] (box) without a title.

 

If a Radio Button is used instead of a checkbox the front view is "Pepperoni: O Yes O No" without a bubble checked AND when a bubble is clicked the bubble can only be "cleared" by selecting another bubble in the Product Option series (for instance if the "Yes bubble" is filled in it can only be cleared by clicking "filling in" the "No bubble". Once a selection is made in radio button series it cannot be undone, but checkboxes can be unchecked.

 

So the No does not need to be used, only the Yes (and "Yes" can be any text) for checkboxes.

And radio buttons are used similar as the default dropdown with only one selection possible.

Edited by Silver Captain
Link to comment
Share on other sites

I am trying to build this contribution into OSCMax - mainly for the text option that OSCMax doesn't have. We currently have a shop with text-options fully working, but are trying to build OSCMax up to where we currently are (because of the features that Max has in it that we don't have in our current shop).

 

I've got it working most of the way, but am running into this scenario with the shopping cart... and this is only with the TEXT option.

 

1. If only text is entered, everything appears to work fine.

2. If we enter any symbol in the text form that is converted code - such as ampersand, quotes, etc. - that's when things fail.

 

Here's what happens:

 

1. The item adds to the cart fine

2. Once in the cart, if the UPDATE button is clicked, it duplicates the item on to another line in the cart

3. You can delete all the duplicates, but never the original one placed in the cart

4. This same behavior happens if you select a new and unique item and add it to the cart. UPDATING duplicates them, and you can delete all of them EXCEPT for the first of each item added to the cart.

5. When you have an item with a text item in the cart and use the link back to the product, it normally auto-fills the text form on product_info.php with the data used for the original text option when the item was added to the cart. In the above scenario, the auto-fill breaks and when you use the link from the shopping cart back to the product, the text forms are now empty.

 

When using view source to compare our current working shop's shopping_cart.php browser code to the new that we are building, I see that the (in this example) that the ampersand in our working shop is represented by

&

and in the failing code it's represented by

&

If I keep UPDATING the cart and the list of duplicate items grows, the ampersand in this example continues to accumulate and eventually is represented by something like:

&... and on and on

 

I don't know if that is a separate issue or what's causing it to fail. I'm continuing to compare our current working code to what we are building, but cannot locate where things are failing.

 

Anyone have a direction to point me in? I've dug through product_info.php, application_top.php, option_types.php, various function and module files, and cannot locate the failure.

Link to comment
Share on other sites

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?

 

Yes. A </form> tag is missing, that is the reaon.

 

To be more precise, in /catalog/admin/products_attributes.php,

Change this:

        <td>
         <form name="attributes" action="<?php echo tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=' . $form_action . '&option_page=' . $option_page . '&value_page=' . $value_page . '&attribute_page=' . $attribute_page); ?>" method="post">
         <table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td colspan="7" class="smallText">

to this

        <td>
<!-- 	form name="attributes" START 1	//-->
         <form name="attributes" action= "<?php echo tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 
              'action=' . $form_action . 
              '&option_page=' . $option_page . 
              '&value_page=' . $value_page . 
              '&attribute_page=' . $attribute_page); ?>" method="post">
         </form>
<!-- 	form name="attributes" END 1	//-->
         <table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td colspan="7" class="smallText">

The essential difference is </form>

The other differences are for readability.

 

Eveline

Link to comment
Share on other sites

Hello!!

 

I am not sure if I found another issue or its my site only....

 

It seems if I add attributes to a product and then add an upcharge for the attribute everything is ok.

 

When I save it as a template - everything seems ok.

 

When I try to apply the saved template to another product the attributes transfer however the upcharges do not...

 

Anyone have this issue?? Anyone know where I can start looking to solve this problem??

 

 

Thanks A Mil...

PN

Link to comment
Share on other sites

Hello!!

 

I am not sure if I found another issue or its my site only....

 

It seems if I add attributes to a product and then add an upcharge for the attribute everything is ok.

 

When I save it as a template - everything seems ok.

 

When I try to apply the saved template to another product the attributes transfer however the upcharges do not...

 

Anyone have this issue?? Anyone know where I can start looking to solve this problem??

 

 

Thanks A Mil...

PN

 

Found it!

 

When you add a product option you cannot add the upcharge to it - you have to also add a option value then add the upcharge to the option value - when you make a template and then transfer it to another product all the values carry over....

 

Thanks

PN

Link to comment
Share on other sites

Hi Zappo

 

I have just spent the afternoon reading through this whole thread from start to finish, there has certainly been allot of input, not to mention some terrific support!

 

Before I go ahead and install Option Types V2, I was wondering if you wouldn't mind advising me on a couple of things.

 

Firstly, There are a number of great attribute types already included, but how difficult would it be to add a couple more attribute types, one being date and the other being time.

 

This would be great for me as I run a business that provides training by the hour, so if when someone is ordering their training online, they had the ability to enter a date and time or range of dates and times they would be available for training that would be great.

 

Later on perhaps if there was an attribute (button) on the product_info page for the training product that would allow the customer to check availability by linking into a calendar on an MS Exchange server and displaying and making selectable the available time slots by a selectable view of day/week/month.

 

It would also be great if this sort of function could be used for both booking training and workshop time for rebuilds and repairs etc.

 

Any comments and suggestions on how I might best approach this would be greatfully received!

 

All the best,

Peter.

Link to comment
Share on other sites

Firstly, There are a number of great attribute types already included, but how difficult would it be to add a couple more attribute types, one being date and the other being time.

 

Later on perhaps if there was an attribute (button) on the product_info page for the training product that would allow the customer to check availability by linking into a calendar on an MS Exchange server and displaying and making selectable the available time slots by a selectable view of day/week/month.

 

It would also be great if this sort of function could be used for both booking training and workshop time for rebuilds and repairs etc.

Hi Peter,

 

I can't instantly think of a way of adding Time/Date as an attribute (Let alone an Exchange server link), HOWEVER...

Option Types v2 is made to fairly easily add new Option types.

After installing, you'll only have to add the coding for the Time/Date Type to includes/modules/option_types.php! (and then some references for your new OptionType, to have it show up in Admin --> We'll get to that when you have the Option set up)

I don't know your programming skills, but in my view, with novice/intermediate knowledge you should be able to get it done.

I suggest you first have a look at the option_types.php file, and see how it is setup.

If you have a test installation to try stuff out, I advise to REPLACE an existing OptionType (OPTIONS_TYPE_TEXT) to try your Date/Time code, and add the final version after your test install is working.

Also, because Date and Time will have A LOT of different options, I advise to collect the Date and Time as a Text value, and pass it in the same way as Text options (although this will add some more files to edit, you can search for OPTIONS_TYPE_TEXT, and do the same thing for your Date/Time option - The only NEW code will be in option_types.php, the rest can be copied from OPTIONS_TYPE_TEXT)

One other note though: If you want to add a price to the Time or Date selection, I can't think of a way to calculate, let alone set the price for those attributes... (It will only have 1 price for the Time and/or Date selection)

 

I hope this will get you on your way.

 

-EDIT-

Just thought of some other things:

The code for checking your Exchange server, could just be added to your new Option Type's code (IF buttonpress -> check server, then IF not available -> display message (Or even disable selection))

OR

BEFORE loading the option, maybe add some code to disable the dates and times that are not available...

 

P.S.

If you have the Option Type setup, you can use it over & over again on any product you like.

Edited by Zappo

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

Link to comment
Share on other sites

Hi Zappo,

 

Thanks for the reply, and for the great advice! having read the thread earlier today and seeing some of the other requirements some people were coming up with and your comments and advice on them, I knew you would have some good advice for me B)

 

I have a background in large scale ERP systems, and have done some similar pc/server development, not a huge amount in PHP but plenty in other flavours of SQL and mostly in RPG/400 on an AS/400. Although I came out of that game in 2002.

 

My osCommerce store isnt live just yet (it's in a subdomain off the main domain that has no links from the main site yet) so I have an environment I am more than happy to play about with and not worry too much if I experience problems along the way.

 

Thinking about date and time and the many different options there are for things like format etc. osCommerce has a routine in the main language file (catalog/includes/language/english.php) that sets the format, so providing the date and time option types call and use the same routine, they should both work in unison with the other date and time fields within the system. The other benefit being that if someone wants to change from mm/dd/yy to dd/mm/yy or vice versa, they only need make the change in one place.

 

Maybe this could become an option in the config section of the admin area, as currently there is no such option! I can't believe that one was missed, but it certainly appears to have been!

 

Thanks for your advice on checking the exchange server, That sounds like the way to go, so I will spend some time working the process flow through before I look at coding anything.

 

Fortunatley there are no requirements in this instance for different prices for different dates or times, its a flat rate per hour so there is no need for any additional pricing code.

 

Thinking about it there is already a function in OSC that brings up a calendar for people to select the date they want from, as in the catalog section of the admin area, when someone sets the date effective from field on a product, if they click the button next to the field, it launches a little calendar box, maybe I could look at the code and see if I can call that function in the option type code.

 

The way I see it working is the customer has the ability to either enter a date range in which they would be happy to take their training or they can click a check availability button and select an actual date and time that is available and confirm their booking there and then.

 

Again thinking about it, it would probably be wise to store the date and time they selected somewhere and only confirm the booking in the calendar once they complete the checkout process.

 

What do you think?

 

Best wishes,

Peter.

Link to comment
Share on other sites

Thinking about date and time and the many different options there are for things like format etc. osCommerce has a routine in the main language file (catalog/includes/language/english.php) that sets the format, so providing the date and time option types call and use the same routine, they should both work in unison with the other date and time fields within the system. The other benefit being that if someone wants to change from mm/dd/yy to dd/mm/yy or vice versa, they only need make the change in one place.

 

Maybe this could become an option in the config section of the admin area, as currently there is no such option! I can't believe that one was missed, but it certainly appears to have been!

 

Thinking about it there is already a function in OSC that brings up a calendar for people to select the date they want from, as in the catalog section of the admin area, when someone sets the date effective from field on a product, if they click the button next to the field, it launches a little calendar box, maybe I could look at the code and see if I can call that function in the option type code.

 

The way I see it working is the customer has the ability to either enter a date range in which they would be happy to take their training or they can click a check availability button and select an actual date and time that is available and confirm their booking there and then.

It would probably be wise to store the date and time they selected somewhere and only confirm the booking in the calendar once they complete the checkout process.

 

What do you think?

I agree.

 

osCommerce IS missing a date format option in Admin. The way it works now, is that it's set on a per-language basis (through the main language files)

Also, you are correct on the calendar thing. I think it's sensible to re-use that code (Why re-invent the wheel?)

 

About storing the date and time "Somewhere", I'd use the Shopping Cart object for that. It's Perfect for the job!

After checkout, the cart is emptied, stock products are subtracted, and (in your case) the date and time are booked.

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

Link to comment
Share on other sites

hello

i have just installed oscommerce rc2a with the following contributions : seperate pricing per customer 4.2.2 and SPPC pricebreaks v2.

after installing option type in admin everything worked ok.

i also get produkt_info.php installed and working. but after choosing a tex or textarea atribute the shopping cart stays empty. <_<

the problem lies in the fact that the attribute code in several php files are so much different from original ocs rc2a that i can not make anything out of it to replace it

with the code from the option type v2contribution.

has anyone installed all 3 contributions ??

please give me a solution or the correct code to use all 3 contributions together :rolleyes:

many,many thanks

eric

Hi Eric,

I actually contributed a little to those contribs as well, and did merge them with the previous version of Option Types...

Although the "old" Option Types contrib is very much the same, it's not identical.

So it can be done (and I will do it again with Option Types v2, but not for a while I'm afraid)

 

If you need some help with any particular code, just drop me a message.

 

Hello Zappo

 

I'm trying to get this 3 things to work together too.

 

Everything works fine with the default (drop down) options. My problem is to get the SPPC prices for attributes to show up in the other option types (radio, checkbox etc). So I stuck right now in modules/option_types.php. I was trying to find how you merged the "older" version of option types, but I couldn't find anything.

 

Any link will be appreciated :)

Link to comment
Share on other sites

Hello Zappo

I was trying to find how you merged the "older" version of option types, but I couldn't find anything.

Any link will be appreciated :)

Hi "Blender" :-"

Actually, those files are only located on my running webshop, and my home computer. :P

And with "older version", I mean another contribution (the one Option Types v2 is based upon)

I was only trying to say that I did it with THAT contribution (which mostly works the same way), and so it is possible with this one. There is no specific coding available...

However, I do have a few pointers (and some code from the "older Merging"):

- I never succeeded in merging SPPC with the Attribute manager. I'd leave that one alone for now...

- You'll have to get the Admin side merged first, so you can save the SPPC-Group prices

- You'll have to get the Attributes_id (If not done already): Add (in product_info.php, in the $products_options_name_query) patrib.products_attributes_id

- Add the SPPC attribute-pricing code to the Queries in option_types.php ($products_attribs_query & $products_options_query)

- The code from the queries should become something like:

"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 = " . $products_options_name['products_attributes_id'] . " and pa.products_attributes_id = pag.products_attributes_id and pag.customers_group_id = '" . $customer_group_id . "'"

 

I think this should get you on your way...

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

Link to comment
Share on other sites

Hi Zappo,

 

I have just installed Option Types V2.1.3, now for some reason I am not able to add anything to the shopping cart at all, even products with no attributes.

 

Any ideas on where to look?

 

Thanks,

Peter.

Link to comment
Share on other sites

Any ideas on where to look?

Uuuhm...

Could be a lot of things, but I'd start with application_top (the case 'add_product' part) and/or maybe the shopping cart class...

Did you use a tool to merge the files (kDiff or sumptin'), or did you merge them by hand?

(I REALLY recommend using kDiff to check the differences between Original, Project, and new Addon files)

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

Link to comment
Share on other sites

Hi Zappo,

 

I have done a bit more playing around with this problem now and have come up with the following;

 

In catalog/includes/application_top.php the instruction call for identifying the following code;

 

case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);

 

And replacing it with the following;

 

//BOF - Zappo - Option Types v2 - File uploading: Purge the Temporary Upload Dir

$purgeDir = opendir(TMP_DIR) or die ('Could not open '.TMP_DIR);

while ($file = readdir($purgeDir)) {

if ($file != ('.htaccess') && $file != ('.') && $file != ('..') && 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);

//EOF - Zappo - Option Types v2 - File uploading: Purge the Temporary Upload Dir

 

//BOF - Zappo - Option Types v2 - ONE LINE - Set real_ids for processing

$real_ids = $HTTP_POST_VARS['id'];

//BOF - Zappo - Option Types v2 - File uploading: save uploaded files with unique file names, in the proper folder

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++) {

$TEMP_FILE = $_FILES['id']['tmp_name'][TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]];

if (tep_not_null($TEMP_FILE) && $TEMP_FILE != '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 (From Dropdown)

$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 - Zappo - Option Types v2 - ONE LINE - Replace the posted array with the processed one.

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

 

 

If I leave the original code in place, the add to cart button works fine and the product is added to the cart, if however, I replace it with the Option Types V2 code, in its raw form I get an error in application_top.php as follows;

 

Parse error: syntax error, unexpected T_CASE in /homepages/0/d177551101/htdocs/pmashop/includes/application_top.php on line 444

 

This relates to what looks like an eronious } two lines below the original code, this is how the code looked before the update;

 

// customer adds a product from the products page

case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);

 

 

}

tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

break;

 

The parenthesis that causes the problems when the new code is applied is the one in bold above.

 

Any advice you can give me would be much appreciated!

 

Cheers,

Peter.

Link to comment
Share on other sites

OK i found my bug. It was a problem in the order.php.

 

Now i had a new problem.

 

I use the wishlist-contrib.

 

In the wishlist, the options are not displayed.

But when i put a article from the wishlist to the shopping-cart, the options are correct transmit to it.

 

I think, its only a display-problem in the wishlist, but i can´t find the bug.

 

Can somebody help me please?!

 

 

Hi Anja,

 

I think I am having a similar problem with CUSTOMER-INPUT being displayed. Could you post what the bug was in order.php? Thanks. Kris

Link to comment
Share on other sites

However, I do have a few pointers (and some code from the "older Merging"):

- I never succeeded in merging SPPC with the Attribute manager. I'd leave that one alone for now...

- You'll have to get the Admin side merged first, so you can save the SPPC-Group prices

- You'll have to get the Attributes_id (If not done already): Add (in product_info.php, in the $products_options_name_query) patrib.products_attributes_id

- Add the SPPC attribute-pricing code to the Queries in option_types.php ($products_attribs_query & $products_options_query)

- The code from the queries should become something like:

"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 = " . $products_options_name['products_attributes_id'] . " and pa.products_attributes_id = pag.products_attributes_id and pag.customers_group_id = '" . $customer_group_id . "'"

 

Hi Zappo, thank you for your help.

 

Admin side of SPPC is done already and there are no problems with any default function or default attributes. Also no thoughts right now to do something with the attribute manager, it's not that hard to use the osc tables to do that

 

In general I can say I'm on a good way. Following your suggestions I have now different option prices for different customer groups for all option types. Thats great, but there are still 2 issues

 

1) Adding the SPPC attribute-pricing code to the 2 queries in modules/option_types.php ($products_attribs_query & $products_options_query) made the "retail" prices to dissappear, so I added a if/else and finally the part looks like this

a ) $products_attribs_query

  $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");
// BOF SPPC
// forum http://www.oscommerce.com/forums/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
$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 . "' order by products_options_sort_order");
  }
// EOF SPPC

 

b ) $products_options_query (breaks for better reading)

     $products_options_query = tep_db_query("select distinct 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");
// BOF SPPC
     if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
     $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name,  pag.options_values_price, pag.price_prefix, pa.products_attributes_id 
  from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag
   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 pa.products_attributes_id = " . $ProdAtr_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");
  }
// EOF SPPC

 

The result of this? If there is a customer group #3 thats has no prices for options defined, instead of getting the retail price (standard osc) it displays 0, because there is nothing in TABLE_PRODUCTS_ATTRIBUTES_GROUPS for this group. A manual fix would be to hide the options for each customer group, I don't now

 

2) Adding the attributes ID to the $products_options_name_query in product_info.php multiplies each option type x the number of values it has. Ie, I can see the radio option "how much sugar" 3 times, because of the 3 options "bitter", "medium", "sweet". I think this happens because the attributes ID is getting included into the loop

  while ($products_options_name = tep_db_fetch_array($products_options_name_query)) { 

 

Well, I'm sorry for such a huge codefull post, just a report about where my mixing brought me till now :)

Link to comment
Share on other sites

In catalog/includes/application_top.php the instruction call for identifying the following code;

Any advice you can give me would be much appreciated!

Hi Peter.

PLEASE use the CODE tags on the forum when posting lines of code.

I'm not going to waste my time reading through all those lines of code, searching for a mistake...

Look at Multimixer's post. See how that's A LOT more readable than what you posted?

 

However, you stated you replaced the entire "case 'add_product'" code, when the first line should be kept in place.

Like I said in my previous post, I REALLY recommend using kDiff (or another merging software) to merge files.

Using a software like that will greatly simplify finding the differences between files, and minimize mistakes when merging them!

Edited by Zappo

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

Link to comment
Share on other sites

Hi Zappo,

 

Sorry about that, I'm still finding my way round this forum at the moment and wasnt sure how to show a code snippet. I have now worked it out, so in future I will use it whenever putting code on a post.

 

I have fixed the problem with application_top.php, as you mentioned it was the fact that I didnt have the case statement on the first line as I simply copied and pasted the code in the instructions and replaced it with the replacement code.

 

My software consists of Dreamweaver CS3 and the WinMerge comparison tool, so yes, I do use a comparison tool to check code changes in any contributions I install.

 

I have been looking at the calendar tool as used in the date effective from field on the product record, the calendar box itself is actually a java script, the code for which in catalog/admin/categories.php is as follows;

 

<link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
<script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
<script language="javascript"><!--
 var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);
//--></script>
<script language="javascript"><!--

 

I assume the call to this function would be much the same in option_types.php, which as you previously suggested, I have been looking at the option_type_text code. This code obviously wouldnt need the progress bar, which would simplify things a little. I would also need to create the $tmp_html variable, how would I best integrate the java script into this?

 

Thanks once again for your help :)

Link to comment
Share on other sites

Sorry about that.

 

This code obviously wouldnt need the progress bar, which would simplify things a little. I would also need to create the $tmp_html variable, how would I best integrate the java script into this?

No worries :thumbsup:

 

Adding the Javascript should be done in product_info.php. (Link to the Admin directory if you don't copy the script to catalog/includes/javascript!!!)

However, I don't know how the calendar javascript works... The code below just shows WHERE to put the new code. You'll still have to edit the "var dateAvailable = " line for your specific purpose.

I added some original code to show where to put the new code:

<link rel="stylesheet" type="text/css" href="stylesheet.css">
<link rel="stylesheet" type="text/css" href="admin/includes/javascript/spiffyCal/spiffyCal_v2_1.css">
<script language="Javascript" src="admin/includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
<script language="javascript"><!--
function popupWindow(url) {
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}

 var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);

// BOF - Zappo - Option Types v2 - Added for Form Field Progress Bar 
function textCounter(field,counter,maxlimit,linecounter) {
etc, etc, etc....

The first 2 lines you gave (with the locations of the css and js files) do not have to be changed. They just include the needed files.

The other line however, contains variables that are passed to the calendar script. You'll have to find out what variables to pass, and how to use them...

Edited by Zappo

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

Link to comment
Share on other sites

 

 

1) Adding the SPPC attribute-pricing code to the 2 queries in modules/option_types.php ($products_attribs_query & $products_options_query) made the "retail" prices to dissappear, so I added a if/else and finally the part looks like this

a ) $products_attribs_query

b ) $products_options_query (breaks for better reading)

 

The result of this? If there is a customer group #3 thats has no prices for options defined, instead of getting the retail price (standard osc) it displays 0, because there is nothing in TABLE_PRODUCTS_ATTRIBUTES_GROUPS for this group. A manual fix would be to hide the options for each customer group, I don't now

 

2) Adding the attributes ID to the $products_options_name_query in product_info.php multiplies each option type x the number of values it has. Ie, I can see the radio option "how much sugar" 3 times, because of the 3 options "bitter", "medium", "sweet". I think this happens because the attributes ID is getting included into the loop

 

Well, I'm sorry for such a huge codefull post, just a report about where my mixing brought me till now :)

 

MultiMixer,

Yeah I'm trying the same thing. I got similar results a little differently. PM me if you want to compare my version. My problem is that I cannot get the Text options to add to the cart. I'm thinking it's something in the classes/shopping_cart. Though it may be somewhere in the modules/option_types file. Do you have this problem as well?

Link to comment
Share on other sites

I am having a problem with Option Types V2. I have created a product which contains both drop down selection boxes and text boxes. When I enter text in the box, the text appears in my shopping cart. Then when I login, when I get to the order confirmation screen, the drop down selections are OK but the text I entered is gone and it says CUSTOMER-INPUT. After I'm logged in, if I order a product going from shopping cart to order confirmation works fine. What would cause the text I entered to disappear going from shopping cart, logging in, and going to confirmation? Thanks for your help.

 

 

Hi Anja,

 

I think I am having a similar problem with CUSTOMER-INPUT being displayed. Could you post what the bug was in order.php? Thanks. Kris

 

I have the exact same problem, everything works fine, but when I review the orders, invoices, or any post-sale control. The CUSTOMER-INPUT text substitutes the text entered by the customer.

 

Please HELP!!!, it will be very much appreciated. Thanks.

Link to comment
Share on other sites

Hello Zappo

 

I'm trying to get this 3 things to work together too.

 

Everything works fine with the default (drop down) options. My problem is to get the SPPC prices for attributes to show up in the other option types (radio, checkbox etc). So I stuck right now in modules/option_types.php. I was trying to find how you merged the "older" version of option types, but I couldn't find anything.

 

Any link will be appreciated :)

Link to comment
Share on other sites

MultiMixer,

Yeah I'm trying the same thing. I got similar results a little differently. PM me if you want to compare my version. My problem is that I cannot get the Text options to add to the cart. I'm thinking it's something in the classes/shopping_cart. Though it may be somewhere in the modules/option_types file. Do you have this problem as well?

Hi Rosemary

 

I got much more deeper into the issue the last 2 days, just didn't post anything not to spam the forum with half done things. It's very hard to get the 3xloop of product_info.php into modules/option_types.php. Also changes need to be done in shopping_cart.php to get a proper display of the choosen options. I'm pming you with more info and details

Edited by multimixer
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...