Jump to content
Zappo

[Contribution] Option Types v2

Recommended Posts

We had to comment our this code in html_output for the add to cart function to work at all.

$sts->image($src);

If it is not commented out we receive this error:

Fatal error: Call to a member function image() on a non-object in /html/catalog/includes/functions/html_output.php on line 78

Has any one seen a conflict with Option Types V2 and STS?

 

Maybe you will find this post interesting: Option types v2 + STS in application_top.php

Share this post


Link to post
Share on other sites

Thanks multimixer, will take a look.

That did fix the one bug, still fighting to get the filename of the upload to show:

 

I get everything posted but the upload:

 

1 x Product 1

- Size: 36x12x4

- Layout: Layout1

- Font: Aerial

- Text Area: Test

- Special Instructions: Test

Share this post


Link to post
Share on other sites

Sure: My link

 

It is still in testing and only goes to cod at the moment.

Okay, I just tested a clean version of Option Types V2 on a clean version of oScommerce 2.2rc2a and they both don't display the Upload:(filename)in the cart or admin panel.

 

Has anyone seen this on a clean install?

 

Thanks for any info.

Share this post


Link to post
Share on other sites

Hi everyone, i didnt know where else to ask this so i'm going to ask it here. This contibution works great but there is one snag, in the "admin/orders.php", "admin/invoice.php" and "admin/packingslip.php" the order of the options shown dont seem to be in particular order. Is there a way to correct this and order it in the using the sort order number?

 

Thanks for your help and thanks again for the contibution.

 

Zappo, do you have a donate page?

Share this post


Link to post
Share on other sites

Hi all.

Just a quick query. I have recently installed a couple of new contributions and the sort order for my attribute drop down box has changed albeit not on every product. I have checked the sort order in the product attributes in admin and all is ok in there but on the catalog side the sort order is wrong on some products but right on others. Can anyone tell me which file I need to be looking at to find out where the fault is?

The new contributions were Actual product price in attribute and add weight to product attributes.

 

Example of the problem can be found at www.aseawards.co.uk

Share this post


Link to post
Share on other sites

Hello all :)

 

I've been working on a validation script for this addon. I've got it working perfectly using the script in the first code window below. Life would have been much easier had I been able to actually debug javascript instead of guessing >_< Anyway, the code below works, but I wanted to change it around so that instead of the alert coming up once for every unselected option button group, one alert would come up listing all of the errors at once.

 

The code in the second code window has some preliminary testing code to see how things would work. My plan was to add text to my alertvar variable each time an error occurred, then at the end of the function, display the alert box with all changes needed.

 

The problem is, for some reason, the code at the end of the function never triggers.

 

if(errorvar==1){
alert(alertvar);
return false;
}

 

If I move this above the final closing tag from the where statement, it triggers just fine, but of course it happens several times because of the loop.

 

Why won't that code trigger if it's after the

 

	<?php
	}
?>

 

at the end? Is it because the variable is losing its value when it shifts to php mode for the closing bracket? Thanks for looking, and Zappo, thanks for the contribution, it laid the groundwork for some very complex option setups.

 

<script language="javascript"><!--
function validate_me(myform) {

<?php
// jeff added this stuff for radio button validation
  $products_verification_query = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " po where po.products_options_type='3'");

// loop through each option type that has radio buttons   
   while ($products_verification_array = tep_db_fetch_array($products_verification_query)) {
?>
	myOption = -1;	
		// loop through each element of the radio set 
		for (i=cart_quantity.elements['<?php echo 'id[' . $products_verification_array['products_options_id'] . ']'; ?>'].length-1; i > -1; i--) {



			if (cart_quantity.elements['<?php echo 'id[' . $products_verification_array['products_options_id'] . ']'; ?>'][i].checked) {
				myOption = i; i = -1;
			}

		}

		        if (myOption == -1) {
			cart_quantity.elements['<?php echo 'id[' . $products_verification_array['products_options_id'] . ']'; ?>'][0].focus();

				var alertvar = "You must make a selection from the '<?php echo $products_verification_array['products_options_name'];?>' group.";
				alert(alertvar);

				return false;
			}

<?php
	}
?>

}

//--></script>

 

<script language="javascript"><!--
function validate_me(myform) {

<?php
// jeff added this stuff for radio button validation
  $products_verification_query = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " po where po.products_options_type='3'");

