Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

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

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #11  
Old 12-20-2006, 10:29 AM
 
SMDStudios SMDStudios is offline
 

eXpert
  
Join Date: Dec 2003
Location: Orlando, FL
Posts: 207
 

Default 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?
__________________
X-Cart Gold various versions
Tahoe Web Design

WebsiteCM.com - We recommend WebsiteCM
Reply With Quote
  #12  
Old 12-24-2006, 08:15 PM
 
sohaibkhan sohaibkhan is offline
 

Advanced Member
  
Join Date: Apr 2006
Posts: 78
 

Default 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
__________________
Current version: 4.1.5 Centos 4x
Reply With Quote
  #13  
Old 02-05-2007, 12:37 PM
 
Fueled Fueled is offline
 

Newbie
  
Join Date: Feb 2007
Posts: 1
 

Default 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
__________________
X-Cart Gold 4.1
Reply With Quote
  #14  
Old 07-27-2007, 08:00 AM
 
g053584398 g053584398 is offline
 

Newbie
  
Join Date: Jun 2006
Posts: 9
 

Default 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
__________________
D.G.

X-Cart Gold 4.1.6
Reply With Quote
  #15  
Old 09-17-2007, 08:55 AM
 
oldskule oldskule is offline
 

Newbie
  
Join Date: Mar 2006
Posts: 1
 

Default 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.
__________________
Version 4.0.17
Reply With Quote
  #16  
Old 03-12-2008, 03:24 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default 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.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #17  
Old 03-12-2008, 03:25 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default 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.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #18  
Old 04-30-2008, 10:13 AM
 
itsmeee itsmeee is offline
 

Advanced Member
  
Join Date: Sep 2007
Posts: 56
 

Default 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
__________________
Version 4.1.8
Reply With Quote
  #19  
Old 04-30-2008, 11:30 AM
 
itsmeee itsmeee is offline
 

Advanced Member
  
Join Date: Sep 2007
Posts: 56
 

Default 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.
__________________
Version 4.1.8
Reply With Quote
  #20  
Old 04-30-2008, 12:56 PM
 
itsmeee itsmeee is offline
 

Advanced Member
  
Join Date: Sep 2007
Posts: 56
 

Default 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.
__________________
Version 4.1.8
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:55 AM.

   

 
X-Cart forums © 2001-2020