Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Removed Qty Box, now want it back for some

Removed Qty Box, now want it back for some

Locked

Views: 12,331

Results 1 to 20 of 71
This thread is locked. New replies are disabled.
12 May 2007, 11:04 PM
#1
lilleypadgifts avatar

lilleypadgifts

Totally Zenned

Join Date:
Jan 2007
Location:
Southern California
Posts:
550
Plugin Contributions:
0

Removed Qty Box, now want it back for some

I know at one time, when I was working with comics, I wanted to remove the Qty box.... we treat every comic as a individual item ... but now I'm working with Olympic Pins. I want the qty box to show for those items on the product page because we have multiple qtys of these. I thought I just had to checkmark YES to Show Qty Box, but that doesn't do it. The Qty box that shows with the Add To Cart button is showing ,but you can put any number in there ... I need to show the customer how many we have in stock.
Can I have it both ways? :lookaroun

13 May 2007, 12:12 AM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removed Qty Box, now want it back for some

Is this on the same site as the comics?

If not, you can set to show qty in stock in Catalog > Product Types > Product-General > edit layout.

If yes, you can get the different display options in two ways.
You can create a new product type for pins which can have its own settings; this requires a new database table and some files & editing.
Or you can set qty in stock to "on" and add a test in the qty display code to skip if in a comics category (or to show it only if in a pins category, whichever is easier). You would do this in /includes/templates/your_template/templates/tpl_product_info_display.php.

See the Parent Categories Separated In 3 sideboxes thread for how to distinguish categories to use.

13 May 2007, 2:08 AM
#3
lilleypadgifts avatar

lilleypadgifts

Totally Zenned

Join Date:
Jan 2007
Location:
Southern California
Posts:
550
Plugin Contributions:
0

Re: Removed Qty Box, now want it back for some

gjh42:

Is this on the same site as the comics?

If not, you can set to show qty in stock in Catalog > Product Types > Product-General > edit layout.

If yes, you can get the different display options in two ways.
You can create a new product type for pins which can have its own settings; this requires a new database table and some files & editing.
Or you can set qty in stock to "on" and add a test in the qty display code to skip if in a comics category (or to show it only if in a pins category, whichever is easier). You would do this in /includes/templates/your_template/templates/tpl_product_info_display.php.

See the Parent Categories Separated In 3 sideboxes thread for how to distinguish categories to use.

Yes, this is all on the same site! And we are not going to just have pins and comics....everything that we run thru eBay and then some will be on this site. I was so hoping that I was done editing the site :unsure: ... which is the "EASIEST" way to accomplish qty box showing for some and not for others? a new database and editing files is just so scarey since I FINALLY have it all working and now this.:no:

13 May 2007, 2:20 AM
#4
lilleypadgifts avatar

lilleypadgifts

Totally Zenned

Join Date:
Jan 2007
Location:
Southern California
Posts:
550
Plugin Contributions:
0

Re: Removed Qty Box, now want it back for some

Here is the area that I** thought** would change it per item... Qty total on or off... but it doesn't.
So what are these for? Am I just not using the correct settings?
I just changed the one shown below to YES, Show Qty box and a 1 in the Qty Max.... and of course it doesn't work. I could see if the Max Qty was set for the actual Qty that I have, then they couldn't order or back order any more then what is in stock...but if I have 1 of something, it just removes the Qty all together.

13 May 2007, 2:37 AM
#5
lilleypadgifts avatar

lilleypadgifts

Totally Zenned

Join Date:
Jan 2007
Location:
Southern California
Posts:
550
Plugin Contributions:
0

Re: Removed Qty Box, now want it back for some

OK.... I think I figured it out. I found the following thread (and I hope this is how you post a thread link)

http://www.zen-cart.com/forum/showthread.php?t=65176&highlight=Show+Quantity+stock

That told me where to look to find that I needed to edit my Stock preferences.

THEN...
I went back into my items. Turned off the Qty Box for the Comics, but put a 1 in the Max. Qty. Turned on the Qty Box for my pins and put the actual qty that I have in stock in the Max Qty field.
What I think threw me off is that it says 0 = inlimited...1= no box.. something like that and I thought you could only set that field to 0 or 1.
What ALSO threw me off was when I set a item qty to 1, it wasn't showing that, but that is because it doesn't when a qty is only 1, when I set one to 5, it shows the max they can buy is 5.
:flex:
Hope that makes sense and helps out someone else in the future :smile:

