0 Replies Latest reply on Sep 6, 2007 3:25 PM by cfavila0864

    Customized Flexstore - Duplicate Products in Cart

      I have customized the sample Flexstore application to draw from a XML catalog file that is filterable based on a category identifier. The challenge that I am experiencing is how to add multiple products, each with a separate "Size" or "Color" property and have it distinct from the other products (same product id) in the cart.

      I've tailor the "addProduct" function in "ProductList.mxml" to accomodate new entries into the cart, however the second item added assumes the same product "Size".

      Here is the "addProduct" function;

      public function addProduct(product:Product):void
      //var index:int = indexOf(product.productId);
      var index:int;
      var event:ProductListEvent;
      var item:ProductListItem;

      index = items.length;

      // if (maxItems <= 0 || index < maxItems)
      // {
      item = new ProductListItem();
      if (showQuantity)
      item.currentState = 'showQuantity';
      item.product = product;

      item.percentWidth = 100;
      item.addEventListener(ProductListEvent.REMOVE_PRODUCT, removeItemHandler);
      items[index] = item;
      layoutItems(index, true);
      event = new ProductListEvent(ProductListEvent.ADD_PRODUCT);
      event.product = product;
      // }

      While I can add a product to the cart with a "Size" set to "Size 0", the second product added (with "Size" set to "Size 1") automatically changes the previous product Size to "Size 1" as well.

      When I debug at "index = item.length",
      product.size="Size 1" ==> second product added
      items[0].product.size = "Size 0" ==> first product added

      Once I step through the code by even one step,
      items[0].product.size changes to "Size 1"

      This behavior is just driving me crazy and I don't fully understand why the new product is altering the value of the first product added to the cart.

      Here is a snippet of my catalog:

      <product productId="1">
      <name>Uniform-Nokia 6010</name>
      <description>Easy to use without sacrificing style, the Nokia 6010 phone offers functional voice communication supported by text messaging, multimedia messaging, mobile internet, games and more</description>
      <highlight2>Large color display</highlight2>
      <highlight3>Large color display</highlight3>

      All help is greatly appreciated....