Zen Cart Logo
Forums / All Other Contributions/Addons / Qty By Attribute (Beating a Dead Horse?)

Qty By Attribute (Beating a Dead Horse?)

Locked

Views: 2,199

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
23 May 2006, 9:28 PM
#1
tecbrat avatar

tecbrat

Zen Follower

Join Date:
Feb 2005
Posts:
239
Plugin Contributions:
0

Qty By Attribute (Beating a Dead Horse?)

I realize the general topic of qty by attribute has been kicked around a bit, but I saw a mod or two that were concerned with inventory control.
What I am looking for is allowing the customer to choose attribute qty such as,

fruit basket
small $25
large $45
X QTY choc covered apple slices +$1.50 each
x QTY choc covered strawberries +$1.50 each

My client even wants to vary the type of chocolate such as light, dark, or Resses Peanut Butter and Chocolate.

Do the existing mods handle this, or part of this? Am I looking in the right direction?

Thanks, TecBrat.

23 May 2006, 10:40 PM
#2
cherylkemp avatar

cherylkemp

Zen Follower

Join Date:
Mar 2006
Posts:
179
Plugin Contributions:
0

Re: Qty By Attribute (Beating a Dead Horse?)

I think the regular attributes area under the admin can handle that...you can add a ton of them and set a base price then with certain options +1.00 etc. As long as you don't need it to keep track of stock...that feature is not available yet but is supposed to be planned for the next release.

24 May 2006, 11:22 AM
#3
tecbrat avatar

tecbrat

Zen Follower

Join Date:
Feb 2005
Posts:
239
Plugin Contributions:
0

Re: Qty By Attribute (Beating a Dead Horse?)

cherylkemp:

I think the regular attributes area under the admin can handle that...you can add a ton of them and set a base price then with certain options +1.00 etc. As long as you don't need it to keep track of stock...that feature is not available yet but is supposed to be planned for the next release.

I could have a dropdown like

1 dark choc apple slice +1.50
2 dark choc apple slices +3.00
.
.
.
10 dark choc apple slices +15.00

and another like

1 milk choc apple slice +1.50
2 milk choc apple slices +3.00
.
.
.
10 milk choc apple slices +15.00

and so on, but that begins to look bad. Better if my client's customer can type a quantity for the dark choc, and a quantiy for the milk etc. Any suggestion are greatly welcome!
thanks.

24 May 2006, 1:07 PM
#4
cherylkemp avatar

cherylkemp

Zen Follower

Join Date:
Mar 2006
Posts:
179
Plugin Contributions:
0

Re: Qty By Attribute (Beating a Dead Horse?)

If you go to the options value section under catalog...you can choose the way the attributes appear...raido, dropdown, text, etc. The easiest to find out how it would all look it to just play around with it a bit. Create the product (choose price by attribute), name your options and then add attributes to the product.

26 May 2006, 2:45 PM
#5
tecbrat avatar

tecbrat

Zen Follower

Join Date:
Feb 2005
Posts:
239
Plugin Contributions:
0

Re: Qty By Attribute (Beating a Dead Horse?)

This is how I solved it. Any simpler or cleaner solutions would be appreciated by the community.

Read carfully and you'll get the understanding of how this works, (see end for more)

in admin/attributes_controller.php
find ```
$attributes_price_letters = zen_db_prepare_input($_POST['attributes_price_letters']);

in 2 places and replace with 

$att_price_let=$_POST['attributes_price_letters'];
$att_qty_price=$_POST['att_qty_price'];
if (isset($att_qty_price)){$att_price_let=10000 + $att_qty_price;}
$attributes_price_letters = zen_db_prepare_input($att_price_let);

in 2 places find
<td align="center" class="smallText" nowrap="nowrap"> <?php echo TABLE_HEADING_ATTRIBUTES_PRICE_LETTERS . ' ' . TABLE_HEADING_ATTRIBUTES_PRICE_LETTERS_FREE; ?><br /> <input type="text" name="attributes_price_letters" value="<?php echo $attributes_values->fields['attributes_price_letters']; ?>" size="6">  <input type="text" name="attributes_price_letters_free" value="<?php echo $attributes_values->fields['attributes_price_letters_free']; ?>" size="6"> </td> ``` and put ``` <!-- Attribute Qty Price will actually mock up a Text attribute. --> <td align="center" class="attributeBoxContent" nowrap="nowrap"> <?php echo 'Attribute Qty Price <br />'; ?><input type="text" name="att_qty_price" size="6"></td> ``` under it. ----------

in yourcart/includes/functions/functions_prices.php

find

// calculate letters price
  function zen_get_letters_count_price($string, $free=0, $price) {
      $letters_price = zen_get_letters_count($string, $free) * $price;
      if ($letters_price <= 0) {
        return 0;
      } else {
        return $letters_price;
      }
  }

and replace with

// calculate letters price or att qty price
  function zen_get_letters_count_price($string, $free=0, $price) {
      if ($price>10000)
       {
        $attqtyprice='flagged';
        $price=$price-10000;
       }
       $count_letters=zen_get_letters_count($string, $free);
       if ($attqtyprice=='flagged'){$count_letters=$string;} // allows a text box to be used to select a certain
                                                              // number of an attribute like 2 extra widgets.
                                                              // a bit of a hack job, but it should work.
       $letters_price = $count_letters * $price;
      if ($letters_price <= 0) {
        return 0;
      } else {
        return $letters_price;
      }
  }

and in yourcart/includes/modules/pages/product_info/main_template_vars_attributes.php

find

//$tmp_html .= TEXT_PER_LETTER . $currencies->display_price($products_options->fields['attributes_price_letters'], zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . ($products_options->fields['attributes_price_letters_free'] !=0 ? TEXT_LETTERS_FREE . $products_options->fields['attributes_price_letters_free'] : '');

and replace with

//for display only
$txtprltr=TEXT_PER_LETTER;
$displayperlettercost=$products_options->fields['attributes_price_letters'];
if ($displayperlettercost > 10000) {$displayperlettercost=$displayperlettercost-10000;
                                                        $txtprltr= "Price Each:";
                                                      }
$tmp_html .= "$txtprltr ". $currencies->display_price($displayperlettercost, zen_get_tax_rate($product_info->fields['products_tax_class_id'])) . ($products_options->fields['attributes_price_letters_free'] !=0 ? TEXT_LETTERS_FREE . $products_options->fields['attributes_price_letters_free'] : '');

When adding an attribute that uses this script, create it as a text attribute. When applying the attribute, look next to the per letter and per word prices and you'll find the new box. when you edit an existing att qty priced item, you will find a $10000.00+ price in the per-letter box. Just delete it and edit the Attribut Per Quantity Price as needed. If for some reason, there was a need to have an actual text attribute with a per letter price greater than $10000.00, one would have to put in a price $10000.00 greater than the actual price.