Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2008
    Posts
    76
    Plugin Contributions
    0

    Default Using attribute text value to calculate price

    Does anyone know how to use an attribute text value to calculate price?

    Any help that would point me in the right direction would be appreciated, like module name and paths

  2. #2
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,684
    Plugin Contributions
    11

    Default Re: Using attribute text value to calculate price

    Have you been to the attributes controller?
    Have you clicked on tutorials/FAQ and entered "price by attribute" in the advance search?
    A little help with colors.
    myZenCartHost.com - Zen Cart Certified, PCI Compatible Hosting by JEANDRET
    Free SSL & Domain with semi-annual and longer hosting. Updating 1.5.2 and Up.

  3. #3
    Join Date
    Mar 2008
    Posts
    76
    Plugin Contributions
    0

    Default Re: Using attribute text value to calculate price

    I had to modify classes/shopping cart.php

    In two places code similar to:

    Code:
             $attribute_name = $db->Execute("select products_options_name
                                from ". TABLE_PRODUCTS_OPTIONS . "
                                where products_options_id = '" . (int)$option . "'");
    
              $attribute_name->fields['products_options_name'];
    
             if ($attribute_name->fields['products_options_name'] == 'Value: $')
             {
                 $text_val = $this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']];
                 $attributes_price += $text_val;
    
              }
    and

    Code:
              $attribute_name = $db->Execute("select products_options_name
                                from ". TABLE_PRODUCTS_OPTIONS . "
                                where products_options_id = '". $attribute_price->fields['options_id']. "'" );
    
              $attribute_name->fields['products_options_name'];
    
             if ($attribute_name->fields['products_options_name'] == 'Value: $')
             {
                 $text_val = $this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']];
                 $this->total += $qty * zen_add_tax($text_val, $products_tax);
    
              }
    I also had to modify modules/attributes to check the input:

    Code:
                           $tmp_html = '<input type="text" name="id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']" size="' . $products_options_names->fields['products_options_size'] .'" maxlength="' . $products_options_names->fields['products_options_length'] . '" value="' . htmlspecialchars($tmp_value) .'" id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '-' . $products_options_value_id . '" onchange="if (\''.$products_options_names->fields['products_options_name'].'\' == \'Value\' && !parseInt(document.all[\'id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']\'].value)) { alert(\'Enter a valid value, please.\');document.all[\'id[' . TEXT_PREFIX . $products_options_names->fields['products_options_id'] . ']\'].value = \'\'; }"/>';

  4. #4
    Join Date
    Mar 2008
    Posts
    76
    Plugin Contributions
    0

    Default Re: Using attribute text value to calculate price

    I removed the javascript from attributes.php and added to functions/function_lookups.php

    Code:
              $attribute_name = $db->Execute("select products_options_name
                                from ". TABLE_PRODUCTS_OPTIONS . "
                                where products_options_id = '". $check_attributes->fields['options_id']. "'" );
    
              $attribute_name->fields['products_options_name'];
    
             if ($attribute_name->fields['products_options_name'] == 'Value: $')
             {
                  if (!is_numeric($value))
                  {
                      $check_valid = false;
                  }
              }

 

 

Similar Threads

  1. v151 Add text attribute value entered to base price
    By DanP in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 23 Jun 2013, 12:36 PM
  2. How can I make an attribute calculate a by-the-inch price and show before checkout?
    By Z888999777T in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 28 Feb 2011, 11:42 AM
  3. Calculate price by number entered as text
    By twdhosting in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 31 Jan 2011, 11:01 AM
  4. Using attribute text value to calculate price
    By dejavu in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 27 Apr 2008, 06:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg