X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown (https://forum.x-cart.com/showthread.php?t=19986)

gfiebich 02-17-2006 12:52 PM

Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
I needed the ability to offer some items in "case quantities" (ie. 12, 24, 36, etc). This thread (http://forum.x-cart.com/viewtopic.php?t=23097) describes how to do this site-wide, but I also have items which are sold in single units. Here's what I did: (This has been edited to resolve the Variant Qty problem described in the posts below. GF) (I've edited the code again to patch another javascript issue - argh.)
  1. Create an Extra Field in the admin called "CaseSize". This will contain the number we will use to STEP by. Uncheck "show".
  2. Open skin1/customer/main/product.tpl and find:
    Code:

    {if $active_modules.Product_Options ne ""}
    {include file="modules/Product_Options/customer_options.tpl"}
    {/if}

    and replace it with
    Code:

    {* Determine if product is sold in Case Quantities. This is handled with an Extra Product Field. *}
    {section name=field loop=$extra_fields}
    {if $extra_fields[field].field eq "CaseSize" && $extra_fields[field].field_value ne ""}
    {assign var="case_size" value=$extra_fields[field].field_value}{/if}
    {/section}

    {if $active_modules.Product_Options ne ""}
    {include file="modules/Product_Options/customer_options.tpl" casesize=$case_size}
    {/if}

  3. Find
    Code:

    var avail = {$mq|default:1}-1;
    and replace it with
    Code:

    {if $case_size eq ''}
    var avail = {$mq|default:1}-1;
    {/if}

  4. Find
    Code:

    {section name=quantity loop=$mq start=$start_quantity}
    and replace it with
    Code:

    {section name=quantity loop=$mq start=$start_quantity step=$case_size}
  5. Open modules/Product_Options/customer_options.tpl and find
    Code:

    {include file="modules/Product_Options/check_options.tpl"}
    and replace it with
    Code:

    {include file="modules/Product_Options/check_options.tpl" case_size=$casesize}
  6. Open modules/Product_Options/check_options.tpl and find
    Code:

                            if(!isNaN(min_avail) && !isNaN(avail)) {
                                    var first_value = -1;
                                    if(document.getElementById('product_avail').options[0])
                                            first_value = document.getElementById('product_avail').options[0].value;
                                    if(first_value == min_avail) {
                                            if((avail-min_avail+1) != document.getElementById('product_avail').options.length) {
                                                    if(document.getElementById('product_avail').options.length > avail) {
                                                            cnt = document.getElementById('product_avail').options.length;
                                                            for(x = avail; x < cnt; x++)
                                                                    document.getElementById('product_avail').options[document.getElementById('product_avail').options.length-1] = null;
                                                    } else {
                                                            cnt = document.getElementById('product_avail').options.length;
                                                            for(x = cnt+1; x <= avail; x++)
                                                                    document.getElementById('product_avail').options[cnt++] = new Option(x, x);
                                                    }
                                            }
                                    } else {
                                            while(document.getElementById('product_avail').options.length > 0)
                                                    document.getElementById('product_avail').options[0] = null;
                                            cnt = 0;
                                            for(x = min_avail; x <= avail; x++)
                                                    document.getElementById('product_avail').options[cnt++] = new Option(x, x);
                                    }
                                    if(document.getElementById('product_avail').options.length == 0)
                                            document.getElementById('product_avail').options[0] = new Option(txt_out_of_stock, 0);
                            }

    and replace it with
    Code:

                            if (case_size == '') {
                                    if(!isNaN(min_avail) && !isNaN(avail)) {
                                            var first_value = -1;
                                            if(document.getElementById('product_avail').options[0])
                                                    first_value = document.getElementById('product_avail').options[0].value;
                                            if(first_value == min_avail) {
                                                    if((avail-min_avail+1) != document.getElementById('product_avail').options.length) {
                                                            if(document.getElementById('product_avail').options.length > avail) {
                                                                    cnt = document.getElementById('product_avail').options.length;
                                                                    for(x = avail; x < cnt; x++)
                                                                            document.getElementById('product_avail').options[document.getElementById('product_avail').options.length-1] = null;
                                                            } else {
                                                                    cnt = document.getElementById('product_avail').options.length;
                                                                    for(x = cnt+1; x <= avail; x++)
                                                                            document.getElementById('product_avail').options[cnt++] = new Option(x, x);
                                                            }
                                                    }
                                            } else {
                                                    while(document.getElementById('product_avail').options.length > 0)
                                                            document.getElementById('product_avail').options[0] = null;
                                                    cnt = 0;
                                                    for(x = min_avail; x <= avail; x++)
                                                            document.getElementById('product_avail').options[cnt++] = new Option(x, x);
                                            }
                                            if(document.getElementById('product_avail').options.length == 0)
                                                    document.getElementById('product_avail').options[0] = new Option(txt_out_of_stock, 0);
                                    }
                            }

  7. Now, edit an item that you want to display with case quantities
  8. set the "Min order amount" to the quantity you want to start at ("12" in my example).
  9. set the "CaseSize" to the number you want to STEP by ("12" in my example).

That's it! Items that don't have a CaseSize set will behave normally, stepping by 1. Notes: If you allow customers to update item quantities in the cart, they will be able to change their quantities to non case quantity multiples. Items using CaseSize will not benefit from X-cart's built-in inventory javascript. This was done in x-cart gold 4.0.13.

happy modding,
Glen

gfiebich 03-02-2006 06:54 AM

I've updated the code above to fix a problem with the quantity listing when showing case quanitities. The javascript on product.tpl also controls the quantity select menu and this needed to be edited to match how the Section loop behaved.

-Glen

photo 05-11-2006 08:28 AM

Hello Glen

I installed this mod and it works great except for the "step" option in the dropdown box. I have it set up to step by 10 up to 500 which it does, but after the 500 in the dropdown box it goes to 60, 61, 62, ect.. up to 500

Example of options in drop down box:

480
490
500
60
61
62

Any idea what may be causing this?

Thanks

photo 05-15-2006 02:53 AM

I also found out I only have this problem if the product has a variant.

gfiebich 05-15-2006 11:31 AM

Tony -
I've edited the original code above to fix the problem you found. Items with Variants and CaseSize should now display a proper Quantity selection pulldown. Thanks for spotting that.
-Glen

photo 05-15-2006 11:39 AM

Quote:

Originally Posted by gfiebich
Tony -
I've edited the original code above to fix the problem you found. Items with Variants and CaseSize should now display a proper Quantity selection pulldown. Thanks for spotting that.
-Glen


Thanks alot Glen I'll give it try. Really apreciate you taking the time to check this out.

Tony

photo 05-15-2006 12:02 PM

That did the trick Glen.

Thanks again
Tony

gfiebich 05-15-2006 04:55 PM

I've updated the code again with hopefully the last fix. Today's previous update disabled the "add to cart" button (whoops). The new fix applies to modules/product_options/check_options.tpl and turns off some javascript if the item has case quantities.

-Glen

photo 05-16-2006 05:57 AM

Thanks Glen,

I turned in a ticket on this to see if there is a way of doing this without losing X-cart's built-in inventory javascript.

Thanks
Tony

bretto 11-06-2006 05:00 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Thanks so much for the code. Works a treat.

SMDStudios 12-20-2006 10:29 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
I need something very similar to this. If I have the min. order amount set to 2 I need the quantity to increment by 2s.

Any help with modifying this?

sohaibkhan 12-24-2006 08:15 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
I have this code running on my site I can sell it for $35. I have also PM you the link for demo.

Thanks

Fueled 02-05-2007 12:37 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Hi

I started making this mod to my cart (4.1.5) but had to stop at the step where you modify the javascript. It looks like it has been moved and substantially changed in 4.1. Has anyone gotten this to work in their cart?

Thanks

g053584398 07-27-2007 08:00 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
I am running X-Cart version 4.1.6.

I was following gfiebich's instrusctions until I came to:

"6. Open modules/Product_Options/check_options.tpl and find..."

The code section mentioned is missing from check_options.tpl in the version of X-Cart that I'm running. Can anyone post a modification for version 4.1.6 please?

Thanks

oldskule 09-17-2007 08:55 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Seamless. Worked well.

Now, how can I pass that same variable to the buy_now.tpl so it displays the same quantity drop down on the products pages.

Right now in buy_now.tpl, I just have:
{section name=quantity loop=$mq start=$start_quantity step=12}

But I'd like to get it to pass the CaseSize variable instead of having it hard-coded.
Just not sure what i need to do to make $case_size usable in that spot.

cherie 03-12-2008 03:24 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Quote:

Originally Posted by g053584398
I am running X-Cart version 4.1.6.

I was following gfiebich's instrusctions until I came to:

"6. Open modules/Product_Options/check_options.tpl and find..."

The code section mentioned is missing from check_options.tpl in the version of X-Cart that I'm running. Can anyone post a modification for version 4.1.6 please?


Looks like all of the steps work fine for 4.1 and you can skip step 6. It doesn't appear to be needed but I may be missing something. :)

cherie 03-12-2008 03:25 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Quote:

Originally Posted by oldskule
Seamless. Worked well.

Now, how can I pass that same variable to the buy_now.tpl so it displays the same quantity drop down on the products pages.

Right now in buy_now.tpl, I just have:
{section name=quantity loop=$mq start=$start_quantity step=12}

But I'd like to get it to pass the CaseSize variable instead of having it hard-coded.
Just not sure what i need to do to make $case_size usable in that spot.


This may be difficult with 4.0 since Extra Fields are not available in the product listings. However, they are available in 4.1. :)

itsmeee 04-30-2008 10:13 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Quote:

Originally Posted by Fueled
Hi

I started making this mod to my cart (4.1.5) but had to stop at the step where you modify the javascript. It looks like it has been moved and substantially changed in 4.1. Has anyone gotten this to work in their cart?

Thanks


Hey I had just started working on a module like this until I found this thread. I had the same problem though when I hit the last step until I looked at the bottom of the page and noticed that they have just seperated the java from the rest of the code.

So the last step for 4.1.8 (maybe the whole 4.1.x branch) should be

6. Open modules/Product_Options/func.js and find
Code:

        if (!availObj)
                availObj = document.getElementById('product_avail');

        if (availObj && availObj.tagName.toUpperCase() == 'SELECT') {
                if (!isNaN(min_avail) && !isNaN(avail)) {
                        var first_value = -1;
                        if (availObj.options[0])
                                first_value = availObj.options[0].value;

                        if (first_value == min_avail) {

                                /* New and old first value in quantities list is equal */
                                if ((avail-min_avail+1) != availObj.options.length) {
                                        if (availObj.options.length > avail) {
                                                var cnt = availObj.options.length;
                                                for (var x = (avail < 0 ? 0 : avail); x < cnt; x++)
                                                        availObj.options[availObj.options.length-1] = null;
                                        } else {
                                                var cnt = availObj.options.length;
                                                for (var x = cnt+1; x <= avail; x++)
                                                        availObj.options[cnt++] = new Option(x, x);
                                        }
                                }
                        } else {

                                /* New and old first value in quantities list is differ */
                                while (availObj.options.length > 0)
                                        availObj.options[0] = null;
                                var cnt = 0;
                                for (var x = min_avail; x <= avail; x++)
                                        availObj.options[cnt++] = new Option(x, x);
                        }
                        if (availObj.options.length == 0)
                                availObj.options[0] = new Option(txt_out_of_stock, 0);
                }
                select_avail = availObj.options[availObj.selectedIndex].value;
        }

        check_wholesale(select_avail);

        if ((alert_msg == 'Y') && (min_avail > avail))
                alert(txt_out_of_stock);


and replace it with

Code:

        if (case_size == '') {
        if (!availObj)
                availObj = document.getElementById('product_avail');

        if (availObj && availObj.tagName.toUpperCase() == 'SELECT') {
                if (!isNaN(min_avail) && !isNaN(avail)) {
                        var first_value = -1;
                        if (availObj.options[0])
                                first_value = availObj.options[0].value;

                        if (first_value == min_avail) {

                                /* New and old first value in quantities list is equal */
                                if ((avail-min_avail+1) != availObj.options.length) {
                                        if (availObj.options.length > avail) {
                                                var cnt = availObj.options.length;
                                                for (var x = (avail < 0 ? 0 : avail); x < cnt; x++)
                                                        availObj.options[availObj.options.length-1] = null;
                                        } else {
                                                var cnt = availObj.options.length;
                                                for (var x = cnt+1; x <= avail; x++)
                                                        availObj.options[cnt++] = new Option(x, x);
                                        }
                                }
                        } else {

                                /* New and old first value in quantities list is differ */
                                while (availObj.options.length > 0)
                                        availObj.options[0] = null;
                                var cnt = 0;
                                for (var x = min_avail; x <= avail; x++)
                                        availObj.options[cnt++] = new Option(x, x);
                        }
                        if (availObj.options.length == 0)
                                availObj.options[0] = new Option(txt_out_of_stock, 0);
                }
                select_avail = availObj.options[availObj.selectedIndex].value;
        }

        check_wholesale(select_avail);

        if ((alert_msg == 'Y') && (min_avail > avail))
                alert(txt_out_of_stock);
        }


I've gotten this working fine (I think) with dynamic images too so if you have questions about doing it with that program feel free to ask me and I'll try to help you through.

I need to confess though that I don't know javascript though so if anyone can confirm what I've done here I'd love to know I'm not screwing things up :p

Also I think these forums should setup some way to monetarily thank people for awesome modules like this! I know people are just sharing some knowledge which is really really awesome, but I'd love it if I could give a few bucks at least to thank people like gfiebich for saving me tons of time :)

itsmeee 04-30-2008 11:30 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
I'm also working on a modification to this so that i can specify minimum quantities for wholesale customers only. So for example I have bookmarks that a normal customer can buy 1 at a time but wholesale need to buy at least 6. I'll update with any progress I make with this.

itsmeee 04-30-2008 12:56 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Alright, now again please realize I've only been working with PHP for a little bit here and everything I know I've taught myself. So if anyone good could make sure I'm not screwing stuff up that would be great.

Anyway my problem as I listed in my last post is that I needed certain products such as bookmarks to be purchased in certain quantities by wholesale members while regular users needed to be able to purchase whatever amount they wanted.

We start with what gfiebich posted but with my modifications for the 4.1.8 ver (maybe the whole 4.1.x branch).
  1. Create an Extra Field in the admin called "CaseSize". This will contain the number we will use to STEP by. Uncheck "show".
  2. Open skin1/customer/main/product.tpl and find:
    Code:

    {if $active_modules.Product_Options ne ""}
    {include file="modules/Product_Options/customer_options.tpl"}
    {/if}

    and replace it with
    Code:

    {* Determine if product is sold in Case Quantities. This is handled with an Extra Product Field. *}
    {section name=field loop=$extra_fields}
    {if $extra_fields[field].field eq "CaseSize" && $extra_fields[field].field_value ne ""}
    {assign var="case_size" value=$extra_fields[field].field_value}{/if}
    {/section}

    {if $active_modules.Product_Options ne ""}
    {include file="modules/Product_Options/customer_options.tpl" casesize=$case_size}
    {/if}

  3. Find
    Code:

    var avail = {$mq|default:1}-1;
    and replace it with
    Code:

    {if $case_size eq ''}
    var avail = {$mq|default:1}-1;
    {/if}

  4. Find
    Code:

    {section name=quantity loop=$mq start=$start_quantity}
    and replace it with
    Code:

    {section name=quantity loop=$mq start=$start_quantity step=$case_size}
  5. Open modules/Product_Options/customer_options.tpl and find
    Code:

    {include file="modules/Product_Options/check_options.tpl"}
    and replace it with
    Code:

    {include file="modules/Product_Options/check_options.tpl" case_size=$casesize}
  6. Open modules/Product_Options/func.js and find
    Code:

            if (!availObj)
                    availObj = document.getElementById('product_avail');

            if (availObj && availObj.tagName.toUpperCase() == 'SELECT') {
                    if (!isNaN(min_avail) && !isNaN(avail)) {
                            var first_value = -1;
                            if (availObj.options[0])
                                    first_value = availObj.options[0].value;

                            if (first_value == min_avail) {

                                    /* New and old first value in quantities list is equal */
                                    if ((avail-min_avail+1) != availObj.options.length) {
                                            if (availObj.options.length > avail) {
                                                    var cnt = availObj.options.length;
                                                    for (var x = (avail < 0 ? 0 : avail); x < cnt; x++)
                                                            availObj.options[availObj.options.length-1] = null;
                                            } else {
                                                    var cnt = availObj.options.length;
                                                    for (var x = cnt+1; x <= avail; x++)
                                                            availObj.options[cnt++] = new Option(x, x);
                                            }
                                    }
                            } else {

                                    /* New and old first value in quantities list is differ */
                                    while (availObj.options.length > 0)
                                            availObj.options[0] = null;
                                    var cnt = 0;
                                    for (var x = min_avail; x <= avail; x++)
                                            availObj.options[cnt++] = new Option(x, x);
                            }
                            if (availObj.options.length == 0)
                                    availObj.options[0] = new Option(txt_out_of_stock, 0);
                    }
                    select_avail = availObj.options[availObj.selectedIndex].value;
            }

            check_wholesale(select_avail);

            if ((alert_msg == 'Y') && (min_avail > avail))
                    alert(txt_out_of_stock);


    and replace it with

    Code:

            if (case_size == '') {
            if (!availObj)
                    availObj = document.getElementById('product_avail');

            if (availObj && availObj.tagName.toUpperCase() == 'SELECT') {
                    if (!isNaN(min_avail) && !isNaN(avail)) {
                            var first_value = -1;
                            if (availObj.options[0])
                                    first_value = availObj.options[0].value;

                            if (first_value == min_avail) {

                                    /* New and old first value in quantities list is equal */
                                    if ((avail-min_avail+1) != availObj.options.length) {
                                            if (availObj.options.length > avail) {
                                                    var cnt = availObj.options.length;
                                                    for (var x = (avail < 0 ? 0 : avail); x < cnt; x++)
                                                            availObj.options[availObj.options.length-1] = null;
                                            } else {
                                                    var cnt = availObj.options.length;
                                                    for (var x = cnt+1; x <= avail; x++)
                                                            availObj.options[cnt++] = new Option(x, x);
                                            }
                                    }
                            } else {

                                    /* New and old first value in quantities list is differ */
                                    while (availObj.options.length > 0)
                                            availObj.options[0] = null;
                                    var cnt = 0;
                                    for (var x = min_avail; x <= avail; x++)
                                            availObj.options[cnt++] = new Option(x, x);
                            }
                            if (availObj.options.length == 0)
                                    availObj.options[0] = new Option(txt_out_of_stock, 0);
                    }
                    select_avail = availObj.options[availObj.selectedIndex].value;
            }

            check_wholesale(select_avail);

            if ((alert_msg == 'Y') && (min_avail > avail))
                    alert(txt_out_of_stock);
            }

  7. Now, edit an item that you want to display with case quantities
  8. set the "Min order amount" to the quantity you want to start at ("12" in my example).
  9. set the "CaseSize" to the number you want to STEP by ("12" in my example).

To add in the functionality so that certain products such as bookmarks to be purchased in certain quantities by wholesale members while regular users needed to be able to purchase whatever amount they wanted.
  • Follow this link and follow the instructions so that you can specify things in smarty based on membership levels you've created.
  • Now open modules/Product_Options/customer_options.tpl again and find this:
    Code:

    {* Determine if product is sold in Case Quantities. This is handled with an Extra Product Field. *}
    {section name=field loop=$extra_fields}
    {if $extra_fields[field].field eq "CaseSize" && $extra_fields[field].field_value ne ""}
    {assign var="case_size" value=$extra_fields[field].field_value}{/if}
    {/section}

    {if $active_modules.Product_Options ne ""}
    {include file="modules/Product_Options/customer_options.tpl" casesize=$case_size}
    {/if}


    and replace with:

    Code:

    {if $usermembership == "Wholesale"}
    {* Determine if product is sold in Case Quantities. This is handled with an Extra Product Field. *}
    {section name=field loop=$extra_fields}
    {if $extra_fields[field].field eq "CaseSize" && $extra_fields[field].field_value ne ""}
    {assign var="case_size" value=$extra_fields[field].field_value}{/if}
    {/section}

    {if $active_modules.Product_Options ne ""}
    {include file="modules/Product_Options/customer_options.tpl" casesize=$case_size}
    {/if}{** end **}

    {else}

    {if $active_modules.Product_Options ne ""}
    {include file="modules/Product_Options/customer_options.tpl"}
    {/if}

    {/if}

  • Now in the same file find this:
    Code:

    {section name=quantity loop=$mq start=$start_quantity step=$case_size}

    and replace it with:

    Code:

    {if $usermembership == "Wholesale"}
    {section name=quantity loop=$mq start="0" step=$case_size}
    <option value="{%quantity.index%}"{if $smarty.get.quantity eq %quantity.index%} selected="selected"{/if}>{%quantity.index%}</option>
    {/section}

    {else}

    {section name=quantity loop=$mq start=$start_quantity}
    <option value="{%quantity.index%}"{if $smarty.get.quantity eq %quantity.index%} selected="selected"{/if}>{%quantity.index%}</option>
    {/section}
    {/if}


This isn't fully finished. I'd like to change the starting # from "0" to something I have defined in an extra field. I'm sort of figuring out how to do this.

itsmeee 05-01-2008 10:02 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Alright, realized in another thread most people probably have account stuff setup differently then I do which makes it easy for me to do this. We don't allow most people to create an account, they can signup for mailers and post on our blog. We do have wholesale accounts which we create and then they are able to login and that is the only way they can get prices for that.

So the problem is if you can have regular accounts, a wholesale or whoever can go in as a logged out person, select under the min quantity and then log in which makes it so they can get the savings without quantities. This can be fixed but it's not something we have to deal with.

WLPracing 06-04-2008 09:56 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Well unfortunatly this doesn't work with xcart 4.1.10 anyone know how to make it successfully work in this version?

xcesiv 07-21-2008 10:27 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
i would love to know aswell

the part u need to replace in the Check_options.tpl doesnt exist.

xcesiv 07-21-2008 10:31 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
also... is it possible to tweak this to make the case options not a multiple of that vale, but a list of quantities,

eg,
2, 10, 20, 50, 100

BodyBalance 08-01-2008 11:37 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
I took would like it to be able to input specific quantites, not multiples. Any suggestions?

WhiteDoveGifts 12-27-2008 05:44 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Quote:

Originally Posted by WLPracing
Well unfortunatly this doesn't work with xcart 4.1.10 anyone know how to make it successfully work in this version?


I'd like to know as well... :roll: Anyone got this mod working with a recent version?

WhiteDoveGifts 01-02-2009 01:50 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Never mind, I got it working!!! Just skipped step 5 and used the renewed code change in step 6. :) :) :)

