Jump to content
Zappo

[Contribution] Option Types v2

Recommended Posts

Nope, no other contributions.

 

I added another option with the "Select" type and the Value showed up. So I changed my real option to a select type as well, and yep, it showed up. I just can't use it as a work-around because I need the checkbox type.

 

Also, can you do options that are also products? Example, if you had printers and ink cartridges for sale, you would have the ink products as options on the Product Info page for the printer, but the ink would also have its own Product Info page to be purchased separately?

Share this post


Link to post
Share on other sites

Nope, no other contributions.

 

I added another option with the "Select" type and the Value showed up. So I changed my real option to a select type as well, and yep, it showed up. I just can't use it as a work-around because I need the checkbox type.

 

Also, can you do options that are also products? Example, if you had printers and ink cartridges for sale, you would have the ink products as options on the Product Info page for the printer, but the ink would also have its own Product Info page to be purchased separately?

Ok, could you try that again with a non-standard option, like radio? (the contribution always falls back to (default) select options when something goes wrong)

 

I was working on (and am going to use myself) a contribution (Linked Products) with a "Products as Options" option, but that's currently not working and "On Pause", but I will eventually pick that contribution up when I have the time.

(As I said, I'll be needing it myself)

Edited by Zappo

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

Share this post


Link to post
Share on other sites

Radio worked! (And at the moment, that would suffice, though I'm still curious why checkbox doesn't show it).

 

I'll look forward to Products as Options. You've done an amazing job with this contribution!

Share this post


Link to post
Share on other sites

Radio worked! (And at the moment, that would suffice, though I'm still curious why checkbox doesn't show it).

 

I'll look forward to Products as Options. You've done an amazing job with this contribution!

Hold on!

I just now remember how the checkboxes are setup! :blush:

They don't show the name, as it's a yes/no question, and only accepts 1 option value.

So with the option name: "Wrapping paper", and option value "Yes Please", if customer checks the box, the cart says: "Wrapping paper: 'Yes Please'"

If the customer doesn't check the box, nothing is shown (or added) with the product.

 

Just to add to this, for multiple Checkboxes, you'll have to add multiple Attributes!

It's not possible to add different values of the same attribute to a single product.

(Notice all the other Option Types are "either this OR that", never "this AND that")

 

And thinking of it, I'll look into this...

To use the default installed stuff: maybe changing "Memory" to option type Checkbox, should trigger being able to select 4mb, 8mb and 16mb at the same time...

That's not really wanted in that example, but for pizza toppings, it could be great!

I'll only implement this if it IS possible (osC "standard") to add multiple attributes of the same option...

 

To be continued...

Edited by Zappo

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

Share this post


Link to post
Share on other sites

To be continued...

Well, I looked at it, and it seems that's gonna take quite a bit of coding to accomplish...

The fields use the Option's ID to identify themselves, so when we check more than 1 box, only one is added to cart. (all the checkboxes have the same name)

So, this would involve changing the names of the Checkbox Fields to include the OptionValueID, and add special handling for the checkboxes in application_top.php

Then, we'll have to hope osCommerce (the shoppingcart, checkout, etc) doesn't really care about products having multiple attributes of the same option...

 

I don't have time to investigate this further now, but it does seem like a nice functionality to add... (Anyone?)


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

Share this post


Link to post
Share on other sites

what i am thinking is something simple,at the present i have the code in a way that when there is upload option for a product instead of "Add to Cart" button the user is presented with "Add to Cart & Upload Image" button. they both do the same job. its only more user friendly for them to know that to upload the image they need to click this buttonwhat i am thinking is this. as soon as the user clicks the Add to Cart (Add to Cart & Upload Image) button they will be presented with new page (or stay on the same page) showing a progress bar or something like this just to show to the user they have to wait. this code can include also cancel upload option.in particular this is important when the image is larger one and takes some time to uploadas soon as the upload has been completed the user is moved to shoping_cart.phpi was looking for ajax progress bar but to be honest i am not good at coding and struggle to integrate it anyway i will keep on tryingcheersvaleri

 

I am also needing something similar to this. I find it confusing on my site when a user is uploading an image the page just sits there while the image or file is loading. For the novice web surfer the first instinct is to continually hit the submit button over and over again until they notice something happen. Anyone have a solution yet?

Share this post


Link to post
Share on other sites

I am also needing something similar to this. I find it confusing on my site when a user is uploading an image the page just sits there while the image or file is loading. For the novice web surfer the first instinct is to continually hit the submit button over and over again until they notice something happen. Anyone have a solution yet?

You'll need AJAX uploading for that, and I'm really not good with javascript...

Edited by Zappo

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

Share this post


Link to post
Share on other sites

I'm not great with coding in general :) I'll have to do some research and hopefully i'll come up with a solution. I'll be sure to post my results.

Share this post


Link to post
Share on other sites

Is there a way to limit what characters somebody can put into a Text field?

 

I sell Embossed Dog tags and the embossing wheel only has certain characters on it and limiting what the customer can put into the field would be awesome.

Share this post


Link to post
Share on other sites

Is there a way to limit what characters somebody can put into a Text field?

 

I sell Embossed Dog tags and the embossing wheel only has certain characters on it and limiting what the customer can put into the field would be awesome.

Yep.

In "Product Attributes -> Product Options" notice the "Value Length" field...


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

Share this post


Link to post
Share on other sites

<script type="text/javascript">
var ray={
ajax:function(st)
{
	this.show('load');
},
show:function(el)
{
	this.getID(el).style.display='';
},
getID:function(el)
{
	return document.getElementById(el);
}
}
</script>
<style type="text/css">
#load{
position:absolute;
z-index:1;
border:3px double #999;
background:#f7f7f7;
width:300px;
height:300px;
margin-top:-150px;
margin-left:-150px;
top:50%;
left:50%;
text-align:center;
line-height:300px;
font-family:"Trebuchet MS", verdana, arial,tahoma;
font-size:18pt;
}
</style>
<div id="load" style="display:none;">Loading... Please wait</div>
<form action="http://www.yahoo.com" method="post" onsubmit="return ray.ajax()">
<input type="text" value="Test" name="q">
<input type="submit" value="Search">
</form>

 

