13 Replies Latest reply on Aug 3, 2008 10:22 AM by Peter Lorent

    Remove Item from Shopping Cart

    katychapman85
      Ok I have been trying to work this out for hours and it's driving me crazy.

      I have a function that removes items from the shopping basket:
      public function RemoveFromBasket(Key:int):void{
      document.RemoveShoppingBasketItems.url = " http://localhost/Flex/Personalised%20Palettes-debug/ShoppingBasket.php?Remove="
      document.RemoveShoppingBasketItems.url += Key;
      document.RemoveShoppingBasketItems.send();
      document.ShoppingBasketCount.url = " http://localhost/Flex/Personalised%20Palettes-debug/Header.php";
      document.ShoppingBasketCount.send();
      ViewShoppingBasket();
      }

      In my MXML I have a label that displays how many items are in the shopping basket which is populated by the ShoppingBasketCount HTTPService. I call the setTotal function everytime the label is updated.

      <mx:Label
      x="640" y="4"
      text="Your Shopping Basket Contains {ShoppingBasketRepeater.currentItem.@Total} Item(s)"
      color="#FFFFFF"
      id="ShoppingBasketLabel"
      updateComplete="SetTotal(event.currentTarget.getRepeaterItem().@Total)"/>

      And the setTotal function sets the Total Variable to the number of items in the shopping basket:

      public function SetTotal(Number:int):void{
      Total = Number;
      document.TestLabel.text = Total;
      }

      Once the item has been removed from the shopping basket and the ShoppingBasketCount has be re-sent the RemoveFromBasket function is called:
      public function ViewShoppingBasket():void{
      document.TestLabel.text = Total;
      if (document.TestLabel.text == 0)
      {
      document.ShoppingBasket.visible = true;
      document.ShoppingBasketGrid.visible = false;
      document.ShoppingBasketHeader.text = "Your Shopping Basket Is Empty";
      document.ProceedToCheckoutButton.visible = false;
      }else{
      document.ShoppingBasketItems.url = " http://localhost/Flex/Personalised%20Palettes-debug/ShoppingBasket.php";
      document.ShoppingBasketItems.send();
      document.ShoppingBasket.visible = true;
      document.ShoppingBasketGrid.visible = true;
      document.ShoppingBasketHeader.text = "Shopping Basket";
      document.ProceedToCheckoutButton.visible = true;
      }
      ToggleMenu(0);
      }

      However when I remove the last item in the basket so that there's no more items in the basket the shopping basket displays an empty grid. The ShoppingBasketLabel displays 0 and the TestLabel displays 0. If I click on the View Shopping Basket link it will then say the Shopping Basket is empty. Why is it showing me an empty grid and not the Shopping Basket is empty message when I remove the last item in the shopping basket?

      Any help would be great!!
      Thanks
      Katy