// loop through each option type that has radio buttons   
   while ($products_verification_array = tep_db_fetch_array($products_verification_query)) {
?>
	myOption = -1;	
		// loop through each element of the radio set 
		for (i=cart_quantity.elements['<?php echo 'id[' . $products_verification_array['products_options_id'] . ']'; ?>'].length-1; i > -1; i--) {

			if (cart_quantity.elements['<?php echo 'id[' . $products_verification_array['products_options_id'] . ']'; ?>'][i].checked) {
				myOption = i; i = -1;
			}

		}
			if (myOption == -1) {
			cart_quantity.elements['<?php echo 'id[' . $products_verification_array['products_options_id'] . ']'; ?>'][0].focus();

				var alertvar = "You must make a selection from the '<?php echo $products_verification_array['products_options_name'];?>' group.";
				errorvar = 1;

			}

<?php
	}
?>

if(errorvar==1){
alert(alertvar);
return false;
}

}


//--></script>

Edited by zaaephod

Share this post


Link to post
Share on other sites

First let me say OUTSTANDING CONTRIBUTION AND SUPPORT!

 

Took me a little to get it going had the SQL issues with id#’s but this tread got me on the right track

 

Zaaephod did you get it to work?

 

I’m wondering if there is a way to do a validation on just one option and not all

 

I’m trying to set up a registration for fishing tournaments and need “agree to terms” check box but I have other radio and check boxes and they are not required

 

I’ve looked at the agree2terms mod but I would rather have this on the product page due to the fact they sell hats and shirts and no need to agree to terms for a hat maybe merge this mod in some way (I’m not script guru)

 

Maybe something for a future version to have a “required” option type in attributes

Share this post


Link to post
Share on other sites

I've needed a validation script for this addon. I used Jeffs code but fixed the SQL so it works for all products not just the first one...

 

Ben

 

When you create the form you'll need to add a onSubmit function like this: -

 

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product'), 'post', 'onSubmit="return validate_me(this);"'); ?>

 

Then the javascript is

 

<script language="javascript"><!--

