X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Change product quantity from drop down to number input field (https://forum.x-cart.com/showthread.php?t=2428)

wayfarer 04-24-2003 12:52 AM

Change product quantity from drop down to number input field
 
Which template do I need to change and (with what code) do I need to change to replace the product quantity drop down menu in a normal product table, to a normal quantity input field?

funkydunk 04-24-2003 04:03 AM

This is in products.tpl

Jon 04-24-2003 11:33 AM

What provisions need to be made to ensure that the field is numeric and not going to cause complications?

funkydunk 04-24-2003 01:39 PM

That is already inbuilt into cart.php and will not cause a problem.

8)

wayfarer 04-24-2003 03:50 PM

Excuse the newbie question, but which code should I replace, with what?

Jon 04-24-2003 03:55 PM

Code:

<select name=amount>
{if $products[product].min_amount le 1}
{assign var="start_quantity" value=1}
{else}
{assign var="start_quantity" value=$products[product].min_amount}
{/if}
{section name=quantity loop=$mq start=$start_quantity}
<option value="{%quantity.index%}" {if $smarty.get.quantity eq %quantity.index%}selected{/if}>{%quantity.index%}</option>
{/section}
</select>


Replace with this code and that should do it:

Code:

<input type="text" name="amount" size="3">

wayfarer 04-24-2003 05:35 PM

:D Sweeeeeet! Thanks!

gfiebich 05-28-2003 06:06 AM

made the modification - now Access Denied problem
 
I've changed my quantity field as described above - but now have this problem:

Product has a minimum quantity - must purchase 100. If user enters a number less than 100, resulting page reads "Access Denied! You are not allowed to access that resource!". Any ideas? I'm assuming the cart is trying to redirect me to a page alerting me that I didn't enter a valid quantity, but for some reason isn't getting there.

thanks in advance!
Glen

Jon 05-28-2003 10:28 AM

If I was using minimum and/or maximum quantity I'd stick with the drop down box personally.

adpboss 10-10-2003 07:16 PM

How would I set the default value of this text box to "1"?

So the box would read "1" but the user could change that number via highlight or delete and add their own number.

Make sense?

chatfield 10-11-2003 11:45 AM

I use almost the same line as above.

<input type="text" name=amount size="6" value="{$product.min_amount}">

This gives a little bigger field to type in and it sets the default to whatever the minimum order amount that you set for that item.

Good luck.

chatfield 10-11-2003 11:57 AM

I use almost the same line as above.

<input type="text" name=amount size="6" value="{$product.min_amount}">

This gives a little bigger field to type in and it sets the default to whatever the minimum order amount that you set for that item.

Good luck.

adpboss 10-11-2003 12:19 PM

Excellent thinking!

Thanks!

BCSE 07-15-2004 09:37 AM

I implemented this before even finding this post. I did some Javascript validation to make sure they input greater than minimum amount.

Here's what I did. In 3.4.x, I changed the FormValidation at the top of skin1/customer/product.tpl to:
Code:

function FormValidation()

{/literal}
{if $javascript_code}
{$javascript_code}
return false;
{else}
if(parseInt(document.orderform.amount.value) >= parseInt(document.orderform.minamount.value))

        return true;

else
{literal}
{
{/literal}
        alert("{"The quantity you entered was invalid.  Please enter the appropriate quantity to add this product to your cart."|replace:"\n":" "|replace:"\r":" "}");
        return false;
{literal}
}
{/literal}
{/if}
{literal}
}


and I added this before the other hidden inputs:

Code:

{* BCSE Begin *}
<input type=hidden name=minamount value="{$product.min_amount}">
{* BCSE End *}



FIXED! This should work now if you want to use a text box instead of a quantity drop down box.

Carrie

QVS 12-20-2004 03:09 AM

anyone know how to do this for version 4.08?

tried following the above information, but it doesnt seem to match up with my version.

any help would be great.

CC 12-20-2004 04:38 AM

