A A A
Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 4 characters - maximum search word length is 84 characters

No permission to create posts
sp_Feed Topic RSS sp_TopicIcon
How to add an extra option box to Market 4.0
June 24, 2010
2:51 pm
Avatar
Admin
Forum Posts: 5856
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

Some of you have asked how to add an additional option dropdown box to the Market Theme website and admin area. 

Here's how:

 

Most of the code is still the same for version 4.0, however the Market Product Manager plugin has actually been integrated into the Market theme "functions.php" file, so it's actually a little easier.

I believe there are only a couple of files you'll need to modify with version 4.0 -- they are:

single.php

functions.php

language/english.php

 

In essence -- what you're going to do is find all of the option items related to "color", and then copy them and change the variable names and increment some "os" and "on" numbers.

 

***************************************************************
For versions 4.2 and higher, jump down to post #31 for updated instructions
http://www.markettheme.com/for.....e-2#p19590

***************************************************************

 

For version 4.0 and 4.1, perform the following code modifications:

In "single.php", here are the lines you're going to copy and modify:

 

$color = get_post_meta($post->ID, 'color', $single = true); // check items color

 

add this immediately after:

 

$color2 = get_post_meta($post->ID, 'color2', $single = true); // check items color

 

Next, find this:

 

$colorlist = explode(",", $color);

 

add this immediately after:

 

$colorlist2 = explode(",", $color2);

Next, find this:

 

$colorlistdata = explode(",", $color);
for ($i = 0; $i < count($colorlistdata); $i++) {
    $colorlistoptions = explode("@", $colorlistdata[$i]);    
    $colorlist[$i] = $colorlistoptions[0];
    $colorlistprice[$i] = $colorlistoptions[1];
}

 

add this immediately after:

 

$colorlistdata2 = explode(",", $color2);
 for ($i = 0; $i < count($colorlistdata2); $i++) {
     $colorlistoptions2 = explode("@", $colorlistdata2[$i]);    
     $colorlist2[$i] = $colorlistoptions2[0];
     $colorlistprice2[$i] = $colorlistoptions2[1];
 }

 

Next, find this:

 

        <tr>
           <?php if (!empty($color)){             echo '<td><input type="hidden" name="on1" value="'.mkt_THEME_SINGLE_LABEL_COLOR.'"/>'.mkt_THEME_SINGLE_LABEL_COLOR.':</td>
                    <td><select id="os1" name="os1" class="field">';                for($i=0; $i<count($colorlist); $i++){                 echo "<option value='$colorlist[$i]'>$colorlist[$i]</option>";
            }                    echo '</select></td>'; 
            } ?>
        </tr>         <tr><td colspan="2"><br></td></tr>

 

add this immediately after:

 

        <tr>
           <?php if (!empty($color2)){

            echo '<td><input type="hidden" name="on2" value="'.mkt_THEME_SINGLE_LABEL_COLOR2.'"/>'.mkt_THEME_SINGLE_LABEL_COLOR2.':</td>
                    <td><select id="os2" name="os2" class="field">';
              
               for($i=0; $i<count($colorlist2); $i++){
                echo "<option value='$colorlist2[$i]'>$colorlist2[$i]</option>";
            }         
            
            echo '</select></td>';
            } ?>
        </tr>

        <tr><td colspan="2"><br></td></tr>

Next, find this:

        <tr>
           <?php if (!empty($color)){

            echo '<td><input type="hidden" name="on1" value="'.mkt_THEME_SINGLE_LABEL_COLOR.'"/>'.mkt_THEME_SINGLE_LABEL_COLOR.':</td>
                    <td><select id="os1" name="os1" class="field">';
              
               for($i=0; $i<count($colorlist); $i++){
                if ($colorlistprice[$i]) {
                    if ($colorlistprice[$i]>0) {
                        $optiontext = " (+";
                    } else {
                        $optiontext = " (-";
                    }
                    $optiontext = $optiontext . $CURRENCY_SYMBOL.number_format(abs($colorlistprice[$i]), 2, '.', ',');
                    $optiontext = $optiontext .")";
                } else {
                    $optiontext = "";
                }
                echo "<option value='$colorlist[$i]@$colorlistprice[$i]'>$colorlist[$i] $optiontext</option>";
            }         
            
            echo '</select></td>';
            } ?>
        </tr>
        
        <tr><td colspan="2"><br></td></tr>

 

