Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18
  1. #11
    Join Date
    Sep 2009
    Posts
    55
    Plugin Contributions
    0

    Default Re: User input product dimensions, update price based on inputs

    Thanks jackie,
    I would be varying thankful to you. But it would be vary nice if this would fulfilled my requirement.
    Today I would be waiting for your link,
    Thanks
    Zahid

  2. #12
    Join Date
    Sep 2009
    Posts
    55
    Plugin Contributions
    0

    Default Re: User input product dimensions, update price based on inputs

    Dear, i need addon for this situation plz look at the link below
    user will enter there squrar footer, then according to that price will be adjusted,
    http://team-kh.awpdc.com/~zadhnanr/b...roducts_id=483



    Thanks
    Zahid

  3. #13
    Join Date
    Jun 2009
    Location
    Orange County, California
    Posts
    544
    Plugin Contributions
    18

    Default Re: User input product dimensions, update price based on inputs

    Hello Zahid,

    My mod will work a little different from what you have there on your site - it will actually take the length and width, and calculate the square footage as well as the total cost. the customer will not need to enter the square footage itself :)

    It will not calculate it directly on the product page, but when customer clicks "add to cart", it will calculate and add price to the shopping cart.

    Hopefully in the future I'll get some more features added (like showing total on product page, etc).

    Link to download coming later today!

  4. #14
    Join Date
    Sep 2009
    Posts
    55
    Plugin Contributions
    0

    Default Re: User input product dimensions, update price based on inputs

    Hello! Jackie,

    Thanks for your response,
    My problem is that, I do my all calculation, but now my new price will not to add as final price as I have no idea about final price variable , that I will assigned my final value to that that variable,

    Please let me know if you have an idea about this situation.

    Thanks
    Zahid.

  5. #15
    Join Date
    Jun 2009
    Location
    Orange County, California
    Posts
    544
    Plugin Contributions
    18

    Default Re: User input product dimensions, update price based on inputs

    Hello Zahid,

    Here's what I've got for the mod so far... kind of a beta version, but hopefully it will help solve your situation.

    I had this working on a live site, but as I'm trying to make the code scalable for use on any website, I'm running into trouble getting it to work just right. I'll keep at it. If there are any other Zen Cart pros on here that would like to have a look and let me know why this would or wouldn't work, or if there may be vulnerabilities in editing this code, then please feel free to give some feedback ;)

    Anyhow, you want to edit this file: includes/classes/shopping_cart.php

    Find the following code (should be around line 1180):
    PHP Code:
            $products_array[] = array('id' => $products_id,
                                      
    'category' => $products->fields['master_categories_id'],
                                      
    'name' => $products->fields['products_name'],
                                      
    'model' => $products->fields['products_model'],
                                      
    'image' => $products->fields['products_image'],
                                      
    'price' => ($products->fields['product_is_free'] =='1' $products_price),
            
    //                                    'quantity' => $this->contents[$products_id]['qty'],
                                      
    'quantity' => $new_qty,
                                      
    'weight' => $products->fields['products_weight'] + $this->attributes_weight($products_id),
                                      
    // fix here
                                      
    'final_price' => ($products_price $this->attributes_price($products_id)),
                                      
    'onetime_charges' => ($this->attributes_price_onetime_charges($products_id$new_qty)),
                                      
    'tax_class_id' => $products->fields['products_tax_class_id'],
                                      
    'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),
                                      
    'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''),
                                      
    'products_priced_by_attribute' => $products->fields['products_priced_by_attribute'],
                                      
    'product_is_free' => $products->fields['product_is_free'],
                                      
    'products_discount_type' => $products->fields['products_discount_type'],
                                      
    'products_discount_type_from' => $products->fields['products_discount_type_from']);
          }
        }
        
    $this->notify('NOTIFIER_CART_GET_PRODUCTS_END');
        return 
    $products_array;
      } 
    And REPLACE with this:
    PHP Code:
            //begin Attribute Calculator 1.0
            //Zen Cart contribution by JT Website Design http://www.jtwebsitedesign.com    
            
    $description_sql 'SELECT products_name FROM ' TABLE_PRODUCTS_DESCRIPTION ' where products_id = "' . (int) $products_id '"';

            
    $pdescription $db->Execute($description_sql);
            
    $products_name $pdescription->fields['products_name'];

            switch(
    $products->fields['products_name'])
                {
                  case 
    'Product A':
                  
    $priceFactor 1.00;
                  break;
                  case 
    'Product B':
                  
    $priceFactor 0.50;
                  break;
                  case 
    'Product C':
                  
    $priceFactor 1.25;
                  break;
                  default:
                
    $priceFactor 0;        
                }
            if(
    $priceFactor != 0)
                {
                
    $Length_ID_Query "select products_options_id from " TABLE_PRODUCTS_OPTIONS " where products_options_name = 'Length'";
                
    $Length_ID $db->Execute($Length_ID_Query);
                
    $LengthID = (int)$Length_ID->fields['products_options_id'];
        
                
    $Width_ID_Query "select products_options_id from " TABLE_PRODUCTS_OPTIONS " where products_options_name = 'Width'";
                
    $Width_ID $db->Execute($Width_ID_Query);
                
    $WidthID = (int)$Width_ID->fields['products_options_id'];
                
                if (
    $this->contents[$products_id]['attributes_values'][$WidthID] && $this->contents[$products_id]['attributes_values'][$LengthID])
                
    $areaFactor $this->contents[$products_id]['attributes_values'][$WidthID]*$this->contents[$products_id]['attributes_values'][$LengthID];
                
                else
                
    $areaFactor 0;
                
    $extraCharge $areaFactor $priceFactor;
                }
            else
                
    $extraCharge 0;
            
    //end Attribute Calculator 1.0

            
    $products_array[] = array('id' => $products_id,
                                      
    'category' => $products->fields['master_categories_id'],
                                      
    'name' => $products->fields['products_name'],
                                      
    'model' => $products->fields['products_model'],
                                      
    'image' => $products->fields['products_image'],
                                      
    'price' => ($products->fields['product_is_free'] =='1' $products_price+$extraCharge),
            
    //                                    'quantity' => $this->contents[$products_id]['qty'],
                                      
    'quantity' => $new_qty,
                                      
    'weight' => $products->fields['products_weight'] + $this->attributes_weight($products_id),
                                      
    // fix here
                                      
    'final_price' => ($products_price $this->attributes_price($products_id) + $extraCharge),
                                      
    'onetime_charges' => ($this->attributes_price_onetime_charges($products_id$new_qty)),
                                      
    'tax_class_id' => $products->fields['products_tax_class_id'],
                                      
    'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),
                                      
    'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''),
                                      
    'products_priced_by_attribute' => $products->fields['products_priced_by_attribute'],
                                      
    'product_is_free' => $products->fields['product_is_free'],
                                      
    'products_discount_type' => $products->fields['products_discount_type'],
                                      
    'products_discount_type_from' => $products->fields['products_discount_type_from']);
          }
        }
        
    $this->notify('NOTIFIER_CART_GET_PRODUCTS_END');
        return 
    $products_array;
      } 

    So, what you'll want to do is change "Product A", "Product B", etc to match the names of your product. Then you can put a price per square foot (the variable for this is $PriceFactor), which can be specified for each individual product.

    If you want the same price per square foot for all products, the above code can be modified a bit, and you can hard code the PriceFactor to be a specific number, removing the cases per product.

    Hope it makes sense and helps out a bit! Let me know if it works for you

  6. #16
    Join Date
    Sep 2009
    Posts
    55
    Plugin Contributions
    0

    Default Re: User input product dimensions, update price based on inputs

    <form action="" method="post">
    <table width="100%" height="129" border="1" align="center">
    <tr>
    <td height="27" width="50%" bgcolor="#A9A9A9" ><b>Enter Your Square Footage below:</b></td>
    <td bgcolor="#A9A9A9"><b>Your Material cost</b></td>
    </tr>
    <tr>
    <td width="50%" align="center"><br /><input id="size" size="15" name="boxsize" /></td>

    <td>
    <?php

    $box=$_POST['boxsize'];
    //echo $box;
    if($box==0)
    {
    echo 0;
    echo " "."boxes";
    }
    elseif($box<$products_colour)
    {
    echo 1;
    echo " "."boxes";
    }
    else
    {
    //echo "now more than 20";

    $noboxes=($box/$products_colour);

    $finalbox= ceil($noboxes);
    echo $finalbox;
    echo " "."boxes";

    }
    ?>
    <br /><br />
    <?php
    if($finalbox<1)
    {
    echo 1;
    echo " "."sq.ft";
    }
    else
    {
    $sqft=($finalbox*$products_colour);
    echo $sqft;
    echo " "."sq.ft";
    }
    ?>
    <br /><br />
    <?php
    //echo $pri;
    $price= $finalbox*$pri;
    echo " "."$".$price;

    //$_SESSION['myprice']=$price;
    //echo $_SESSION['myprice'];
    ?>
    </td>
    <tr><td height="25" colspan="2" align="center"><input type="submit" value="Calculate" /> </td></tr>

    </tr>
    </table>
    </form>

    my last calculated price value is "."$".$price;, file name is product_info_display.php

  7. #17
    Join Date
    Jun 2009
    Location
    Orange County, California
    Posts
    544
    Plugin Contributions
    18

    Default Re: User input product dimensions, update price based on inputs

    Zahid,

    So did that work for you in conjunction with my script (or a modification of it)?

    You should be able to pass that value to the shopping_cart.php file using a similar method as what i posted.

    Note especially this line:
    'final_price' => ($products_price + $this->attributes_price($products_id) + $extraCharge),

    the $extraCharge variable adds the extra cost

  8. #18
    Join Date
    Nov 2007
    Posts
    32
    Plugin Contributions
    0

    Default Re: User input product dimensions, update price based on inputs

    Did this module ever get finished? Any updates to it?

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. v151 User input product dimensions, update price based on inputs now Working!
    By ChobPT in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 3 Dec 2012, 01:39 AM
  2. Price based on custom dimensions
    By shamkeem in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 3 Aug 2011, 04:58 AM
  3. price based on dimensions
    By jinx in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 24 Jan 2008, 08:35 PM
  4. Need User text input based on Attribute selected
    By heinz in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 7 Aug 2007, 09:35 PM
  5. Price based on dimensions (per square meter)
    By frankkubiak in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 28 Sep 2006, 04:08 AM

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