I was thinking about using something similar to this in order to create the loading window. Is this to simple? Can anyone give me some direction on how to incorporate it into the existing code as far as which pages to edit etc. I tried adding it myself with no luck...

Share this post


Link to post
Share on other sites

<!--//BOF - Zappo - Option Types v2 - Added for File upload: 'enctype="multipart/form-data"' //-->
   <td width="100%" valign="top"><?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 ray.ajax()"', 'enctype="multipart/form-data"'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
<?php
//EOF - Zappo - Option Types v2 - Added for File upload: 'enctype="multipart/form-data"'

 

I think i'm getting close. I have the simple ajax script working when the button is clicked. I added the onSubmit to the form in the product_info.php page (around line 73 on mine). Only problem is, when I have the onSubmit action in there, I still continue onto the shopping cart, but without the image uploading. Remove it and the image uploads fine. Any reason why this would be stopping the image from uploading? Any way around it?

Share this post


Link to post
Share on other sites

Yep.

In "Product Attributes -> Product Options" notice the "Value Length" field...

Hi Zappo thanks for the reply.

 

That limits the length which I have already set (to 15). I wish to only allow my customers to enter "A,B,C,D..." etc etc and NOT allow other characters for example "!,@,$,&..." etc etc as the wheel on the embossing machine does not have these characters on it. In other words a character validation check.

Share this post


Link to post
Share on other sites

Hi Zappo thanks for the reply.

 

That limits the length which I have already set (to 15). I wish to only allow my customers to enter "A,B,C,D..." etc etc and NOT allow other characters for example "!,@,$,&..." etc etc as the wheel on the embossing machine does not have these characters on it. In other words a character validation check.

OOooh... Now I see...