L ~
www.LilleyPadGifts.com

13 May 2007, 4:13 AM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removed Qty Box, now want it back for some

Glad you were able to figure out how to get what you wanted for the display.
I do have a doubt about it, though... if someone buys one of your 5-in-stock items, your display will still say Max 5 until you manually change it to 4, and that setting by itself will happily let someone buy all 5 of the now 4 items. If you also set (in Configuration > Stock)
Check stock level true
Subtract stock true
Allow Checkout false

This should keep you safe.

You still really want automatic qty-in-stock display, though, and for that you would best do as suggested above with Product Types > Product-General > edit layout and testing before display. That will be much less involved than a new product type.

13 May 2007, 4:16 AM
#7
lilleypadgifts avatar

lilleypadgifts

Totally Zenned

Join Date:
Jan 2007
Location:
Southern California
Posts:
550
Plugin Contributions:
0

Re: Removed Qty Box, now want it back for some

gjh42:

Glad you were able to figure out how to get what you wanted for the display.
I do have a doubt about it, though... if someone buys one of your 5-in-stock items, your display will still say Max 5 until you manually change it to 4, and that setting by itself will happily let someone buy all 5 of the now 4 items. If you also set (in Configuration > Stock)
Check stock level true
Subtract stock true
Allow Checkout false

This should keep you safe.

You still really want automatic qty-in-stock display, though, and for that you would best do as suggested above with Product Types > Product-General > edit layout and testing before display. That will be much less involved than a new product type.

I see what you mean.... now if I could wrap my brain around what you posted above about Product Types, I would do that... maybe I will be able to comprehend it tomorrow, but tonight I just can't :blush: .
I do, however, already have my Stock configs set as you mentioned above.

13 May 2007, 4:54 AM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removed Qty Box, now want it back for some

OK, good. I thought you might since you were working in Stock, but wanted to mention it for completeness.

In Product Types, all you have to do is set
Show Quantity in Stock to 1.

