Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8828579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:38:21+00:00 2026-06-14T07:38:21+00:00

Am using the codeigniter cart library, but now the client wants users to only

  • 0

Am using the codeigniter cart library, but now the client wants users to only be able to checkout items from one category at at a time because of some issues with their payment gateway.
Current the site has a single checkout logic for all categories.
When a users adds an items to the cart, i have an array like this

Array
(
    [d8df18561040f3d9bd9868f5c5aaa7c2] => Array
        (
            [rowid] => d8df18561040f3d9bd9868f5c5aaa7c2
            [id] => MYU_SC1
            [qty] => 1
            [price] => 500
            [name] => WAEC Scratch Card
            [service_image] => assets/img/waec.jpg
            [service_category] => scratch_cards
            [subtotal] => 500
        )

    [99483fe03da62c9e98ce71232998f447] => Array
        (
            [rowid] => 99483fe03da62c9e98ce71232998f447
            [options] => Array
                (
                    [size] => 36
                    [colour] => N/A
                )

            [id] => 80433426a546064bf5f8d09a6e7fdabc
            [qty] => 1
            [price] => 5000
            [name] => Green Vee Jeans
            [service_image] => http://localhost/myunivacity/uploads/apparels/IMG_0425.JPG
            [service_category] => apparels
            [subtotal] => 5000
        )

)

how i do check if whether or not the items in the cart have same value for “service_category” element?. Thanks for the help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:38:22+00:00Added an answer on June 14, 2026 at 7:38 am

    You could go with something like this:

    <?php 
    
    $categories = array();
    
    foreach($this->cart->contents() as $cart_item) {
        if(!isSet($categories[$cart_item["service_category"]]) {
            $categories[$cart_item["service_category"]] = 1;        
        }
        else {
            $categories[$cart_item["service_category"]]++;
        }
    }
    
    print_r($categories);
    
    ?>
    

    This fills an array with a count per category

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the Cart class of CodeIgniter, basically that's just sessions. Now, Safari
I'm using CodeIgniter's Session class to manage my sessions for a cart/checkout system. The
I am using CodeIgniter to display a list of items from the database. I
I'm using CodeIgniter + Zend libraries. I want to let users upload videos to
using CodeIgniter normally one has to specify the controllers in the config/routes.php file. This
I'm using the Cart class in Codeigniter. What I want to do should (hopefully!)
Background: Using CodeIgniter with this MongoDB library . This is my first go-round with
I am using codeigniter framework for one of my PHP project. In form I
I am using codeigniter and in my library file I am storing the cookie
Using Codeigniter, any numeric data returned from my MySQL database is returned as strings.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.