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)
-   -   Auto update Qty in View Cart (https://forum.x-cart.com/showthread.php?t=1671)

shan 02-28-2003 05:25 AM

Auto update Qty in View Cart
 
On the view cart page and on the checkout step one page I would like to change the quantity box to a drop down menu then automaticaly refreshes the page with the new settings when its changed.

Has anyone already done this ?

V3.3.3

B00MER 03-02-2003 05:33 AM

[skin1]/customer/main/cart.tpl:

Find this line:

Code:

<input type=text size=3 name="productindexes[{$smarty.section.product.index}]" value="{$products[product].amount}">

Delete it out, add some spacing inbetween the other code that is wrapped around it, so you that you can paste the following in:

Code:

{if $config.General.show_in_stock ne "Y"}
{assign var="mq" value=$config.General.max_select_quantity}
{else}
{math equation="min(maxquantity+minamount, productquantity)+1" assign="mq" maxquantity=$config.General.max_select_quantity minamount=$product.min_amount productquantity=$product.avail}
{/if}
{if $product.min_amount le 1}
{assign var="start_quantity" value=1}
{else}
{assign var="start_quantity" value=$product.min_amount}
{/if}
<select name="productindexes[{$smarty.section.product.index}]" onchange="document.cartform.submit()">
{section name=quantity loop=$mq start=$start_quantity}
<option value="{%quantity.index%}" {if $products[product].amount eq %quantity.index%}selected{/if}>{%quantity.index%}</option>
{/section}
</select>


I've also adjusted step 1 of the checkout as well:

[skin1]/customer/main/cart_contents.tpl

Locate the following line:

Code:

<input type=text size=3 name="productindexes[{$smarty.section.product.index}]" value="{$products[prod_num].amount}">

Highlight this entire line of code and replace it with:

Code:

{if $config.General.show_in_stock ne "Y"}
{assign var="mq" value=$config.General.max_select_quantity}
{else}
{math equation="min(maxquantity+minamount, productquantity)+1" assign="mq" maxquantity=$config.General.max_select_quantity minamount=$product.min_amount productquantity=$product.avail}
{/if}
{if $product.min_amount le 1}
{assign var="start_quantity" value=1}
{else}
{assign var="start_quantity" value=$product.min_amount}
{/if}
<select name="productindexes[{$smarty.section.product.index}]" onchange="document.cartform.submit()">
{section name=quantity loop=$mq start=$start_quantity}
<option value="{%quantity.index%}" {if $products[prod_num].amount eq %quantity.index%}selected{/if}>{%quantity.index%}</option>
{/section}
</select>


I'm not too sure if this will work properly with the quantity or inventory check on the product so if you are using a check on inventory & if you do experience the select field selecting the max, disregarding the amount of products available, let me know.

Donations happily accepted :D

Kudos ;)

shan 03-02-2003 12:59 PM

Cheers mate,

ill take a look at this tomorow :wink:

kpriest 04-30-2003 08:04 AM

Has anyone had a problem with even the default template updating the quantity? When I change the quantity while I am viewing the cart and click update - it refreshes, but the quantity reverts to its original value. This is in 3.3.5. Any ideas?


All times are GMT -8. The time now is 01:44 AM.

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