add this immediately after:

 

        <tr>
           <?php if (!empty($color2)){

            echo '<td><input type="hidden" name="on2" value="'.mkt_THEME_SINGLE_LABEL_COLOR2.'"/>'.mkt_THEME_SINGLE_LABEL_COLOR2.':</td>
                    <td><select id="os2" name="os2" class="field">';
              
               for($i=0; $i<count($colorlist2); $i++){
                if ($colorlistprice2[$i]) {
                    if ($colorlistprice2[$i]>0) {
                        $optiontext = " (+";
                    } else {
                        $optiontext = " (-";
                    }
                    $optiontext = $optiontext . $CURRENCY_SYMBOL.number_format(abs($colorlistprice2[$i]), 2, '.', ',');
                    $optiontext = $optiontext .")";
                } else {
                    $optiontext = "";
                }
                echo "<option value='$colorlist2[$i]@$colorlistprice2[$i]'>$colorlist2[$i] $optiontext</option>";
            }         
            
            echo '</select></td>';
            } ?>
        </tr>
        
        <tr><td colspan="2"><br></td></tr>

Save the file.

 

Now...  changes to the "functions.php" file.  So, open it for editing.

All of the changes will be made after the section titled

************************* Product Manager functions ****************************

on or around line # 1417.

First, you'll find on or around line 1514 the line:

    $color = get_post_meta($post->ID, 'color', $single = true);

Immediately after this, add the following:

    $color2 = get_post_meta($post->ID, 'color2', $single = true);

Now, on or around line #1602 you'll find this:
 

       <div class="postbox">
          <h3 style="font-weight: normal;"><?php echo mkt_ADMIN_ADD_PRODUCT_COLORS; ?></h3>
           <div class="inside">
            <table style="text-align: left;">
            <tr>
                <td><input tabindex="1" type="text" name="color" id="color" value="<?php echo htmlentities($color, ENT_QUOTES); ?>"  scrolling="auto" cols="30" rows="4" tabindex="9"></td><td valign="top" style="font-size: 11px;"><?php echo mkt_ADMIN_ADD_PRODUCT_COLORS_EXAMPLE1; ?><br/><br/><?php echo mkt_ADMIN_ADD_PRODUCT_COLORS_EXAMPLE2; ?></td>
                
                </tr>
                </table>
               </div>
      </div> 

Immediately after it, enter this:
 

       <div class="postbox">
          <h3 style="font-weight: normal;"><?php echo mkt_ADMIN_ADD_PRODUCT_COLORS2; ?></h3>
           <div class="inside">
            <table style="text-align: left;">
            <tr>
                <td><input tabindex="1" type="text" name="color2" id="color2" value="<?php echo htmlentities($color2, ENT_QUOTES); ?>"  scrolling="auto" cols="30" rows="4" tabindex="9"></td><td valign="top" style="font-size: 11px;"><?php echo mkt_ADMIN_ADD_PRODUCT_COLORS2_EXAMPLE1; ?><br/><br/><?php echo mkt_ADMIN_ADD_PRODUCT_COLORS2_EXAMPLE2; ?></td>
                
                </tr>
                </table>
               </div>
      </div> 

Next, scroll down until you find this on or around line #1667:

 

    $color = stripslashes($_POST["color"]);

Add this immediately after:

 

    $color2 = stripslashes($_POST["color2"]);

Next, find the line:

 

    delete_post_meta($id, 'color');

Add this immediately after:

 

    delete_post_meta($id, 'color2');

 

Next, find the line:

 

    add_post_meta($id, 'color', $color);

Add this immediately after:

 

    add_post_meta($id, 'color2', $color2);

Save the file.

 

Now, the last step is to update the language file.  (We'll do this for english, however you'll need to do it for German, italian, etc. if you want to use those languages.)

So, open up the file "english.php" located in the "language/" folder.

Locate the line:

 

define('mkt_THEME_SINGLE_LABEL_COLOR', 'Color');

Add this immediately after:

 

define('mkt_THEME_SINGLE_LABEL_COLOR2', 'Extra Color');

