The following are instructions regarding the use of multiple attributes with Market. Please send any questions to the Market Theme forums.
If you have not made any significant changes to your Market 3 install, download the Market 3 Multiple Attributes theme package from the Download Center. This compressed file has done all the work for you and includes the Market Product Manager 1.5 beta which allows you to easily use Multiple Attributes with your products. If you have made customizations to your theme and do not wish to overwrite, there are some quick instructions below to get multiple attributes working for you.
"</head>" tag. (If for some reason copying and pasting from this screen doesn't work, copy and paste from the javascript source text file):
<!-- --------------------Begin Multiple Attributes Code ------------------- -->
<script type="text/javascript">
<!--
function Dollar (val) { // force to valid dollar amount
var str,pos,rnd=0;
if (val < .995) rnd = 1; // for old Netscape browsers
str = escape (val*1.0 + 0.005001 + rnd); // float, round, escape
pos = str.indexOf (".");
if (pos > 0) str = str.substring (rnd, pos + 3);
return str;
}
function ReadForm (obj1) { // process selects
var i,j,amt=0,des="",obj,pos,tok,val,
op1a="",op1b="",op2a="",op2b="",itmn="";
var ary = new Array ();
if (obj1.baseamt) amt = obj1.baseamt.value*1.0; // base amount
if (obj1.basedes) des = obj1.basedes.value; // base description
if (obj1.baseon0) op1a = obj1.baseon0.value; // base options
if (obj1.baseos0) op1b = obj1.baseos0.value;
if (obj1.baseon1) op2a = obj1.baseon1.value;
if (obj1.baseos1) op2b = obj1.baseos1.value;
if (obj1.baseitn) itmn = obj1.baseitn.value;
for (i=0; i<obj1.length; i++) { // run entire form
obj = obj1.elements[i]; // a form element
if (obj.type == "select-one") { // just get selects
if (obj.name == "quantity" || // don't mess with these
obj.name == "amount") continue;
pos = obj.selectedIndex; // which option selected
val = obj.options[pos].value; // selected value
ary = val.split (" "); // break apart
for (j=0; j<ary.length; j++) { // look at all items
// first we do single character tokens...
if (ary[j].length < 2) continue;
tok = ary[j].substring (0,1); // first character
val = ary[j].substring (1); // get data
if (tok == "@") amt = val * 1.0;
if (tok == "+") amt = amt + val*1.0;
if (tok == "%") amt = amt + (amt * val/100.0);
if (tok == "#") { // record item number
if (obj1.item_number) obj1.item_number.value = val;
ary[j] = ""; // zap this array element
}
// Now we do 3-character tokens...
if (ary[j].length < 4) continue;
tok = ary[j].substring (0,3); // first 3 chars
val = ary[j].substring (3); // get data
if (tok == "s1=") { // value for shipping
if (obj1.shipping) obj1.shipping.value = val;
ary[j] = ""; // clear it out
}
if (tok == "s2=") { // value for shipping2
if (obj1.shipping2) obj1.shipping2.value = val;
ary[j] = ""; // clear it out
}
}
val = ary.join (" "); // rebuild val with what's left
if (obj.name == "on0" || // let these go where they want
obj.name == "os0" ||
obj.name == "on1" ||
obj.name == "os1") continue;
tag = obj.name.substring (obj.name.length-2); // get flag
if (tag == "1a") op1a = op1a + " " + val; // stuff data
else if (tag == "1b") op1b = op1b + " " + val;
else if (tag == "2a") op2a = op2a + " " + val;
else if (tag == "2b") op2b = op2b + " " + val;
else if (tag == "3i") itmn = itmn + " " + val;
else if (des.length == 0) des = val;
else des = des + ", " + val;
}
}
// Now summarize stuff we just processed, above
if (op1a.length > 0) obj1.on0.value = op1a; // stuff it away
if (op1b.length > 0) obj1.os0.value = op1b;
if (op2a.length > 0) obj1.on1.value = op2a;
if (op2b.length > 0) obj1.os1.value = op2b;
if (itmn.length > 0) obj1.item_number.value = itmn;
obj1.item_name.value = des;
obj1.amount.value = Dollar (amt);
if (obj1.tot) obj1.tot.value = "$" + Dollar (amt);
}
//-->
</script>
<!-- --------------------End Multiple Attributes Code ------------------- -->
<div class="buy">. Replace everything from and including this opening <div class"buy> tag, all the way to the closing </div> tag.
<div class="buy">
<form class="lsf" action="https://www.paypal.com/cgi-bin/webscr" method="post"
onsubmit="this.target = 'paypal'; ReadForm (this);">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="amount" value="" />
<input type="hidden" name="business" value="<?php bloginfo('admin_email'); ?>">
<input type="hidden" name="item_name" value="<?php the_title(); ?>">
<input type="hidden" name="return" value="<?php bloginfo('url'); ?>">
<input type="hidden" name="cancel_return" value="<?php bloginfo('url'); ?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="shipping" value="1" />
<input type="hidden" name="shipping2" value="2" />
<input type="hidden" name="baseamt" value="1.00" />
<input type="hidden" name="basedes" value="<?php the_title(); ?>" />
<input type="hidden" name="on0" value="" />
<input type="hidden" name="os0" value="" />
<input type="hidden" name="on1" value="" />
<input type="hidden" name="os1" value="" />
<input type="hidden" name="item_number" value="" />
<input type="hidden" name="baseitn" value="" />
<table>
<tr>
<td>Image Size:<br />
<td><select class="field" onchange = "ReadForm (this.form);">
<option value="<?php echo $options1; ?> s1=<?php echo $shipping; ?> s2=0 @<?php echo $sprices1; ?>">Small ($<?php echo $sprices1; ?>)</option>
<option value="<?php echo $options2; ?> s1=<?php echo $shipping; ?> s2=0 @<?php echo $sprices2; ?>">Medium ($<?php echo $sprices2; ?>)</option>
<option value="<?php echo $options3; ?> s1=<?php echo $shipping; ?> s2=0 @<?php echo $sprices3; ?>">Original Size ($<?php echo $sprices3; ?>)</option>
</select></td>
</tr>
</table>
<input type="image" src="<?php bloginfo('template_directory'); ?>/imgs/bn.gif" class="pp" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
<!--Start Vcart Code-->
<form class="crtAdd rsf" method="post" action="<?php bloginfo('template_directory'); ?>/ajCart/cart.php" >
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<input type="hidden" name="amount" value="" />
<input type="hidden" name="quantity" value="1">
<input type="hidden" name="business" value="<?php bloginfo('admin_email'); ?>">
<input type="hidden" name="item_name" value="<?php the_title(); ?>">
<input type="hidden" name="handling" value="" />
<input type="hidden" name="handling_cart" value="" />
<input type="hidden" name="on0" value="Shipping" />
<input type="hidden" name="shipping" value="1" />
<input type="hidden" name="shipping2" value="2" />
<input type="hidden" name="os0" value="" />
<input type="hidden" name="lc" value="US">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="<?php bloginfo('url'); ?>">
<input type="hidden" name="cancel_return" value="<?php bloginfo('url'); ?>">
<input type="hidden" name="baseon0" value="Image Size" />
<input type="hidden" name="baseos0" value="" />
<input type="hidden" name="baseitn" value="" />
<input type="hidden" name="baseamt" value="1.00" />
<input type="hidden" name="basedes" value="<?php the_title(); ?>" />
<table>
<tr>
<td>Image Size:<br />
<td><select class="field" onchange = "ReadForm (this.form);">
<option value="<?php echo $options1; ?> s1=<?php echo $shipping; ?> s2=0 @<?php echo $sprices1; ?>">Small ($<?php echo $sprices1; ?>)</option>
<option value="<?php echo $options2; ?> s1=<?php echo $shipping; ?> s2=0 @<?php echo $sprices2; ?>">Medium ($<?php echo $sprices2; ?>)</option>
<option value="<?php echo $options3; ?> s1=<?php echo $shipping; ?> s2=0 @<?php echo $sprices3; ?>">Original Size ($<?php echo $sprices3; ?>)</option>
</select></td>
</tr>
</table>
<input type="image" src="<?php bloginfo('template_directory'); ?>/imgs/atc.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
<!--End Vcart Code-->
<div style="clear: both"></div>
</div>
Adding more multiple attributes can be done. I will not assist each and every case, so it is up to you to make the required changes. I'll outline how to add additional multiple attribute fields below, but you must make the changes for yourself. The default setup of multiple attributes has just one drop down, can be used to specify whatever you may like and a matching price. You may want two, three, or even more options and dropdowns, for example the colors, sizes, and styles of piece of clothing. The color could set the base price, the size could increase it by a few bucks, and the style could increase it by a few more. There are an unlimited amount of ways you could put the multiple attributes to work for you. Read this guide and view the source of single.php to get a better idea of how to add the actual fields themselves.
After adding the fields themselves to single.php, you'll probably want to be able to control these items via the Market Product Manager. Adding them is not that hard.
mycustomattribut1 = get_post_meta($post->ID, 'mycustomattribute1', $single = true);
< input type="text" name="mycustomattribut" id="
mycustomattribut" value="< ?php echo $
mycustomattribut; ? >" scrolling="auto" cols="30" rows="4" tabindex="10" >delete_post_meta($id, 'options1');. Once again, follow the format to add lines for your custom fields, placing them in the same order as they appear in the postbox bit. Same thing for a few lines under that where you'll add post meta data by following the format already there in the code for you.If you wish to use the size and or color list dropdowns without price differences for each, Add whichever code below you may need above the following < tr >< td >Image Size:< /td > in both the add to cart button and the buy now button (it will appear twice in single.php)
<?php if (!empty($size)){
echo "
<td><input type=\"hidden\" name=\"on0\" value=\"Size\"/>
Size:</td>
<td><select name=\"os0\" class=\"field\" >
<option value=\"$sizelist[0]\">$sizelist[0]</option>";
if (isset($sizelist[1])) { echo "<option value=\"$sizelist[1]\">$sizelist[1]</option>"; }
if (isset($sizelist[2])) { echo "<option value=\"$sizelist[2]\">$sizelist[2]</option>"; }
if (isset($sizelist[3])) { echo "<option value=\"$sizelist[3]\">$sizelist[3]</option>"; }
if (isset($sizelist[4])) { echo "<option value=\"$sizelist[4]\">$sizelist[4]</option>"; }
if (isset($sizelist[5])) { echo "<option value=\"$sizelist[5]\">$sizelist[5]</option>"; }
if (isset($sizelist[6])) { echo "<option value=\"$sizelist[6]\">$sizelist[6]</option>"; }
if (isset($sizelist[7])) { echo "<option value=\"$sizelist[7]\">$sizelist[7]</option>"; }
if (isset($sizelist[8])) { echo "<option value=\"$sizelist[8]\">$sizelist[8]</option>"; }
if (isset($sizelist[9])) { echo "<option value=\"$sizelist[9]\">$sizelist[9]</option>"; }
if (isset($sizelist[10])) { echo "<option value=\"$sizelist[10]\">$sizelist[10]</option>"; }
echo " </select>
</td>"; } ?>
</tr>
Color List
<tr>
<td><?php if (!empty($color)){
echo "<input type=\"hidden\" name=\"on1\" value=\"Color\"/>
Color:</td>
<td><select name=\"os1\" class=\"field\">
<option value=\"$colorlist[0]\">$colorlist[0]</option>";
if (isset($colorlist[1])) { echo "<option value=\"$colorlist[1]\">$colorlist[1]</option>"; }
if (isset($colorlist[2])) { echo "<option value=\"$colorlist[2]\">$colorlist[2]</option>"; }
if (isset($colorlist[3])) { echo "<option value=\"$colorlist[3]\">$colorlist[3]</option>"; }
if (isset($colorlist[4])) { echo "<option value=\"$colorlist[4]\">$colorlist[4]</option>"; }
if (isset($colorlist[5])) { echo "<option value=\"$colorlist[5]\">$colorlist[5]</option>"; }
if (isset($colorlist[6])) { echo "<option value=\"$colorlist[6]\">$colorlist[6]</option>"; }
if (isset($colorlist[7])) { echo "<option value=\"$colorlist[7]\">$colorlist[7]</option>"; }
if (isset($colorlist[8])) { echo "<option value=\"$colorlist[8]\">$colorlist[8]</option>"; }
if (isset($colorlist[9])) { echo "<option value=\"$colorlist[9]\">$colorlist[9]</option>"; }
if (isset($colorlist[10])) { echo "<option value=\"$colorlist[10]\">$colorlist[10]</option>"; }
echo "
</select>
</td>"; } ?>
</tr>