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

  • SEARCH
  • Home
  • 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 1107037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:52:50+00:00 2026-05-17T01:52:50+00:00

I have one certain product that needs to be in the cart under certain

  • 0

I have one certain product that needs to be in the cart under certain circumstances. I have been looking at the Ubercart api documentation and I don’t see any hooks that would be the obvious place to see if a certain item exists prior to checkout.

I could use the hook_add_to_cart hook to add the special item whenever the first item is added, but I’m concerned that the visitor may remove the item and then complete the purchase without the required item.

Any suggestions how to make sure the special item is in the cart on checkout?

  • 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-05-17T01:52:51+00:00Added an answer on May 17, 2026 at 1:52 am

    You can have a module and run something like:

    function mymodule_init() {
       if (preg_match('/checkout/', request_uri()) {
          $items = uc_cart_get_contents();
          foreach ($items as $item) {
             // code
          }
       }
    }
    

    That will fire up on the checkout page, and fetch the cart contents. Everytime they hit the checkout page, uc_cart_get_contents() returns the cart contents.

    http://www.ubercart.org/docs/api/uc_cart_get_contents

    There are probably better ways to do what you want to do though, like using a Conditional Action to prevent checkout if Item B is in the cart but Item A is not. You can also look at Product Kits, but I don’t have much experience with that.

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

Sidebar

Related Questions

I've got an inventory table that needs to have certain in each row, and
I have one question; In my ASP.NET MVC web application have to do certain
I have a Java application which requires certain software (one of them being Perl)
So I have a TreeView like the one below, with certain items being hidden.
have one time consuming step that flattens a bunch of files. basically i'd like
I have one table that has sales records and another table that has additional
Supposing I have a merge module that installs a file MyFile.txt to a certain
I have an appliction right now that is a pipeline design. In one the
I'm looking for a best practice solution.... I have table that holds products called
When you have 2 appenders, say one for debug errors and one for product

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.