(Note: you may change the text "Extra Color" to anything you desire.  This is the text that will display on the website to the customer, so name it something meaningful to them, such as "bottom color" or "inside color" or whatever.  You can even name it something unrelated to color like "Capacity".  The code behind the scenes can say "color2" and it won't matter.  Only the text from this language file will be visible to users, so this is where you customize what the extra option box is used for.)

 

Now, locate the line:

 

define('mkt_ADMIN_ADD_PRODUCT_COLORS_EXAMPLE1', '<span class="mpm_infoblue">Separate colors with a comma.</span><br />For Example: <b>Red,White,Blue</b>');

 

Add this immediately after:

 

define('mkt_ADMIN_ADD_PRODUCT_COLORS2_EXAMPLE1', 'Place any text you desire in here - this is the instructions area for adding the option');

(Note:  Again, you can make change the text to say whatever you like.  )

 

Now, locate the line:

 

define('mkt_ADMIN_ADD_PRODUCT_COLORS_EXAMPLE2', '<span class="mpm_infored">For option upcharge or discount, use a "@" symbol followed by price variance.</span><br />For Example: <b>Red@-1.25,White,Blue@1.50</b>');

 

Add this immediately after:

 

define('mkt_ADMIN_ADD_PRODUCT_COLORS2_EXAMPLE2', 'Place any text you desire in here - same applies as above');

 

(Note:  Again, you can make change the text to say whatever you like.  )

 

Save the file, and upload all the files. 

 

I believe that should do it.

July 18, 2010
10:04 am
Avatar
ibfishn
Member
Members
Forum Posts: 9
Member Since:
June 5, 2010
sp_UserOfflineSmall Offline

Can you add 2 additional option boxes?

July 21, 2010
7:56 pm
Avatar
Admin
Forum Posts: 5856
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

Yes, but you'll need to change variable names.  (ie. Everywhere it says "color2", make it say "color3",  --   Where it says "colorlist2", make it say "colorlist3", etc.)

Also, "os2" will become "os3".

It's basically the same changes, but with different variables.

July 23, 2010
1:13 pm
Avatar
ibfishn
Member
Members
Forum Posts: 9
Member Since:
June 5, 2010
sp_UserOfflineSmall Offline

outstanding!

July 30, 2010
8:33 am
Avatar
New Member
Members
Forum Posts: 1
Member Since:
July 30, 2010
sp_UserOfflineSmall Offline

tried this, but doesn't work

new custom field shows, but doesn't register once saved

July 30, 2010
5:17 pm
Avatar
Admin
Forum Posts: 5856
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

You must be missing a copied line somewhere.  Just do a search for the word "color", and try to duplicate all of the lines that shows up in, and then name them as a different variable.

March 28, 2011
10:39 am
Avatar
ericab
Member
Members
Forum Posts: 23
Member Since:
July 5, 2010
sp_UserOfflineSmall Offline

Will this work if you are using 4.1?

I did everything you mentioned above but under English.php there was no line that read define('mkt_THEME_SINGLE_LABEL_COLOR2', 'Color');

 

Now when I add items to the cart, the cart shows blank.

March 28, 2011
11:59 am
Avatar
Admin
Forum Posts: 5856
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

You'll need to add that line to English.php, as it's a new label that wasn't there before your modification.

 

If your cart is now showing blank, when it DID show before -- then my guess is that you added a single quote somewhere in your editing of "English.php".

 

Single quotes (and apostrophes), need to be preceeded by a backslash "\" character so that they are not viewed as part of the code.

 

Like this:  

 

    won\'t

 

Not like this:

 

    won't

March 28, 2011
2:05 pm
Avatar
ericab
Member
Members
Forum Posts: 23
Member Since:
July 5, 2010
sp_UserOfflineSmall Offline

It works now. I didn't add anything incorrectly I guess. It was the mod security issue. Hostgator cleared it all up. Thanks.

April 7, 2011
8:09 am
Avatar
Member
Members
Forum Posts: 156
Member Since:
February 27, 2011
sp_UserOfflineSmall Offline

Can we do this but have a box that the customer can write in instead of choices to pick?

April 7, 2011
12:42 pm
Avatar
Admin
Forum Posts: 5856
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

Let's continue the "text box" topic on this other thread:

http://www.markettheme.com/for.....a/text-box

April 7, 2011
12:51 pm
Avatar
Member
Members
Forum Posts: 156
Member Since:
February 27, 2011
sp_UserOfflineSmall Offline

oh, so sorry - I didn't realize I had already asked Surprised

July 21, 2011
7:17 am
Avatar
rrsales
Member
Members
Forum Posts: 4
Member Since:
July 18, 2011
sp_UserOfflineSmall Offline

Since this is a pretty useful feature for anyone that runs a shopping cart, why does'nt this theme come with this feature? Instead of giving people directions how to add this custom code to their site why not just make it part of the features? Example

In the settings area give the option to have as many drop down option boxes as one needs. Also why don't you add a way that the options are saved so your customers do not have to copy this same information over and over? I have had to copy the same options over and over for several products. However if this was an option then all I would have to do is choose this same option from a drop down menu. It's a very simple and streight forward theme and cart but you could do much more with it!

July 21, 2011
4:29 pm
Avatar
Admin
Forum Posts: 5856
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

It's easier said than done.

Market is a continuous work in progress, and is advancing more and more as time goes on.

Thanks for the feedback.

January 2, 2012
3:05 am
Avatar
New Hampshire
Member
Members
Forum Posts: 144
Member Since:
August 3, 2011
sp_UserOfflineSmall Offline

I have made all these changes and pages still will not render.  I have searched high and low for the issue in the three files and I have not found any issues that I can readily see.  :(.  Everything looks fine on the edit pages the new fields all show up, but the pages will all not open with a 500 server error now.

 

I did notice that in one section you call out:

<div class="postbox">

          <h3 style="font-weight: normal;"><?php echo mkt_ADMIN_ADD_PRODUCT_COLORS; ?></h3>

           <div class="inside">

            <table style="text-align: left;">

            <tr>

                <td><input tabindex="1" type="text" name="color" id="color" value="<?php echo htmlentities($color, ENT_QUOTES); ?>"  scrolling="auto" cols="30" rows="4" tabindex="9"></td><td valign="top" style="font-size: 11px;"><?php echo mkt_ADMIN_ADD_PRODUCT_COLORS_EXAMPLE1; ?><br/><br/><?php echo mkt_ADMIN_ADD_PRODUCT_COLORS_EXAMPLE2; ?></td>

                

                </tr>

                </table>

               </div>

      </div>

 

but what I actually found is:

<div id="adminaddcolor" class="postbox">

 

The code above does not show the id="" section nor in the copied sectin.  Is there additional code that is missing in this document for 4.28 specifically?  I am at a total loss after 4 hours.

StitchTek Services, LLC is the parent company for the following websites http://www.jaquilting.com (Market Theme Site) http://www.chriscolotti.us
January 2, 2012
4:28 pm
Avatar
New Hampshire
Member
Members
Forum Posts: 144
Member Since:
August 3, 2011
sp_UserOfflineSmall Offline

I did get this working, just started over. 

 

I am curious how you increase the size of the text box in the editor?  All this appears as though it should be the same as the color field but I would like to extend the box to be longer.  When line of code is it?

StitchTek Services, LLC is the parent company for the following websites http://www.jaquilting.com (Market Theme Site) http://www.chriscolotti.us
January 6, 2012
10:24 pm
Avatar
Admin
Forum Posts: 5856
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

To extend the width of the text box, you just increase the value of the "size" value in the "input" tag.  (The code is located in the functions.php file.)

 

For example:

<input tabindex="1" type="text" name="color" id="color" value="<?php echo htmlentities($color, ENT_QUOTES); ?>"  
scrolling="auto" size="30" cols="30" rows="4" tabindex="9">

 

could become

 

<input tabindex="1" type="text" name="color" id="color" value="<?php echo htmlentities($color, ENT_QUOTES); ?>"  
scrolling="auto" size="50" cols="30" rows="4" tabindex="9">

 

I hope this helps.

January 7, 2012
5:34 pm
Avatar
New Hampshire
Member
Members
Forum Posts: 144
Member Since:
August 3, 2011
sp_UserOfflineSmall Offline

Yep that helps.  I thought it was that line, but it is set the same as the one above yet they ae different lengths.  I will give it a shot but it is working awesome now for us!

StitchTek Services, LLC is the parent company for the following websites http://www.jaquilting.com (Market Theme Site) http://www.chriscolotti.us
January 24, 2012
9:04 pm
Avatar
sewgeen
Member
Members
Forum Posts: 10
Member Since:
January 23, 2012
sp_UserOfflineSmall Offline

I have taken these steps to add extra options to my site: tonyscanvas.com and once i get past 10 extra options, the rest will not register with the extra money for those options.

 

It seems it is working on a test product, but on my existing products the extra money will not register in the cart.

 

Please let me know if Ican paste in my code or email you the three files to see what I am doing wrong.  I have rechecked the code on all three files multiple times and I am positive there are no mistakes.  I am at a total loss because it worked before and we havent changed anything and now it doesnt work.

 

Thanks, Tony

January 25, 2012
12:51 am
Avatar
Admin
Forum Posts: 5856
Member Since:
March 16, 2008
sp_UserOfflineSmall Offline

In the Paypal documentation, it looks like there is a maximum limit of 7 options.

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables

No permission to create posts
Forum Timezone: UTC 0

Most Users Ever Online: 213

Currently Online:
10 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

icy1: 2636

wreed06: 175

laurie390: 169

boutiqueelliette: 156

StitchTek Services, LLC: 144

yiorgos: 127

Member Stats:

Guest Posters: 457

Members: 2468

Moderators: 1

Admins: 1

Forum Stats:

Groups: 1

Forums: 4

Topics: 4076

Posts: 18961

Newest Members: aceman, peteryoung320@gmail.com, JdsCentral, anthony775, Chaz07, ebarj

Moderators: Market Admin: 5856

Administrators: Market Admin: 5856

Market takes ecommerce to the next level with an easy to use, quick setup platform. Learn more or take the tour.