In tpl_product_info_display.php, you will want to add a test in this section```php

<!--bof Product details list --> <?php if ( (($flag_show_product_info_model == 1 and $products_model !=”) or ($flag_show_product_info_weight == 1 and $products_weight !=0) or ($flag_show_product_info_quantity == 1) or ($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name))) ) { ?> <ul id="productDetailsList" > <?php echo (($flag_show_product_info_model == 1 and $products_model !='') ? '<li>' . TEXT_PRODUCT_MODEL . $products_model . '</li>' : '') . "\n"; ?> <?php echo (($flag_show_product_info_weight == 1 and $products_weight !=0) ? '<li>' . TEXT_PRODUCT_WEIGHT . $products_weight . TEXT_PRODUCT_WEIGHT_UNIT . '</li>' : '') . "\n"; ?> <?php echo (($flag_show_product_info_quantity == 1 and $products_quantity >0) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>' : '') . "\n"; ?> <?php echo ((/*$flag_show_product_info_quantity == 1 and */$products_quantity <=0) ? '<li>' . TEXT_PRODUCT_O_O_S . '</li>' : '') . "\n"; ?>
 <?php echo (($flag_show_product_info_quantity == 1 and $products_quantity >0) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>'  : '') . "\n"; ?>
is only executed if you are not in a comics category.
A variation on this code ```php
if(in_array(str_replace("cPath=","",$box_categories_array[$i]['path']), explode(",",'3,21,21_57'))) {  
``` where the last bunch of numbers are replaced by your comic category cPaths will control it.

I'll go into it more thoroughly tomorrow, though it's not much more complicated than just this.
13 May 2007, 5:13 AM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removed Qty Box, now want it back for some

Actually, since all your comics are under top category id #1, I believe you can achieve your goal with just this snippet (!ereg("(^1$|^1_)",$cPath)) inserted in the existing line:

 <?php echo (((!ereg("(^1$|^1_)",$cPath)) and $flag_show_product_info_quantity == 1 and $products_quantity >0) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>'  : '') . "\n"; ?>

The function ereg will be true if $cPath either equals "1" or starts with "1_" (i.e. Comics), so if ereg is not true and the flag is on and there is 1 or more in stock, the qty in stock will be displayed. In Comics, this will never be displayed. In everything else, it will be.

If you come to a product from Search or All Products, there will be no cPath involved and the qty in stock will always show.

13 May 2007, 5:59 AM
#10
lilleypadgifts avatar

lilleypadgifts

Totally Zenned

Join Date:
Jan 2007
Location:
Southern California
Posts:
550
Plugin Contributions:
0

Re: Removed Qty Box, now want it back for some

Hmmmmm.... is this also true if I end up with another category that is one of a kinds? Right now, its Comics and Pins because I haven't started in on the others, but some will be handled the same as comics and some the same as pins. I'm afraid that what you showed above is only if Comics is the only product that we handle as individual items (because of condition and grades).

I'm wayyyyyy passed sleepy here, so I will come back here tomorrow and see if I can understand it better. If you are around tomorrow, please let me know.
Thanks!

13 May 2007, 6:40 AM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removed Qty Box, now want it back for some

You can add other categories to the no-show list with just a few characters for each one.
I'll tell you how tomorrow.

13 May 2007, 7:36 AM
#12
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: Removed Qty Box, now want it back for some

Glenn, as you mentioned in this quasi-related thread:

http://www.zen-cart.com/forum/showthread.php?p=373514#post373514
(Thread summary: To have a single category within a store that is Showcase-only. The rest of the store operates normally, displaying prices & cart)

This same logic does seem like it could be applied. However, it's way out of my league to do so. Could I trouble you to point me in the right direction?

It does seem that the ability to do this would be quite helpful to a number of people. (My self-serving way of being benevolent :P )

Thanks - Tim

13 May 2007, 4:52 PM
#13
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removed Qty Box, now want it back for some

Will do, Tim. First, the logic to include other categories/subcategories in this list:

(!ereg("(^1$|^1_)",$cPath))

You can find a full description of the PHP function ereg() in online tutorials like w3schools. For present purposes, there are three elements to understand.

^1$ means"the string is exactly 1".
^1_ means "the string starts with 1_".
| means "or".

And of course $cPath is the variable that holds the current category path, visible in the address bar.

For any top category (##) with or without subcategories, ^##$ will specify that top category.
For any top category with subcategories, ^##_ will specify all of its subcategories (and sub-subs etc.).
One step more detailed, for any subcategory (23_42), ^23_42$ will specify only that subcategory. THis can be extended as desired.
You can string any number of these specifications together with | between them, and if any one of them is true, ereg will return true.

Since in this case we want to execute if not in these categories, we add ! in front of ereg which says "f ereg is false, return true; if ereg is true, return false".

THis bit of logic can be embedded in any PHP statement where true or false is being evaluated on a category/product page.

13 May 2007, 7:23 PM
#14
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: Removed Qty Box, now want it back for some

gjh42:

Will do, Tim. First, the logic to include other categories/subcategories in this list:

(!ereg("(^1$|^1_)",$cPath))

You can find a full description of the PHP function ereg() in online tutorials like w3schools. For present purposes, there are three elements to understand.

^1$ means"the string is exactly 1".
^1_ means "the string starts with 1_".
| means "or".

And of course $cPath is the variable that holds the current category path, visible in the address bar.

For any top category (##) with or without subcategories, ^##$ will specify that top category.
For any top category with subcategories, ^##_ will specify all of its subcategories (and sub-subs etc.).
One step more detailed, for any subcategory (23_42), ^23_42$ will specify only that subcategory. THis can be extended as desired.
You can string any number of these specifications together with | between them, and if any one of them is true, ereg will return true.

Since in this case we want to execute if not in these categories, we add ! in front of ereg which says "f ereg is false, return true; if ereg is true, return false".

THis bit of logic can be embedded in any PHP statement where true or false is being evaluated on a category/product page.

Huh...!?! :huh: OK, I'll have to stew on that a bit and look into the tutorials. (And/or start drinking heavily) Whose wonderful idea was this, anyway?! :P

13 May 2007, 9:43 PM
#15
lilleypadgifts avatar

lilleypadgifts

Totally Zenned

Join Date:
Jan 2007
Location:
Southern California
Posts:
550
Plugin Contributions:
0

Re: Removed Qty Box, now want it back for some

gjh42:

Will do, Tim. First, the logic to include other categories/subcategories in this list:

(!ereg("(^1$|^1_)",$cPath))

You can find a full description of the PHP function ereg() in online tutorials like w3schools. For present purposes, there are three elements to understand.

^1$ means"the string is exactly 1".
^1_ means "the string starts with 1_".
| means "or".

And of course $cPath is the variable that holds the current category path, visible in the address bar.

For any top category (##) with or without subcategories, ^##$ will specify that top category.
For any top category with subcategories, ^##_ will specify all of its subcategories (and sub-subs etc.).
One step more detailed, for any subcategory (23_42), ^23_42$ will specify only that subcategory. THis can be extended as desired.
You can string any number of these specifications together with | between them, and if any one of them is true, ereg will return true.

Since in this case we want to execute if not in these categories, we add ! in front of ereg which says "f ereg is false, return true; if ereg is true, return false".

THis bit of logic can be embedded in any PHP statement where true or false is being evaluated on a category/product page.

:shocking: is that something I have to understand TOO!!!

I knew, when I 'finished" my store in less then a week, it was too good to be true!:unsure:

If you're online and have some time, please email me and let me know if you have any sort of IMs. If I can just wrap my blonde brain around it, I will get it eventually. I'm just SOOOO scared to mess with what is already working that it kept me awake all last night .

I try to calm down, we have new kittens in the house, so I go and hold one, but the minute I live the "nursery", I break out in a cold sweat cause I'm worried about getting this to work correctly.
I was so happy that I thought all I had to do was just start adding stock.... I was wrong :(.

I'm going to go read over your posts (again and again) and see if anything starts to gel.
Thanks!
Lalla
www.LilleyPadGifts.com
www.NothingButRomance.com

13 May 2007, 9:44 PM
#16
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removed Qty Box, now want it back for some

OK, Tim, don't worry! Bite-size chunks coming up ;)

I included the full explanation for those who want to apply the logic to other situations; for you both, you can use what I have posted essentially as is.

Working in /includes/templates/your_template/templates/tpl_product_info_display.php, find this section ```php

<!--bof Product Price block --> <h2 id="productPrices" class="productGeneral"> <?php // base price if ($show_onetime_charges_description == 'true') { $one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />'; } else { $one_time = ''; } echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']); ?></h2> <!--eof Product Price block --> ``` and add <?php if (!ereg("(^23$|^23_)",$cPath)) { ?>

and

<?php } ?>