That can only be accomplished by javascript... (and shouldn't be too hard (not as hard as an upload script))

But as I'm not good with Javascript, can't really help you out here...

I could devise something with PHP, but that would change the text AFTER adding it to cart.


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

Share this post


Link to post
Share on other sites

<!--//BOF - Zappo - Option Types v2 - Added for File upload: 'enctype="multipart/form-data"' //-->
   <td width="100%" valign="top"><?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 ray.ajax()"', 'enctype="multipart/form-data"'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
<?php
//EOF - Zappo - Option Types v2 - Added for File upload: 'enctype="multipart/form-data"'

 

I added the onSubmit to the form in the product_info.php page (around line 73 on mine).

You added the onsubmit wrongly:

Add it like this (onsubmit and enctype together):

...roduct'), 'post', 'onSubmit="return ray.ajax()" enctype="multipart/form-data"'

 

Let us know how it works out! (And post an update if it works)

Edited by Zappo

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

Share this post


Link to post
Share on other sites

Hi Zappo thanks for the reply.

 

That limits the length which I have already set (to 15). I wish to only allow my customers to enter "A,B,C,D..." etc etc and NOT allow other characters for example "!,@,$,&..." etc etc as the wheel on the embossing machine does not have these characters on it. In other words a character validation check.

Couldn't leave this hanging somehow...

To help you on your way, I found a script (and tweaked it a little) to block entering anything but 0-9 and a-z

HOWEVER, it seems this isn't as simple as I thought: it seems validating what key was pressed by the customer, depends on his/her keyboard settings! We can only check what physical button was pressed, not what (special-)character.

I would imagine you'd want to let the user enter "." as well, which already gave me too much hassle to investigate further... ("." is key Code 190 on my keyboard)

Anyway, checkout the code I found: In product_info.php, BEFORE:

// EOF - Zappo - Option Types v2 - Added for Form Field Progress Bar 
//--></script>
</head>

ADD: (as you can see, I added some comments to help tweak the code)

function checkchars(e) {
 var key;
 var keychar;
 if (window.event) {
   key = window.event.keyCode;
 } else if (e) {
   key = e.which;
 } else {
   return true;
 }
 keychar = String.fromCharCode(key);
 //alert(key); // - Zappo - Un-comment to check what key Code is passed. Passed key can be added below to ALLOW
 if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) || (key==27) ) {
   return true;
 // - Zappo - You can modify ALLOWED characters here...
 } else if ((("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ").indexOf(keychar) > -1)) {
   return true;
 } else
   return false;
}

Then, in option_types.php, find the onKeyDown, onKeyUp and onFocus events of the OPTIONS_TYPE_TEXT option (around line 32), and add the following code to EACH EVENT:

return checkchars(event);

So the events look like this:

onKeyDown="return checkchars(event); textCounter(this,\'progressbar......

 

