Topic RSS
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.
In "single.php", here are the lines you're going to copy and modify:
add this immediately after:
Next, find this:
add this immediately after:
Next, find this:
for ($i = 0; $i < count($colorlistdata); $i++) {
$colorlistoptions = explode("@", $colorlistdata[$i]);
$colorlist[$i] = $colorlistoptions[0];
$colorlistprice[$i] = $colorlistoptions[1];
}
add this immediately after:
for ($i = 0; $i < count($colorlistdata2); $i++) {
$colorlistoptions2 = explode("@", $colorlistdata2[$i]);
$colorlist2[$i] = $colorlistoptions2[0];
$colorlistprice2[$i] = $colorlistoptions2[1];
}
Next, find this:
<?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:
<?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:
<?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:
<?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:
<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:
<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:
Add this immediately after:
Next, find the line:
Add this immediately after:
Next, find the line:
Add this immediately after:
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:
Add this immediately after:
(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:
Add this immediately after:
(Note: Again, you can make change the text to say whatever you like. )
Now, locate the line:
Add this immediately after:
(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.
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
Let's continue the "text box" topic on this other thread:
http://www.markettheme.com/for…..a/text-box
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!
3:05 am
August 3, 2011
OfflineI 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.
4:28 pm
August 3, 2011
OfflineI 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?
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.
5:34 pm
August 3, 2011
OfflineYep 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!
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
Most Users Ever Online: 40
Currently Online:
21 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Member Stats:
Guest Posters: 428
Members: 2252
Moderators: 1
Admins: 1
Forum Stats:
Groups: 1
Forums: 4
Topics: 2983
Posts: 16042
Newest Members: Allsed, deleteduser, shanm, slidesketch, jimharrison, vmi
Moderators: Market Admin (5051)
Administrators: Market Admin (5051)

Log In
Register
Home