to get ```php

<!--bof Product Price block --> <?php if (!ereg("(^23$|^23_)",$cPath)) { ?><!--no price in gallery --> <h2 id="productPrices" class="productGeneral"> <?php // base price if ($show_onetime_charges_description == 'true') { $one_time = '<span >' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span><br />'; } else { $one_time = ''; } echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']); ?></h2> <?php } ?><!--/no price in gallery --> <!--eof Product Price block --> ``` Change 23 to your gallery category id, and the price will not be shown on any product viewed in the gallery.
13 May 2007, 9:45 PM
#17
lilleypadgifts avatar

lilleypadgifts

Totally Zenned

Join Date:
Jan 2007
Location:
Southern California
Posts:
550
Plugin Contributions:
0

Re: Removed Qty Box, now want it back for some

were we typing at the same time or what? LMAO!

13 May 2007, 9:53 PM
#18
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removed Qty Box, now want it back for some

Lalla, if you post a list of the category ids you want to skip the qty on, I will show you how the full testing list will look. You can take that as an example when you want toadd another category to the list.

13 May 2007, 9:57 PM
#19
lilleypadgifts avatar

lilleypadgifts

Totally Zenned

Join Date:
Jan 2007
Location:
Southern California
Posts:
550
Plugin Contributions:
0

Re: Removed Qty Box, now want it back for some

gjh42:

Lalla, if you post a list of the category ids you want to skip the qty on, I will show you how the full testing list will look. You can take that as an example when you want toadd another category to the list.

Ok, cool :smile: ,
From the cat's I have showing now, it would be the following that should NOT show a qty because they are treated as individual items.

1 - Comics
2 - Salt & Pepper Shakers
3- Postcards
22- Lucy & Me Bears

Thanks so much!

13 May 2007, 10:13 PM
#20
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Removed Qty Box, now want it back for some

The other categories besides Comics don't have subcats, so I will include the simplest form of the test.

(^1$|^1_|^2$|^3$|^22$)

<?php echo (((!ereg("(^1$|^1_|^2$|^3$|^22$)",$cPath)) and $flag_show_product_info_quantity == 1 and $products_quantity >0) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>'  : '') . "\n"; ?> 

If you want to include another top cat which has subcats (say id 27), you would add it to the above list like this:

(^1$|^1_|^2$|^3$|^22$|^27_)