I added debugging code in the javascript to help you tweak the script a little to accept the correct characters (doesn't accept spacebar for example, (key=32)), so this should get you on your way...


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

Share this post


Link to post
Share on other sites

Wow its always something easy isn't it. It works! Thanks for all your help Zappo! Its not a perfect solution, but now when the form is submitted, a popup window will appear until the shopping_cart.php page loads. This is extremely useful with images, because with the wait time, it allows the user an understanding of what is going on. Thanks again guys!

Share this post


Link to post
Share on other sites

Wow its always something easy isn't it.

Its not a perfect solution, but now when the form is submitted, a popup window will appear until the shopping_cart.php page loads.

Well.... Not always :lol:

Is it worth a Package-Update?

Maybe send it to me so I can get it integrated, or maybe you can add an update package to the contribution yourself?

Edited by Zappo

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

Share this post


Link to post
Share on other sites

Is there a way to limit what characters somebody can put into a Text field?

 

Fourpaws - Can you use javascript that just looks at the value after it's entered, instead of trying to catch the keystroke as it happens?

 

I did something like this for one of my forms. I added an "onblur" function to the input field, so that when the user leaves the focus from it, it runs a function that looks for a specific string (like a no-no character).

 

The function below is super simple. It just looks to see if the % is somewhere in the string, and if it is, provides an alert. Hopefully it gives you an idea of what to do?

 

function charCheck(fieldValue)

{

 

if(fieldValue.search("%")>=0)

{

alert("These symbols are not available: %$@!*");

}

 

}

Share this post


Link to post
Share on other sites

Has anyone got this contribution working with downloadable products/super download shop? I installed it and it seems to somehow break the functionality needed to work with downloads, ie after installation at the point of checkout customers are taken through the shipping page which should be skipped for downloadables, which is annoying but much worse is the fact that the order details are not posted at all in the orders_products_downloads table, so there is no way for a customer to get their downloads even after they are marked as available. I think I installed it correctly - I had to manually update many files which I already modded with other contributions and no php errors are occuring anywhere in the product display/adding to basket/purchase procedures - but somewhere the special processing which was working before for downloads has broken.

 

So can anyone confirm it works for them with SDS so I can at least have a clue whether I need to try and figure out where and why the coding of this contribution is incompatible with SDS, or whether it's simply a flawed installation on my part and I need to go through again and try and see which part of which file I didn't update correctly.


www.jyoshna.com. Currently using OsC with STS, Super Download Store, Categories Descriptons, Manufacturers Description, Individual Item Status, Infopages unlimited, Product Sort, Osplayer with flashmp3player, Product Tabs 2.1 with WebFx Tabpane and other bits and pieces including some I made myself. Many thanks to all whose contributions I have used!

Share this post


Link to post
Share on other sites

Has anyone got this contribution working with downloadable products/super download shop? I installed it and it seems to somehow break the functionality needed to work with downloads, ie after installation at the point of checkout customers are taken through the shipping page which should be skipped for downloadables, which is annoying but much worse is the fact that the order details are not posted at all in the orders_products_downloads table, so there is no way for a customer to get their downloads even after they are marked as available. I think I installed it correctly - I had to manually update many files which I already modded with other contributions and no php errors are occuring anywhere in the product display/adding to basket/purchase procedures - but somewhere the special processing which was working before for downloads has broken.

 

So can anyone confirm it works for them with SDS so I can at least have a clue whether I need to try and figure out where and why the coding of this contribution is incompatible with SDS, or whether it's simply a flawed installation on my part and I need to go through again and try and see which part of which file I didn't update correctly.

To be honest, this contribution was never tested with downloadable products.

I had no idea things would be any different with those, so there is a probability of incompatibility...


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

Share this post


Link to post
Share on other sites

Well.... Not always :lol:

Is it worth a Package-Update?

Maybe send it to me so I can get it integrated, or maybe you can add an update package to the contribution yourself?

 

this is a nice and simple solution. thank you

i think it is worth adding it to the contribution

 

add on product_info.php the following java script:

 

-------------------

<script type="text/javascript">

var ray={

ajax:function(st)

{

this.show('load');

},

show:function(el)

{

this.getID(el).style.display='';

},

getID:function(el)

{

return document.getElementById(el);

}

}

</script>

<style type="text/css">

#load{

position:absolute;

z-index:1;

border:1px double #999;

background:#f7f7f7;

width:300px;

height:200px;

margin-top:-150px;

margin-left:-150px;

top:50%;

left:50%;

text-align:center;

line-height:200px;

font-family:"Trebuchet MS", verdana, arial,tahoma;

font-size:18pt;

}

</style>

<div id="load" style="display:none;">Loading image... Please wait</div>

 

--------------------

then change the line adding the onsubmit action:

 

<!--//BOF - Zappo - Option Types v2 - Added for File upload: 'enctype="multipart/form-data"' //-->

<td width="100%" valign="top"><?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 ray.ajax()" enctype="multipart/form-data"'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">

 

-------------------

Share this post


Link to post
Share on other sites

this is a nice and simple solution.

Indeed!

Very simple, and easy to add...


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

Share this post


Link to post
Share on other sites

To be honest, this contribution was never tested with downloadable products.

I had no idea things would be any different with those, so there is a probability of incompatibility...

 

It hadn't occured to me that they would be incompatible, but it seems so. My first suspicions fall upon the way osc decides whether the cart contains virtual products, and how your mod affects that determination. The two problems - going to the shipping page when it shouldn't, and not processing the order_products_downloads table when it should, both have to arise because osc doesn't know the products are virtual. But what it is that's preventing it from knowing it when your mod is installed, I don't know!


www.jyoshna.com. Currently using OsC with STS, Super Download Store, Categories Descriptons, Manufacturers Description, Individual Item Status, Infopages unlimited, Product Sort, Osplayer with flashmp3player, Product Tabs 2.1 with WebFx Tabpane and other bits and pieces including some I made myself. Many thanks to all whose contributions I have used!

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

×