I am not sure if this is the correct forum, if not my apologies. I have created a dropdownlist for a magazine subscription issues, multivalues, I had to set the price in product variant(SKU) to 0.00 (zero) for the correct pricing to populate in the cart. The problem is that 0.00(USD) shows on category Page (product price) and the product details page. The price does not change when the dropdownlist selection changes and it does not use the default value of the preselected item.
I did add code to make the dropdownlist.autopostback true, I think I also need to create an slectedIndex change event handler for the dropdownlist. As I am new to using this product, I am not totally familar with the technology, not sure if when the category page is generated is AJAX involved and if so, will I need to add a trigger?
An update for those who need the productVariantAttribute(s) to manage the price label, the price does show correctly in the Cart, however those of you who want the price to change on the Product Listing and Details Page when a dropdown list item is selected, try the following..
In productsAttribute.ascx.cs, Procedure CreateAttributesControls(), switch (attribute.AttributeControlType),case AttributeControlTypeEnum.DropdownList: Makes sure you have not added or set ddlAttributes.autopostBack = true, REMOVE it or set it to FALSE
After the line divAttribute.Controls.Add(ddlAttributes);, ADD ddlAttributes.Attributes.Add("onChange", "onSubscriptionChange(this);");
Add Javascript function and var declaration, I added a js file in the scripts folder with function and var declaration referenced it in the /MasterPages/Root.Master<head><script language="javascript" src="../scripts/Common.js" type="text/javascript"></script></head>, but you can do whatever.
var LabelPriceValueClientID = 'ctl00_ctl00_cph1_cph1_ctl00_ctrlProductVariantsInGrid_rptVariants_ctl00_ctrlProductPrice_lblPriceValue';
function onSubscriptionChange(ctrl) { var obj = document.getElementById(ctrl.id.toString()); var x = obj.selectedIndex; var text = obj.options[x].text; var start = text.indexOf("$"); var end = text.indexOf("]"); var amount = text.substring(start, end); var span = document.getElementById(LabelPriceValueClientID); start = span.innerHTML.indexOf("("); end = span.innerHTML.indexOf(")"); var currencyType = span.innerHTML.substring(start, end + 1); span.innerHTML = amount + " " + currencyType; }
AND you will need to create a function in /modules/ProductPrice.ascx.cs, ProductBox1.ascx, productBox.ascx
that does the initial population of the lblPriceValue, you need to create a function similar to