Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2016
    Location
    Suffolk VA
    Posts
    590
    Plugin Contributions
    0

    Default Variable name for category quantity

    Is there a predefined variable name for the total number of products in a given category in the shopping cart? I need to tweak my usps.php code to prevent people from choosing a small flat rate box for quantities that won't fit in that. I've done this for specific product numbers and it works fine, but I now have six items in the affected category and I'd like to be able to exclude them without the program having to step through each product number one at a time. I've looked through the shopping_cart.php code but my brain is not finding it if it's in there anywhere.

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,472
    Plugin Contributions
    88

    Default Re: Variable name for category quantity

    There's no such value, to my knowledge.

  3. #3
    Join Date
    Jun 2016
    Location
    Suffolk VA
    Posts
    590
    Plugin Contributions
    0

    Default Re: Variable name for category quantity

    Any advice on how to derive it? I guess I can create an array to hold product names that fall in the desired category and then add up those quantities. Better than enumerating each one of them. But I'm open to other suggestions.

  4. #4
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,671
    Plugin Contributions
    123

    Default Re: Variable name for category quantity

    A couple of options, but definitely do not use product name - that's a field that could change at any moment.

    - Use product id
    - Use master_category id for the whole category
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  5. #5
    Join Date
    Jun 2016
    Location
    Suffolk VA
    Posts
    590
    Plugin Contributions
    0

    Default Re: Variable name for category quantity

    Sorry, sloppy writing, I do use product id. I use master_category to exclude whole categories from some shipping options (small flat rate box being one of them). But this is a situation where any two products from one specific category would be okay, but not more than two. It looks like populating an array from the shopping cart for all products that match that category id, and then testing for total quantity greater than two is the way to go.

  6. #6
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,671
    Plugin Contributions
    123

    Default Re: Variable name for category quantity

    That's what I would do.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  7. #7
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,472
    Plugin Contributions
    88

    Default Re: Variable name for category quantity

    The shopping_cart class' get_products method, $_SESSION['cart']->get_products(), should give you the basics of what you need. It returns a numerically-indexed array of associative arrays (one per product variant in the cart).

    Each of the associative arrays contains the category (e.g. $products[$i]['category']) that identifies the product's master category id. You could use that to determine how many items in that category are present in the cart.

  8. #8
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Variable name for category quantity

    Try:
    Code:
    $_SESSION['cart']->in_cart_product_total_quantity_category($the_category_id_here)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  9. #9
    Join Date
    Jun 2016
    Location
    Suffolk VA
    Posts
    590
    Plugin Contributions
    0

    Default Re: Variable name for category quantity

    Thanks, lat9 and DrByte. I'm not sure why, but I never saw your replies before. Didn't mean to ignore them.

 

 

Similar Threads

  1. Server Side Variable Name for Order Total?
    By MikeMurphyINC in forum Code Collaboration
    Replies: 4
    Last Post: 5 Mar 2014, 09:46 PM
  2. Master Categories Name variable
    By solo_400 in forum General Questions
    Replies: 10
    Last Post: 18 Dec 2013, 11:55 PM
  3. variable for category in product listing?
    By headies in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 20 Oct 2009, 02:44 PM
  4. What is the variable's name for Total?
    By kinethic in forum Managing Customers and Orders
    Replies: 2
    Last Post: 27 Jul 2006, 01:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR