Basket templates¶
Template list¶
Path | Description |
---|---|
basket/page.html.twig |
Main basket template |
basket/widget.html.twig |
Basket preview in the upper right corner of the shop screen |
basket/row.html.twig |
Single row of basket preview |
basket/basket_summary.html.twig |
Basket summary |
SilversolutionsEshopBundle:Basket:stored_basket_preview_wish_list.html.twig |
Wishlist row with a number of products in the "My Shop" menu |
SilversolutionsEshopBundle:Basket:stored_basket_preview_comparison.html.twig |
Comparison row with a number of products in the "My Shop" menu |
Display the content of a basket¶
The BasketController
provides the basket
variable that contains the content of the current basket.
You can access all basket attributes from a template.
The count of basket lines:
1 |
|
Access to basket lines:
1 2 3 4 |
|
You can access the basket total value (net or gross) using basket.totalsSum
:
1 |
|
To get the catalog element from the basket line, use line.catalogElement
.
If a basket line does not provide product data (for example, the caching life time of a product has been exceeded), the product can be fetched with the ses_product
function, by providing it with the product SKU obtained through line.sku
.
1 2 3 4 5 |
|
Adding a product to the basket¶
To create a button that adds the current product to the basket, use the following form:
1 2 3 4 5 6 7 |
|
You can add more than one product to the basket (for example, in a product list) by using the index:
1 2 3 |
|
Note
If you want to add more products to the basket (for example, from the wishlist), you need one form around all the lines. The form adds all the lines to the basket at once. However, you might also need to add only one product from the list.
To add a single product to the basket, you need to define parent elements with the class .js-product-line
.