I don't tend to think of tasks as "slices". They are the things you need to do in order to implement a given user story, so are often things like make a schema change, add a new class, add a new method, add a page, style the page etc. You wouldn't typically have one task to implement the whole feature. If you're going to think of them as either vertical or horizontal slices through a user story, they are definitely more horizontal.
Taking a vertical slice of a user story is typically used for splitting one large user story into several smaller ones if your team conclude that it is too big, e.g. if it gets an estimate of an infinite number of story points in planning poker.
If this were the case for your shopping cart example, with a little bit of artistic license, I might break it down into the following different user stories:
- As a buyer I want an add to basket button on every product page so that I can click it to add the product to my basket once that functionality is implemented.
- As a buyer I want to enter the quantity I want to add to my basket so that I can add more that the default of one.
- As a buyer I want a quantity of items to be added to my basket when I click the button so that I can later buy the items.
- As a buyer I want a confirmation screen telling me what I've just added to my basket so that I can correct any errors I might have made.
These are vertical slices through all layers of the system, each implementing data storage, business logic, user interface and everything else needed for a working, albeit not feature complete, system.
This is however the exception, only to be used to deal with user stories which are uncomfortably large. Typically a user story will be of a manageable size and can be broken down into tasks to describe the steps you will take to implement it.