cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frankie70
Post Patron
Post Patron

Design shopping cart and manage items

Hi all,

I am building a webshop and I would like to be able to change the quantity of products or remove them from my gallery.

Frankie70_0-1615994026302.png

I can think of two options:

  1. use a dropdown (when choosing '0' is deleting the product from the list
  2. using buttons (up and down arrow) to modify the quantity or put it to '0' for deletion

Currently the dropdown is configured like this:

 

Sequence(ThisItem.Amount+3,0,1)

 

In my gallery the items ar grouped

 

AddColumns(
    GroupBy(
        basket,
        "itemname",
        "itemopt",
        "itemprice",
        "itemname_rec"
    ),
/*      "Total", Sum(itemname_rec, itemprice), */
    "Amount",
    Sum(
        itemname_rec,
        itemcount
    )
    
)

 

I am really stuck here and any help is appreciated!

40 REPLIES 40

Hi @RandyHayes 

this is the error:

Frankie70_0-1616531009843.png

 

And at the button it says "Name isn't valid. idetifier isn't recognized"

RandyHayes
Super User
Super User

@Frankie70 

Yes, you have a syntax error in that formula.  The error mentions what it is...there is an issue with the closing parens and curly brackets.

 

It looks like you took the formula I provided earlier and removed the dd_amount.Selected from the formula and failed to remove one of the closing parens to the Value function that was removed.

 

Should be:

With({_itm: LookUp(basket, itemname = Gallery4.Selected.Title)},
    If(!IsBlank(_itm.itemcount), 
        UpdateIf(basket, itemname=_itm.itemname,
           {itemcount: _itm.itemcount + 1}
        ),
        Collect(basket, 
           {itemname: Gallery4.Selected.Title, 
            itemcat: Gallery4.Selected.Category, 
            itemprice: Gallery4.Selected.Price, 
            itemopt: dd_options_5.Selected.Result, 
            itemid:Gallery4.Selected.ID, 
            itemcount: 1
           }
        )
    )
)

 

Are you no longer considering the dropdown for incrementing the count?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi @RandyHayes 

thanks a lot...now it works, seems, I made a mistake...sorry for that!!

But the Keyboard layout options should be considered aswell, so keyboard layout GER should not be grouped with IT for example, because they have different prices.

Yes, I want to get rid of the dropdown. But I am free if you think, that this is better/easier to implement I go with that as well.

RandyHayes
Super User
Super User

@Frankie70 

No, I didn't like the dropdown concept from the beginning.  For carts, either provide an increment/decrement option, or just a plain textinput to input a new quantity. 

Think about the user experience - If I added an item to the cart and wanted 100 of them, I'd have to click on the + icon 100 times to get what I want...very annoying.  And a dropdown limits my choices, because, if it only went up to 50 and I wanted 100, how would I get that?

 

As for the grouping...this is going to be based on how you look to see if the collection already has an item in it.

Right now we have this:

With({_itm: LookUp(basket, itemname = Gallery4.Selected.Title)},
 ...

So, you are ONLY basing the addition of the item to the cart on the itemname.

If you want to expand that to other parameters, then add then to the LookUp.

Ex:

With({_itm: LookUp(basket, itemname = Gallery4.Selected.Title && 
                           itemcat: Gallery4.Selected.Category && 
                           itemopt: dd_options_5.Selected.Result)},
 ...

 Would base it on the itemname, itemcat and itemopt.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi @RandyHayes 

I fixed it and it works great!

The only thing that is left now (for today  😊) is how to use the arrows in the shopping tray.

OnSelect: ThisItem.itemcount +1

does not work...!

Hi @RandyHayes 

this webshop is only for our internal user, where you maybe order anoth.er headset or a noew lapttop with docking for a new employee or maybe 4 or 5 keyboards or mouse. So, I think a +/- would be good to have to quickly change the amount in the tray.

How would I do the formula to increment with the arrow up (or later +)--> because I cannot find the minus symbol?

RandyHayes
Super User
Super User

@Frankie70 

Yes, that incrementing will not work.  Here is what you need.

On the Plus icon:

With({_itm: LookUp(basket, itemname = Gallery4.Selected.Title &&
                           itemcat = Gallery4.Selected.Category &&
                           itemopt = dd_options_5.Selected.Result)},

        Patch(basket, _itm, {itemcount: _itm.itemcount + 1})
)

And for the minus:

With({_itm: LookUp(basket, itemname = Gallery4.Selected.Title &&
                           itemcat = Gallery4.Selected.Category &&
                           itemopt = dd_options_5.Selected.Result)},

        Patch(basket, _itm, {itemcount: _itm.itemcount - 1})
)

 

I would also put this on the minus button.

If(LookUp(basket, itemname = Gallery4.Selected.Title &&
                  itemcat = Gallery4.Selected.Category &&
                  itemopt = dd_options_5.Selected.Result,
                  itemcount) <=1,
    Disabled,
    Edit
)

 

This will keep people from going less than 1 on the item.  

I would assume then a Delete icon on the item so people can get rid of it:

RemoveIf(basket, itemname = Gallery4.Selected.Title &&
                  itemcat = Gallery4.Selected.Category &&
                  itemopt = dd_options_5.Selected.Result
)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

Thanks a lot, you really helped me!!

Hi @RandyHayes ,

I just checked more closely and I found an issue.

When adding black iPhones from the "Add to cart" button, the number of white iPhones is increased aswell.

For products without the itemoption (itemopt= dd_options_5.Selected.Result) ist working correct.

So, for example:

  • adding 3 black phone
  • adding 1 white phone
  • adding 1 black phone

results in 4 black and 4 white phones.

Somehow it seems that the option is not found correctly. I can not find the logical error in the formula.

Do you have an idea?

Hi @RandyHayes 

got it working!

Helpful resources

Announcements
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.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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