4 replies [Last post]
matshep1's picture
Offline
Joined: 02/08/2009
Juice: 21
Was this information Helpful?

Hi there,

I want to be able to change the SKU listed on the product page when the attribute in the dropdown box is changed. I figure I can do this using a little bit of JQuery magic.

What I need to know is how can I access the alternate SKUs I have stored in the products attribute adjustments settings?

Thanks,
Mat

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3424
Re: Attribute adjustments: Change SKU on product page

Check out http://drupal.org/project/uc_aac, which does that for prices instead of SKUs. Should be just a small change to get it to do what you want.

<tr>.
matshep1's picture
Offline
Joined: 02/08/2009
Juice: 21
UC Ajax Attribute Calculation

Hi TR,

Thanks for the pointer. I have downloaded the module and I am reading through the module code. Wow...! Pretty complex. As the module suggests, I have made sure my product SKU (model) is wrapped in a div like this:

<?php print t( '<h4>Product Code:</h4>') . ('<div id="node-' . $node->nid. 'model"' . ' class="prod_model">') . $node->model . ('</div><br />') ?>

However, I need to figure out how to give my attributes select box a similar ID as it is currently

<select id="edit-attributes-2" class="form-select required" name="attributes[2]">
<option selected="selected" value="">Please select</option>
<option value="5">Small</option>
<option value="6">Medium</option>
<option value="7">Large</option>
<option value="8">Ex. Large</option>
</select>

I can see that the module is using a database query to get the product sell price and the price adjustments...

function _uc_aac_markup($form_id, $nid) {
  $result = db_query('SELECT sell_price FROM {uc_products} WHERE nid=%d AND vid=(SELECT vid FROM {node} WHERE nid=%d)', $nid, $nid);
  // uc_attribute_priced_attributes() depends on Ubercart v1.1 or higher
  $priced_attributes = count(uc_attribute_priced_attributes($nid));
  $total_attributes = db_num_rows(db_query("SELECT * FROM {uc_product_attributes} WHERE nid = %d ORDER BY ordering", $nid));
  $price = 0;
  if ($product = db_fetch_object($result)) {
    $price = $product->sell_price;
  }
  $update_attributes = 0;
  if (variable_get('uc_aac_attribute_reprice', '1') == 1 && (variable_get('uc_attribute_option_price_format', 'adjustment') == 'adjustment' || $priced_attributes > 1) && (variable_get('uc_attribute_option_price_format', 'adjustment') != 'none')) {
    $update_attributes = 1;
  }
  return theme('uc_aac_js', $nid, $price, $update_attributes);
}

So I figure I need to pull the SKU attribute adjustments I entered into the product node using something similar to the above code.

After that I am kind of at a loss. Any further pointers would be great.

Thanks,
Mat

mogop's picture
Offline
Joined: 09/07/2010
Juice: 34
any progress

I'm also interested in this. do you have a solution for the problem?

xl_cheese's picture
Offline
Joined: 04/01/2010
Juice: 252
Re: Attribute adjustments: Change SKU on product page

check out the module posted in the earlier reply. Ubercart attribut adjustments.

www.pinkgorillacycles. Austin, TX motorcycle sales. Online parts, accessories, and apparel.