WhiteDoveGifts 01-03-2009 06:07 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Quote:

Originally Posted by WhiteDoveGifts
Never mind, I got it working!!! Just skipped step 5 and used the renewed code change in step 6. :) :) :)


:( Well, I guess I expressed my joy to early. I discovered a problem with all my products with a variant (size)

The size option drop down box now appears twice on top of each other. I restored the product.tpl and func.js files back to prevent customers from frowning...

Does anyone know how to solve this? Thanks in advance!

WhiteDoveGifts 01-05-2009 01:27 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Hello, well guess again. I got everything working correctly now. It seemed I missed post #20 ( http://forum.x-cart.com/showpost.php?p=214440&postcount=20 ) and just implemented the code from all 6 steps and.. voila! Just the exact mod I need and with my variants also working :)

itsmeee 01-21-2009 02:06 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Quote:

Originally Posted by WhiteDoveGifts
Hello, well guess again. I got everything working correctly now. It seemed I missed post #20 ( http://forum.x-cart.com/showpost.php?p=214440&postcount=20 ) and just implemented the code from all 6 steps and.. voila! Just the exact mod I need and with my variants also working :)


I'm upgrading from 4.1.8 soon so this was good information, thanks :)

angie 06-03-2009 06:17 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Good Morning,

This mod is just what I am looking for but it looks like there are some changes from 4.1.8 to 4.2.1
Has anyone implemented this change on their 4.2.1 version or have a similar mod?

TIA,
Angie

philrisk 02-04-2010 05:47 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
I have just done this mod in 4.3 and works a treat. I only added the extra pieces of code and didnt copy and paste the whole bit of each. The work round for step 6 still needs to be done with changes. Shout if anyone needs to know how I did this. Cheers to the guy who came up with this.

notnac445 03-23-2010 05:39 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
I need to know how to do this in 4.3, can you post it? Thanks!

computerclone 03-24-2010 11:21 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
This would save a whole lot of trouble

BUMP

fioppy 01-08-2011 10:54 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
I need to custiomized the product options to serve a special task in my website.

I want to create a Drop down list which is normal and available now on website for ex:
Size:(1,2,3,4,5, Customize)

I will create different Text options too like: Hips, Arm, Waist, Bust as test field to options products.

If customer selected "customize" from drop down list dynamicaly the Test fields above should be displayed below it. or then they should be hidden all time unless customer picked Customize from Size drop down list.

Please advice what change required to reach this option

Regards

pwdesign 10-15-2011 11:17 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
I am in need of this mod for 4.4.4. The changes from 4.1 to 4.4 are significant but I've been trying to go line by line to try and figure it out. In the meantime, I've been getting quotes from X-Cart Support and BCS to write the mod. Unfortunately I don't have the budget for them. Please...if you have this working on your 4.4 site and can share the changes, I would be indebted...
Thanks.

philrisk 01-19-2012 06:53 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown - UPDATED FOR 4.4.4
 
I have just successfully got this to work on 4.4.4 and also work on the product categories pages. Kudos to gfiebich for the original mod.
  1. Create an Extra Field in the admin called "CaseSize". This will contain the number we will use to STEP by. Uncheck "show".
  2. Open (in my case) /skin/2-columns/customer/main/product_details.tpl or /skin/common_files/customer/main/product_details.tpl

    Find:

    HTML Code:



        {if $product.forsale neq "B" or ($product.forsale eq "B" and  $smarty.get.pconf ne "" and $active_modules.Product_Configurator)}
          {if $active_modules.Product_Options ne ""}
            {if ($active_modules.Extra_Fields and $extra_fields) or  ($active_modules.Feature_Comparison and $product.features.options)}
              <tr>
                <td colspan="3" class="poptions-product-separator">&nbsp;</td>
              </tr>
            {/if}
            {include file="modules/Product_Options/customer_options.tpl" disable=$lock_options}
          {/if}
        {/if}


    Replace with:

    HTML Code:

    {* CASESIZE MOD - Determine if product is sold in Case Quantities. This is handled with an Extra Product Field. *}
    {section name=field loop=$extra_fields}
    {if $extra_fields[field].field eq "CaseSize" && $extra_fields[field].field_value ne ""}
    {assign var="case_size" value=$extra_fields[field].field_value}{/if}
    {/section}

        {if $product.forsale neq "B" or ($product.forsale eq "B" and  $smarty.get.pconf ne "" and $active_modules.Product_Configurator)}
          {if $active_modules.Product_Options ne ""}
            {if ($active_modules.Extra_Fields and $extra_fields) or  ($active_modules.Feature_Comparison and $product.features.options)}
              <tr>
                <td colspan="3" class="poptions-product-separator">&nbsp;</td>
              </tr>
            {/if}
            {include file="modules/Product_Options/customer_options.tpl" casesize=$case_size disable=$lock_options}
          {/if}
        {/if}
    {* CASESIZE MOD - End *}


    Find:

    HTML Code:

    var avail = {$product.appearance.max_quantity|default:1};

    Replace with:

    HTML Code:

    {if $case_size eq ''}
    var avail = {$product.appearance.max_quantity|default:1};
    {/if}


    Find:

    HTML Code:

    {section name=quantity loop=$product.appearance.loop_quantity start=$product.appearance.min_quantity}

    Replace with:

    HTML Code:

    {section name=quantity loop=$product.appearance.loop_quantity  start=$product.appearance.min_quantity step=$case_size}
  3. Open skin/common_files/modules/Product_Options/customer_options.tpl

    Find:

    HTML Code:

    {include file="modules/Product_Options/check_options.tpl"}

    Replace with:

    HTML Code:

    {include file="modules/Product_Options/check_options.tpl" case_size=$casesize}
  4. Open /skin/common_files/modules/Product_Options/func.js

    Find:

    HTML Code:

    if (availObj && availObj.tagName.toUpperCase() == 'SELECT') {

        // Select box
        if (!isNaN(min_avail) && !isNaN(avail)) {
          var first_value = -1;
          if (availObj.options[0])
            first_value = availObj.options[0].value;

          if (first_value == min_avail) {

            /* New and old first value in quantities list is equal */
            if ((avail-min_avail+1) != availObj.options.length) {
              if (availObj.options.length > avail-min_avail+1) {
                var cnt = availObj.options.length;
                for (var x = (avail-min_avail+1 < 0 ? 0 : avail-min_avail+1); x < cnt; x++)
                  availObj.options[availObj.options.length-1] = null;

              } else {
                var cnt = availObj.options.length;
                for (var x = cnt+min_avail; x <= avail-min_avail+1; x++)
                  availObj.options[cnt++] = new Option(x, x);
              }
            }
          } else {

            /* New and old first value in quantities list is differ */
            var cnt = availObj.options.length - 1;
            while (cnt >
    = 0)
              availObj.options[cnt--] = null;

            cnt = 0;
            for (var x = min_avail; x <= avail; x++)
              availObj.options[cnt++] = new Option(x, x);
          }
          if (availObj.options.length == 0 || min_avail >
    avail)
            availObj.options[0] = new Option(txt_out_of_stock, 0);
        }
        select_avail = availObj.options[availObj.selectedIndex].value;

      } else if (availObj && availObj.tagName.toUpperCase() == 'INPUT' && availObj.type.toUpperCase() == 'TEXT') {

        // Input box
            if (!isNaN(min_avail) && !isNaN(avail)) {
          availObj.minQuantity = min_avail;
          availObj.maxQuantity = max_avail;
        }

        if (isNaN(parseInt(availObj.value)) || availObj.value == 0)
          availObj.value = min_avail;
       
          select_avail = availObj.value;
      }


    Replace with:

    HTML Code:

    if (availObj && availObj.tagName.toUpperCase() == 'SELECT') {
    if (case_size == '') {
        // Select box
        if (!isNaN(min_avail) && !isNaN(avail)) {
          var first_value = -1;
          if (availObj.options[0])
            first_value = availObj.options[0].value;

          if (first_value == min_avail) {

            /* New and old first value in quantities list is equal */
            if ((avail-min_avail+1) != availObj.options.length) {
              if (availObj.options.length > avail-min_avail+1) {
                var cnt = availObj.options.length;
                for (var x = (avail-min_avail+1 < 0 ? 0 : avail-min_avail+1); x < cnt; x++)
                  availObj.options[availObj.options.length-1] = null;

              } else {
                var cnt = availObj.options.length;
                for (var x = cnt+min_avail; x <= avail-min_avail+1; x++)
                  availObj.options[cnt++] = new Option(x, x);
              }
            }
          } else {

            /* New and old first value in quantities list is differ */
            var cnt = availObj.options.length - 1;
            while (cnt >
    = 0)
              availObj.options[cnt--] = null;

            cnt = 0;
            for (var x = min_avail; x <= avail; x++)
              availObj.options[cnt++] = new Option(x, x);
          }
          if (availObj.options.length == 0 || min_avail >
    avail)
            availObj.options[0] = new Option(txt_out_of_stock, 0);
        }
        select_avail = availObj.options[availObj.selectedIndex].value;

      } else if (availObj && availObj.tagName.toUpperCase() == 'INPUT' && availObj.type.toUpperCase() == 'TEXT') {

        // Input box
            if (!isNaN(min_avail) && !isNaN(avail)) {
          availObj.minQuantity = min_avail;
          availObj.maxQuantity = max_avail;
        }

        if (isNaN(parseInt(availObj.value)) || availObj.value == 0)
          availObj.value = min_avail;
       
          select_avail = availObj.value;
      }

    }

  5. Open /skin/common_files/customer/main/buy_now.tpl

    Find:

    HTML Code:


                <select name="amount">
                  {section name=quantity loop=$product.appearance.loop_quantity start=$product.appearance.min_quantity}
                    <option value="{%quantity.index%}"{if $smarty_get_quantity eq %quantity.index%} selected="selected"{/if}>{%quantity.index%}</option>
                  {/section}
                </select>


    Replace with:

    HTML Code:

    {section name=field loop=$products}
    {section name=field2 loop=$products[field].extra_fields}
    {if $products[field].extra_fields[field2].field eq "CaseSize" && $products[field].extra_fields[field2].field_value ne ""}
    {assign var="case_size" value=$products[field].extra_fields[field2].field_value}{/if}
    {/section}
    {/section}
                <select name="amount">
                  {section name=quantity loop=$product.appearance.loop_quantity start=$product.appearance.min_quantity step=$case_size}
                    <option value="{%quantity.index%}"{if $smarty_get_quantity eq %quantity.index%} selected="selected"{/if}>{%quantity.index%}</option>
                  {/section}
                </select>

  6. Now, edit an item that you want to display with case quantities
  7. Set the "Min order amount" to the quantity you want to start at ("12" in my example).
  8. Set the "CaseSize" to the number you want to STEP by ("12" in my example).

pwdesign 01-22-2012 01:07 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
philrisk

Thank you very much for your detailed instructions. Everything was spot on except for the very first change box on product_details.tpl. The file in my template skin (fashion mosaic gray) and the one in the common_files directory are very different from the example you gave. There is a ton of code within the first if statement. I even checked the product_details.tpl in 2-columns to see if they matched your example and they did not.

I made an attempt to stitch in the unique extra_case code in product_details.tpl, as well as all the other changes. The Case Size extra field displays in the product admin and I updated a few products, but when I go to the storefront, the quantity box is still a text box, that any number can be entered into. Is it supposed to be a dropdown?

Any light you can shed on the situation would be most appreciated. Thank you for all you've done already.

philrisk 01-23-2012 12:36 AM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
Quote:

Originally Posted by pwdesign
philrisk

Thank you very much for your detailed instructions. Everything was spot on except for the very first change box on product_details.tpl. The file in my template skin (fashion mosaic gray) and the one in the common_files directory are very different from the example you gave. There is a ton of code within the first if statement. I even checked the product_details.tpl in 2-columns to see if they matched your example and they did not.

I made an attempt to stitch in the unique extra_case code in product_details.tpl, as well as all the other changes. The Case Size extra field displays in the product admin and I updated a few products, but when I go to the storefront, the quantity box is still a text box, that any number can be entered into. Is it supposed to be a dropdown?

Any light you can shed on the situation would be most appreciated. Thank you for all you've done already.



Hi pwdesign

That piece of code is at line 75 of /skin/2-column/customer/main/product_details.tpl in a default install of 4.4.4.

It is right after:
{if $active_modules.Feature_Comparison}
{include file="modules/Feature_Comparison/product.tpl"}
{/if}

To get the dropdown for the quantities you need to make sure you have
"Show quantity selector as input textbox" unchecked in the Appearance settings.

pwdesign 01-23-2012 07:45 PM

Re: Case Quantities (ie. 12, 24, 36, etc) in quantity pulldown
 
OK..I see it now. Thanks! Fashion Mosaic has a very different product_details.tpl. I stitched in the code where I thought it should go, unchecked the Text Box option in Appearance and IT WORKS! Thank you!

However...once the item is added to the cart, the quantity field is a text box again and can be changed to any amount. I unchecked "Allow to update product quantity on the checkout pages" in Apperance and it still shows. Is yours like that as well or do you have a dropdown menu in the cart or no quantity update at all?

Thank you very much!


All times are GMT -8. The time now is 03:56 PM.

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