By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,829 Members | 1,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,829 IT Pros & Developers. It's quick & easy.

Help With Javascript

P: 5
Hi,

First let me say I do not know java much at all. Anyway, on my new website I have products that I want to have tiered pricing for. (i.e. 1-5 price $17.85, 6-11 price is $14.85, 12-23 price is $13.85, 24+ price is $11.85.) I want to offer tiered pricing but not sure how to do this. Any help or pointing me in the right direction would greatly be appreciated.

Thanks,
Berri
Feb 24 '07 #1
Share this Question
Share on Google+
11 Replies

10K+
P: 13,262
Hi,

First let me say I do not know java much at all. Anyway, on my new website I have products that I want to have tiered pricing for. (i.e. 1-5 price $17.85, 6-11 price is $14.85, 12-23 price is $13.85, 24+ price is $11.85.) I want to offer tiered pricing but not sure how to do this. Any help or pointing me in the right direction would greatly be appreciated.

Thanks,
Berri
Are you sure you want to use Java or did you mean Javascript? You will have to suppy more info and show the codes you have and where you want to put these prices.
Feb 24 '07 #2

P: 5
Are you sure you want to use Java or did you mean Javascript? You will have to suppy more info and show the codes you have and where you want to put these prices.
Yes, sorry, I want a javascript to allow for multi level prices. If a customer orders 4 sets it is one price if its > 6 another price etc.

Ok, I do not know javascript but I can learn it, I think.

As an example I will have lots of products with different price variations but here is one, http://www.yourgiftspersonalized.com/Sailboat-Tealight-Holders-Set-of-4-p-76.html

Now here is what I think I need to add:

<script language=”javascript”>
Var data = {
<product productid=”76”>
<quantity> <6 </quantity>
<price>17.85</price>
<quantity> <12 </quantity>
<price> 14.85</price>
<quanity> <24 </quantity>
<price> 13.85</price>
<quantity> =>24</quantity>
<price>11.85</price>
</product>
};
</script>

My coding is probably incorrect but hopefully someone will understand.
The pricing for this particular product is: 1-5 = 17.85; 6-11= 14.85; 12-23= 13.85; 24+ = 11.85. I don't know how to do the if quantity is greater than or equal to so any help with this would be appreciated. I just did if greater than.

With xcart there is a place for me to add price modifiers and input javascript for each product I enter but since I don't know javascript I was hoping for help understanding if I am way off or on the right track or just plain help.

Another question with the code I have, do I need to find the productid # for each product or is there a better way to do that?

Thanks for your help!
Berri
Feb 24 '07 #3

100+
P: 157
Yes, sorry, I want a javascript to allow for multi level prices. If a customer orders 4 sets it is one price if its > 6 another price etc.

Ok, I do not know javascript but I can learn it, I think.

As an example I will have lots of products with different price variations but here is one, http://www.yourgiftspersonalized.com...of-4-p-76.html

Now here is what I think I need to add:

<script language=”javascript”>
Var data = {
<product productid=”76”>
<quantity> <6 </quantity>
<price>17.85</price>
<quantity> <12 </quantity>
<price> 14.85</price>
<quanity> <24 </quantity>
<price> 13.85</price>
<quantity> =>24</quantity>
<price>11.85</price>
</product>
};
</script>

My coding is probably incorrect but hopefully someone will understand.
The pricing for this particular product is: 1-5 = 17.85; 6-11= 14.85; 12-23= 13.85; 24+ = 11.85. I don't know how to do the if quantity is greater than or equal to so any help with this would be appreciated. I just did if greater than.

With xcart there is a place for me to add price modifiers and input javascript for each product I enter but since I don't know javascript I was hoping for help understanding if I am way off or on the right track or just plain help.

Another question with the code I have, do I need to find the productid # for each product or is there a better way to do that?

Thanks for your help!
Berri
Hello Berri,
Java and JavaScript are not the same.This is the Java forum pal, you need to post in the JavaScript forum.They'll be able to help you out with the appropriate suggestions.

