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 8256499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:52:41+00:00 2026-06-08T01:52:41+00:00

Code below is part of cart66 WordPress plugin’s php file. When I list options

  • 0

Code below is part of cart66 WordPress plugin’s php file. When I list options of my items for example,

T-shirt
Quantity: 1
Option: Red, Yellow, Blue

First option is always what I put first in the list. Therefore, when my customers don’t pay an attention and add to cart without looking at the list they order red. I added “Please choose a pattern” option at the top but they still add that to cart and checkout. Is there a way of adding an option and making it give an error in case that option is selected ?

  private function _buildOptionList($optNumber) {
    $select = '';
    $optionName = "options_$optNumber";
    if(strlen($this->$optionName) > 1) {
      $select = "\n<select name=\"options_$optNumber\" id=\"options_$optNumber\" class=\"cart66Options options_$optNumber\">";
      $opts = split(',', $this->$optionName);
      foreach($opts as $opt) {
        $opt = str_replace('+$', '+ $', $opt);
        $opt = trim($opt);
        $optDisplay = str_replace('$', CART66_CURRENCY_SYMBOL, $opt);
        $select .= "\n\t<option value=\"" . htmlentities($opt) . "\">$optDisplay</option>";
      }
      $select .= "\n</select>";
    }
    return $select;
  }
  • 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-08T01:52:42+00:00Added an answer on June 8, 2026 at 1:52 am

    You could use jQuery and Javascript to show an alert box.

    <script type="text/javascript">
        $(function() {
            $('#options').change(function() {
                if ($(this).attr('value') == "Please choose a pattern") {
                    alert("Please pick a color!");
                }
            });
        });
    </script>
    

    Make sure to include a recent copy of jQuery in your page, and change the id=”” value of the selectbox to options (without any PHP variable).

    Also, don’t forget to still check in PHP if the user submitted a valid color. Do this because if the user has Javascript disabled, he will still be able to choose the ‘please choose a pattern’ item.

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

Sidebar

Related Questions

Please look at the example code below, when I run it, the defined part
All the code/commands below are part of a PHP script that processes images from
Please review the example code below, I have a class file that is loaded
The code below is part of an rss feed parser using WordPress's simplepie fetch_feed()...
For example, code below, the arrow pointing two part, can the second one use
I have part of the code below: while($array = $result->fetch_assoc() ){ $second_query = INSERT
In the code below, I think I messed up this part: if ( (1
20120315021529.000[-8:PST] to get the first part I was able by using below C# code.
Below, I inserted a code written by Ray Konopka (part of the Coderage presentation).
I have the code below to make part of my rss feed a hyperlink

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.