function validate_me(myform) {

 

<?php

// jeff added this stuff for radio button validation

$products_verification_query = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " popt , " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and popt.products_options_type='3'");

 

// loop through each option type that has radio buttons

while ($products_verification_array = tep_db_fetch_array($products_verification_query)) {

?>

myOption = -1;

// loop through each element of the radio set

for (i=cart_quantity.elements['<?php echo 'id[' . $products_verification_array['products_options_id'] . ']'; ?>'].length-1; i > -1; i--) {

 

 

 

if (cart_quantity.elements['<?php echo 'id[' . $products_verification_array['products_options_id'] . ']'; ?>'].checked) {

myOption = i; i = -1;

}

 

}

 

if (myOption == -1) {

cart_quantity.elements['<?php echo 'id[' . $products_verification_array['products_options_id'] . ']'; ?>'][0].focus();

 

var alertvar = "You must make a selection from the '<?php echo $products_verification_array['products_options_name'];?>' group.";

alert(alertvar);

 

return false;

}

 

<?php

}

 

// Ben added this stuff for text field validation

$products_verification_query = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " popt , " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and popt.products_options_type in ('1', '2')");

 

// loop through each option type that has radio buttons

while ($products_verification_array = tep_db_fetch_array($products_verification_query)) {

?>

 

if (cart_quantity.elements['<?php echo 'id[txt_' . $products_verification_array['products_options_id'] . ']'; ?>'].value == "") {

var alertvar = "You must answer the question'<?php echo $products_verification_array['products_options_name'];?>'.";

alert(alertvar);

return false;

}

 

<?php

}

 

// Ben added this stuff for checkbox validation

$products_verification_query = tep_db_query("select * from " . TABLE_PRODUCTS_OPTIONS . " popt , " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and popt.products_options_type = '4'");

// loop through each option type that has radio buttons

while ($products_verification_array = tep_db_fetch_array($products_verification_query)) {

?>

if (cart_quantity.elements['<?php echo 'id[' . $products_verification_array['products_options_id'] . ']'; ?>'].checked != 1) {

var alertvar = "You must answer the question'<?php echo $products_verification_array['products_options_name'];?>'.";

alert(alertvar);

return false;

}

<?php

}

?>

 

}

 

//--></script>

Share this post


Link to post
Share on other sites

dear multimixer,

 

i wonder if you think there is a way to make the uploaded picture able to viewed even if without been looged into the account?

 

thanks

valeri

Share this post


Link to post
Share on other sites

Yeah, it would be nice if someone could update it for 2.3.1. I tried installing it, but there were alot of differences.

 

Nice Addon

 

Have anyone this Addon for 2.3.1???

 

Please

Share this post


Link to post
Share on other sites

looking to get this working with this add on...http://forums.oscommerce.com/index.php?showtopic=338661...Feedback much appreciated...

Share this post


Link to post
Share on other sites

Hi all

 

This addon is not working with version 2.3.1.

 

If you want to use it right now, you have to use osCommerce version rc2a, that you can upgrade to v2.3

 

Since Zappo is not very active recently, I will make a new version, compatible with 2.3.1 right after the holidays, looking in the same time into issues raised up here in the forum (like image preview etc), so be a little patient till then

Share this post


Link to post
Share on other sites

Since Zappo is not very active recently, I will make a new version, compatible with 2.3.1 right after the holidays, looking in the same time into issues raised up here in the forum (like image preview etc), so be a little patient till then

Thanks

Share this post


Link to post
Share on other sites

Hi

 

Looks excellent, but currently Download button fails to operate. (Shows nil bytes and zip file doesn't get downloaded). Is this an error or just in place during updates, Regards....

Share this post


Link to post
Share on other sites

I had a problem with the "One Page Checkout" contribution number 6646, where if I changed the quantity it lost the text details. To fix it:

 

In includes/classes/shopping_cart.php find

$this->contents[$products_id_string] = array('qty' => (int)$quantity);

 

Change this to:

if (isset($this->contents[$products_id_string]) && isset($this->contents[$products_id_string]['qty'])) {
 $this->contents[$products_id_string]['qty'] = (int)$quantity;
}
else {
 $this->contents[$products_id_string] = array('qty' => (int)$quantity);
}

 

Its not my fix, I posting it hoping someone else will also benefit.

Share this post


Link to post
Share on other sites

i have a problem.first sorry for my English. i have rc2a and i have Option Types v2 instaled. and i have Product Listing Enhancements, Thumbnails & Manufactur... instaled. my problem in product_list if i add a product; in SHOPPING CART without attributes.

in product_info.php is so:

//BOF - Zappo - Option Types v2 - ONE LINE - Initialize $number_of_uploads
   $number_of_uploads = 0;

   $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
   $products_attributes = tep_db_fetch_array($products_attributes_query);
   if ($products_attributes['total'] > 0) {
?>
         <table border="0" cellspacing="0" cellpadding="2">
           <tr>
             <td class="main" colspan="2"><?php echo TEXT_PRODUCT_OPTIONS; ?></td>
           </tr>
<?php
     //BOF - Zappo - Option Types v2 - Add extra Option Values to Query && Placed Options in new file: option_types.php
     $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_type, popt.products_options_length, popt.products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$product_info['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_order, popt.products_options_name");
     while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {

       // - Zappo - Option Types v2 - Include option_types.php - Contains all Option Types, other than the original Drowpdown...
       include(DIR_WS_MODULES . 'option_types.php');

       if ($Default == true) {  // - Zappo - Option Types v2 - Default action is (standard) dropdown list. If something is not correctly set, we should always fall back to the standard.
           $products_options_array = array();
        $products_options_query = tep_db_query("select 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)$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 . "' order by pa.products_options_sort_order");
       while ($products_options = tep_db_fetch_array($products_options_query)) {
         $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
         if ($products_options['options_values_price'] != '0') {
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
         }
       }

       if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
         $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
       } else {
         $selected_attribute = false;
       }
?>
            <tr>
             <td class="main"><?php echo $ProdOpt_Name . ':'; ?></td>
             <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $ProdOpt_ID . ']', $products_options_array, $selected_attribute) . '   ' . $ProdOpt_Comment;  ?></td>


          </tr><?php
     } // End if Default=true
 }
//EOF - Zappo - Option Types v2 - Add extra Option Values to Query && Placed Options in new file: option_types.php
?>

 

product_list:

function attribute_drop($products_id,$tax_class_id) {
   global $languages_id, $multi_add;
   $currencies = new currencies();
$atrib_drop = '';            
         $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
   $products_attributes = tep_db_fetch_array($products_attributes_query);
   if ($products_attributes['total'] > 0) {
       $atrib_drop = '<table border="0" cellspacing="0" cellpadding="2" class="attributes">';

       $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
     while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
       $products_options_array = array();
       $products_options_query = tep_db_query("select 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)$products_id . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
       while ($products_options = tep_db_fetch_array($products_options_query)) {
         $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
         if ($products_options['options_values_price'] != '0') {
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($tax_class_id)) .') ';
         }
       }
$atrib_drop .= '<tr><td class="attributes" >' . $products_options_name['products_options_name'] . ':' . '</td><td align="left">' . tep_draw_pull_down_menu('id' . ($multi_add ? '['. $products_id .']' : '') . '[' . $products_options_name['products_options_id'] . ']', $products_options_array) . '</td></tr>';

     }
                       $atrib_drop .= '</table>';
   }
       return $atrib_drop;
   }
   // function attribute_drop end

Please help me. How can i make appropriate- Thanks

Share this post


Link to post
Share on other sites

I would also like this for 2.3.1

Or, any ideas what add-on I can use to add text boxes to products?


Repetition is the key to success; Practice, Practice, Practice.

No outside links in signatures allowed.

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

×