By the way here's a good link to start learning JavaScript if you are looking to code in it.
Feb 24 '07 #4

P: 5
Hi,

First let me say I do not know java much at all. Anyway, on my new website I have products that I want to have tiered pricing for. (i.e. 1-5 price $17.85, 6-11 price is $14.85, 12-23 price is $13.85, 24+ price is $11.85.) I want to offer tiered pricing but not sure how to do this. Any help or pointing me in the right direction would greatly be appreciated.

I want a javascript to allow for multi level prices. If a customer orders 4 sets it is one price if its > 6 another price etc.

Ok, I do not know javascript but I can learn it, I think.

As an example I will have lots of products with different price variations but here is one, http://www.yourgiftspersonalized.com/Sailboat-Tealight-Holders-Set-of-4-p-76.html

Now here is what I think I need to add:

<script language=”javascript”>
Var data = {
<product productid=”76”>
<quantity> <6 </quantity>
<price>17.85</price>
<quantity> =6<12 </quantity>
<price> 14.85</price>
<quanity> =12<24 </quantity>
<price> 13.85</price>
<quantity> =>24</quantity>
<price>11.85</price>
</product>
};
</script>

My coding is probably incorrect but hopefully someone will understand.
The pricing for this particular product is: 1-5 = 17.85; 6-11= 14.85; 12-23= 13.85; 24+ = 11.85. I don't know how to do the if quantity is greater than or equal to so any help with this would be appreciated. I just did if greater than.

With xcart there is a place for me to add price modifiers and input javascript for each product I enter but since I don't know javascript I was hoping for help understanding if I am way off or on the right track or just plain help.

Another question with the code I have, do I need to find the productid # for each product or is there a better way to do that?

Thanks,
Berri
Feb 24 '07 #5

P: 19
I'm not sure but it looks like X-Cart provides that feature without needing Javascript.

Search for "price modifier" in the X-Cart Manual.

Btw...

On your page, in every place where you have this:

onclick="javascript: js_code...

you need to remove "javascript:".

:)
Feb 25 '07 #6

P: 5
I'm not sure but it looks like X-Cart provides that feature without needing Javascript.

Search for "price modifier" in the X-Cart Manual.

Btw...

On your page, in every place where you have this:

onclick="javascript: js_code...

you need to remove "javascript:".

:)
Hi Mike,

Yes, X-Cart does have the price modifier, the problem with that is I have to list each number 1-100 and for 1-5 leave blank since the default price is already in place with the product. So when I set up the product modifier it would say tiered price 1, 2, 3, 4, 5, 6, etc and than the qty box is there and it is really confusing. I was trying to add a javascript code to so when a customer put in "14" in the qty. box it would calculate the cost at the 13.85 price. 13.85 x 14. The way X-Cart has it with the price modifier is really confusing.

I was hoping to put in a java code that would do that but I don't know the correct java code.

Berri
Feb 25 '07 #7

P: 19
I don't know anything about X-Cart - I only just peeked at the manual.

Here is some basic Javascript - this is only for you to have an idea of what the script might look like. It is not intended to be a final solution.

First, add the following onchange handler to the select:

Expand|Select|Wrap|Line Numbers
  1. <select id="product_avail" name="amount" onchange='adjustPrice(this)'>
  2.  
Now put this in one of the script elements (preferably in the head):
Expand|Select|Wrap|Line Numbers
  1. function adjustPrice(sel)
  2. {
  3.   var p = '', q = parseInt(sel.options[sel.selectedIndex].value);
  4.   if (!q) {
  5.     alert('Error!');
  6.     return;
  7.   }
  8.   else if (q >= 24) {
  9.     p = '11.85';
  10.   }
  11.   else if (q >= 12) {
  12.     p = '13.85';
  13.   }
  14.   else if (q >= 6) {
  15.     p = '14.85';
  16.   }
  17.   else {
  18.     p = '17.85';
  19.   }
  20.   document.getElementById('product_price').innerHTML = '$' + p;
  21. }
  22.  