Ditto :(

CC 12-20-2004 10:18 AM

Teaches me to look without checking correctly...

I replaced this:
Code:

<SELECT id="product_avail" name="amount"{if $active_modules.Product_Options ne '' && $product_options ne ''} onchange="check_wholesale(this.value);"{/if}>
{section name=quantity loop=$mq start=$start_quantity}
<OPTION value="{%quantity.index%}" {if $smarty.get.quantity eq %quantity.index%}selected{/if}>{%quantity.index%}</OPTION>
{/section}
</SELECT>


With this:
Code:

<input type="text" name=amount size="4" value="{$product.min_amount}">

Seems to work well...

AztecOne 02-12-2005 12:23 PM

Thank You!! Thank You!! Worked well for me in 4.0.9

:D whew!!

zilker 02-13-2005 08:13 AM

QVS, below is the javascript form validation for version 4.0.6. I'm going to go out on a limb and say that it should work for any version 4 cart. Highlight the entire code and paste it over the existing code in /form_validation_js.tpl.

It worked for me ~ BUT ~ back up your original before you try the change ~ just to be safe.

Code:

{* $Id: form_validation_js.tpl,v 1.2.2.3 2004/08/11 12:04:13 max Exp $ *}
<SCRIPT type="text/javascript" language="JavaScript 1.2">
function FormValidation() {ldelim}

    {if $active_modules.Product_Options ne '' && $product_options ne ''}
    if(!check_exceptions()) {ldelim}
        alert(exception_msg);
        return false;
    {rdelim}
        {if $product_options_js ne ''}
        {$product_options_js}
        {/if}
    {/if}

        if(document.getElementById('product_avail'))
            if(document.getElementById('product_avail').value == 0) {ldelim}
                alert("{$lng.txt_out_of_stock|replace:"\n":"
"|replace:"\r":" "|replace:'"':'\"'}");
                return false;
            {rdelim}
if(parseInt(document.orderform.amount.value) >= parseInt(document.orderform.minamount.value))

  return true;

else
{ldelim}
  alert("{"The quantity you entered was invalid.  Please enter the appropriate quantity to add this product to your cart."|replace:"\n":" "|replace:"\r":" "}");
  return false;
{rdelim}

    return true;
{rdelim}
</SCRIPT>


Let me know how it works.

mocara 04-07-2005 06:01 AM

Quote:

Originally Posted by CC
Teaches me to look without checking correctly...

I replaced this:
Code:

<SELECT id="product_avail" name="amount"{if $active_modules.Product_Options ne '' && $product_options ne ''} onchange="check_wholesale(this.value);"{/if}>
{section name=quantity loop=$mq start=$start_quantity}
<OPTION value="{%quantity.index%}" {if $smarty.get.quantity eq %quantity.index%}selected{/if}>{%quantity.index%}</OPTION>
{/section}
</SELECT>


With this:
Code:

<input type="text" name=amount size="4" value="{$product.min_amount}">

Seems to work well...


Which file are you editing here? Will these changes work if you are using the product_options module?

zilker 04-07-2005 07:55 AM

that is in products.tpl and yes, you can still use your product options with that mod.

jb5ep 04-14-2005 12:12 PM

Has anyone tried this with 4.0.13? Looking at the 2 changes:

1. products.tpl

I changed this:

Code:

<SELECT id="product_avail" name="amount"{if $active_modules.Product_Options ne '' && $product_options ne ''} onchange="check_wholesale(this.value);"{/if}>
{section name=quantity loop=$mq start=$start_quantity}
<OPTION value="{%quantity.index%}" {if $smarty.get.quantity eq %quantity.index%}selected{/if}>{%quantity.index%}</OPTION>
{/section}
</SELECT>


to this:

Code:

<input name=amount type="text" value="{$product.min_amount}" size="6" maxlength="4">

That appears to work no probs. BUT...

2. form_validation.tpl

I replaced the entire contents of this file with the suggestion in zilker's post of Sun Feb 13, 2005

The problem...

Whenever I now submit the form to 'add to cart', I get the Jscript error "document.orderform.minamount.value' is null or not an object.

Has anyone else had any luck making this mod on 4.0.13?

Cheers,
JB

Tequilaboy 06-14-2005 03:52 PM

I'm looking at skin1/main/products.tpl and I can't seem to find the code to replace. Used the 'find' function with parts of the code and even scanned through the file (since file is fairly short, 3k). Still not finding it. Is this even the right products.tpl file?
Looked at products.php in the root too but code's not in there either.

Somebody please help!

jb5ep 06-15-2005 12:30 AM

sorry - maybe a typo...try product.tpl

Tequilaboy 06-19-2005 09:18 PM

Ok well, looked at both product.tpl products.tpl in the skin1/main/ directory. Search function doesn't even find the words "select" or "amount" anywhere in either document (searching code not text).

I'm using 4.0.13, why the hell can't I find that string? Is the file in another directory?

jb5ep 06-20-2005 12:41 AM

OK, i'm looking at a vanilla, XC 4.0.13 install.

1. Goto skin1/customer/main/product.tpl

2. Look at lines 92-96, for the code in my post above (or, try searching code for '<SELECT id="product_avail" ' )

3. Replace that code with the code from my post above.

Should work no probs, - i've just replicated again to test i'm not going mad. If you still don't have any luck, PM me or post your tpl here..

Cheers,

jedak 06-23-2005 10:31 AM

I tried this code because I too prefer the input field as oppose to the drop down. The problem I'm having is some of my products have variants and if that product is out of stock customers are still able to order the out of stock variant, which should not be since I have that option disable in general settings. Anyone have this problem or better yet a fix.
Thanks

jb5ep 06-23-2005 11:11 AM

Nothing to do with this fix in 4.0.14, is it?

Quote:

Wed Jun 15 10:05:37 MSD 2005 [!] - max - Bug: There was not a checkup procedure at the stage of checkout that would ensure that the quantity of product variant items in cart was not larger than the quantity of this variant in stock. As a result, several customers who added to cart a quantity of variant items that did not exceed the quantity in stock could place their orders, while in fact there were not enough variant items for all of them. Fixed.

jedak 06-24-2005 06:19 AM

Quote:

Originally Posted by jb5ep
Nothing to do with this fix in 4.0.14, is it?

Quote:

Wed Jun 15 10:05:37 MSD 2005 [!] - max - Bug: There was not a checkup procedure at the stage of checkout that would ensure that the quantity of product variant items in cart was not larger than the quantity of this variant in stock. As a result, several customers who added to cart a quantity of variant items that did not exceed the quantity in stock could place their orders, while in fact there were not enough variant items for all of them. Fixed.

No. without the above mod variants work fine and show out of stock - if thats the case - but with this mod seems as though variants are ignored.

If someone could assist me in getting the input field to work on the detail page the way it works on the shopping cart page it would be greatly appreciated.

mocara 09-07-2005 03:31 PM

Any updates to this mod for 4.0.14? Obviously ensuring that we have in stock what we sell is vital :-)

