cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Shopping Cart app | count ++ selected galleryitem & collect shopped items

Hi guys,

 

I'm pretty new to powerapps and i'm trying to make a shopping card. I have a gallery selected with my products and i added a textinput and a add icon. Basically i want to be able to click the items i want and to count them. The screen underneath will explain what i am looking for.

 

AnthonyDB_0-1610093244562.png

 

In addition i am trying to collect all the items that are filled in. I am collecting values but its not working correctly.

 

Code that i have now for collecting shopped items: 

ForAll(Gallery1.AllItems,Collect(ShoppingCart, {itemType:Gallery1.Selected.itemCategoryCode, itemName:Gallery1.Selected.displayName,itemQuantity:TextInput1.Text}))

 

 

AnthonyDB_0-1610096115798.png

 

 

 

I tried this code for the "on select" of the add icon to see if i could only get one of the gallery item textboxes to be ++

 

 

 

 

Gallery1.Selected.TextInput1.Text="1"

 

 

 

 

Once i figure out how to get this to work i will finetune the code with if statements.

 

Kind regards,

 

Anthony

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @Anonymous ,

There is no need to repeat the gallery reference - you are already collecting AllItems and .Selected will only reference one record (the one selected)

ForAll(
   Gallery1.AllItems,
   Collect(
      ShoppingCart, 
      {
         itemType:itemCategoryCode, 
         itemName:displayName,
         itemQuantity:TextInput1.Text
      }
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @Anonymous ,

There is no need to repeat the gallery reference - you are already collecting AllItems and .Selected will only reference one record (the one selected)

ForAll(
   Gallery1.AllItems,
   Collect(
      ShoppingCart, 
      {
         itemType:itemCategoryCode, 
         itemName:displayName,
         itemQuantity:TextInput1.Text
      }
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Anonymous
Not applicable

Hello @WarrenBelz ,

 

Perfect this works. Can you help me with the first bit of code as well? So how i can ++ and eventually also -- every separate gallery item? I haven't done this yet. I have no clue how to only ++ the textbox corresponding to the item.

 

King regards, 

 

Anthony

Hi @Anonymous ,

You would need a checkbox in the gallery (you can only select one item at a time) and check that. Using the name chkCount  for the checkbox, your count would be 

CountRows,
   Filter(
      Gallery1.AllItems,
      chkCount.Value
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,802)