title: Set custom weight of simple product in Magento based on value of selected custom option
body: <p>I have a Magento site for a company that sells custom signs. I have custom options set up so that the customer can choose the material and size that they need. My problem is that I need to be able to dynamically calculate the weight of the sign based on the material and the size selected. I have calculated the weight with javascript and now I'm trying to pass it through to Magento using the checkout_product_add_after event. </p>
  
  <p>I've set up a custom option titled Weight that is a text input field. I hide the input field with javascript and pass in the calculated weight. I can access the weight with my custom module and set the weight using the setWeight() method, but when I go through to the checkout, the weight has not been updated and the shipping rates haven't changed. I've tried setting the weight on both the quote item and the product and neither work.</p>
  
  <p>Here is the code from my Observer.php file:</p>
  
  <pre><code>&lt;?php
  
  class XM_CustomWeight_Model_Observer {
  
    public function set_custom_weight($observer) {
  
      $event = $observer-&gt;getEvent();
  $product = $event-&gt;getProduct();
  $options = $product-&gt;getCustomOptions();
      $last = end($options);
      $weight = $last-&gt;getValue();
  $product-&gt;setWeight($weight);
  $product-&gt;save();
  
    }
  }
  </code></pre>
  
  <p>Has anyone ever run into this problem and found a good solution? Thanks for you help!</p>