Mocara.

Tuner 01-09-2006 07:51 PM

make sure to add this to the product.tpl
<Input type="hidden" name="minamount" value="{$product.min_amount}">

That will allow the javascript toknow the minimum ammount. I placed it with the text box but you can also place it with the other hidden inputs.

scott

Dawn Howard 06-08-2006 12:57 PM

Works like a charm when the customer is viewing the product details! Thanks!

How can I make this happen when a customer is viewing all the products in a category?

banzai 07-12-2006 10:04 AM

Quote:

Originally Posted by Dawn Howard
Works like a charm when the customer is viewing the product details! Thanks!

How can I make this happen when a customer is viewing all the products in a category?


I opened /skin1/customer/main/buy_now.tpl and replaced

Code:

<SELECT name="amount">
{if $product.min_amount le 1}
{assign var="start_quantity" value=1}
{else}
{assign var="start_quantity" value=$product.min_amount}
{/if}
{section name=quantity loop=$mq start=$start_quantity}
<OPTION value="{%quantity.index%}" {if $smarty.get.quantity eq %quantity.index%}selected{/if}>{%quantity.index%}</OPTION>
{/section}
</SELECT>


with

Code:

<input name=amount type="text" value="{$product.min_amount}" size="7" maxlength="5">

ecommerce 08-24-2006 04:03 AM

Re: Change product quantity from drop down to number input field
 
Im on version 4. 0. 18,

are you guys still doing this

<input name=amount type="text" value="{$product.min_amount}" size="7" maxlength="5">

In product.tpl?

OR .....
is there something in tha admin panel that i can set?
I tried setting the quantity select box to 0, but it just went back to 50.

:)

frankdux 09-20-2006 07:02 AM

Re: Change product quantity from drop down to number input field
 
Quote:

Originally Posted by Dawn Howard
Works like a charm when the customer is viewing the product details! Thanks!

How can I make this happen when a customer is viewing all the products in a category?


Dawn, did you ever come up with a solution for this?

After making all the changes previously described in this thread, I am running into the same problem. When the customer is viewing the product details page (/cart/product.php, modified using product.tpl ) the JavaScript alert works fine if they try to order below the minimum. However, when the customer is on the page that lists all the products in one category (cart/home.php?cat=255, modified using buy_now.tpl) they do not get the alert and they still get the message "You are not allowed to access that resource!".

The changes I made to product.tpl and buy_now.tpl are identical. The problem seems to be that the Javascript FormValidation is not availalbe on the category listing pages. Is there an appropriate way to make this available on all pages?

frankdux 09-20-2006 08:15 AM

Re: Change product quantity from drop down to number input field
 
An update to this issue...it was simple enough to include the necessary JavaScript on each page by adding: {include file="form_validation_js.tpl"} to /cart/home.php .

That still didn't solve the problem.

The reason the Javascript alert works on the individual detail pages is that there is only one form on these pages and its name is "orderform" and that is picked up by the "document.orderform.amount.value" in the FormValidation() function.

The reason its not working on the catagory pages that list multiple products, is that there is a different form for each product. Each one has a different name that is dynamically created and is something like "orderform_16152_1154021436". The Javascript FormValidation() function will only be triggered on forms named "orderform".

Anyway, if anyone has an idea how to handle this wrinkle, I would appreciate it as I am stuck at this point.

stuartn 12-14-2007 01:41 PM

Re: Change product quantity from drop down to number input field
 
I have a problem with qty's, no matter what qty you input the amount sent to cart is always 1

Any clues ?

X-Cart version 4.0.18

designtheweb 04-02-2008 02:35 PM

Re: Change product quantity from drop down to number input field
 
I am on version 4.1.9 - is there an update for changing the quanity from drop down to number input?

wendy.email 06-10-2008 01:15 PM

Re: Change product quantity from drop down to number input field
 
anyone? please

stuartn 06-10-2008 02:08 PM

Re: Change product quantity from drop down to number input field
 
in product template

<tr>
<td width="30%">{$lng.lbl_quantity}</td>
<td><input type="text" name="amount" size="2" maxlength="2" value="{$product.min_amount}"/></td>
</tr>


All times are GMT -8. The time now is 03:13 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.