This updates the price on the page (but not actually in the right place) - but it does not put it in the form to be submitted.

Where does the original price come from? Is it in a database on the server? If so then can you change the server-side code to output Js into the html file? I'm assuming you don't want to hard-code these prices in each page.

I could go on but...

as you can see, the Javascript is the easiest part of this task - the real changes should be made in the server-side script. Using Javascript to select a price should only be used for convenience. Your server-side code must still validate the users choices.
Feb 25 '07 #8

P: 5
I don't know anything about X-Cart - I only just peeked at the manual.

Here is some basic Javascript - this is only for you to have an idea of what the script might look like. It is not intended to be a final solution.

First, add the following onchange handler to the select:

Expand|Select|Wrap|Line Numbers
  1. <select id="product_avail" name="amount" onchange='adjustPrice(this)'>
  2.  
Now put this in one of the script elements (preferably in the head):
Expand|Select|Wrap|Line Numbers
  1. function adjustPrice(sel)
  2. {
  3.   var p = '', q = parseInt(sel.options[sel.selectedIndex].value);
  4.   if (!q) {
  5.     alert('Error!');
  6.     return;
  7.   }
  8.   else if (q >= 24) {
  9.     p = '11.85';
  10.   }
  11.   else if (q >= 12) {
  12.     p = '13.85';
  13.   }
  14.   else if (q >= 6) {
  15.     p = '14.85';
  16.   }
  17.   else {
  18.     p = '17.85';
  19.   }
  20.   document.getElementById('product_price').innerHTML = '$' + p;
  21. }
  22.  
This updates the price on the page (but not actually in the right place) - but it does not put it in the form to be submitted.

Where does the original price come from? Is it in a database on the server? If so then can you change the server-side code to output Js into the html file? I'm assuming you don't want to hard-code these prices in each page.

I could go on but...

as you can see, the Javascript is the easiest part of this task - the real changes should be made in the server-side script. Using Javascript to select a price should only be used for convenience. Your server-side code must still validate the users choices.
Mike,

Thanks!

This site uses X-Cart which I am not familiar with and am trying to learn, I know for each product I can add a customer side but will have to look at the server-side. Yeah, I do not want to hard code this on all pages, some products will have tiered prices that will all have different price points so I am trying to find the best way to do this and make it easy for the customers at the same time.

Where in AL?

Berri
Feb 25 '07 #9

P: 19
North Etowah county :)
Feb 25 '07 #10

10K+
P: 13,262
Yes, sorry, I want a javascript to allow for multi level prices. If a customer orders 4 sets it is one price if its > 6 another price etc.

Ok, I do not know javascript but I can learn it, I think.

As an example I will have lots of products with different price variations but here is one, http://www.yourgiftspersonalized.com/Sailboat-Tealight-Holders-Set-of-4-p-76.html

Now here is what I think I need to add:

<script language=”javascript”>
Var data = {
<product productid=”76”>
<quantity> <6 </quantity>
<price>17.85</price>
<quantity> <12 </quantity>
<price> 14.85</price>
<quanity> <24 </quantity>
<price> 13.85</price>
<quantity> =>24</quantity>
<price>11.85</price>
</product>
};
</script>

My coding is probably incorrect but hopefully someone will understand.
The pricing for this particular product is: 1-5 = 17.85; 6-11= 14.85; 12-23= 13.85; 24+ = 11.85. I don't know how to do the if quantity is greater than or equal to so any help with this would be appreciated. I just did if greater than.

With xcart there is a place for me to add price modifiers and input javascript for each product I enter but since I don't know javascript I was hoping for help understanding if I am way off or on the right track or just plain help.

Another question with the code I have, do I need to find the productid # for each product or is there a better way to do that?

Thanks for your help!
Berri
Moved to Javascript forum.
Feb 26 '07 #11

acoder
Expert Mod 15k+
P: 16,027
Threads merged.
Feb 27 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.