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)

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 02:26 PM.

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