studiomitte/cart-count

Endpoint for EXT:cart cart information which can be retrieved by an AJAX request

Installs: 1 028

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:typo3-cms-extension

0.1.2 2020-07-29 11:08 UTC

This package is auto-updated.

Last update: 2021-03-24 10:34:57 UTC


README

This extensions provides a basic endpoint to fetch information from current cart session when using the TYPO3 extension cart. The main benefit is to have pages still cacheable and show e.g. the count of articles in the cart.studiomitte

Example

{
    "net":551,
    "gross":551,
    "count":1,
    "products": [
        {
            "title":"A title",
            "sku":"1234",
            "net":551,
            "gross":551,
            "quantity":1
        }
    ]
}

Installation

Install this extension by using composer require studiomitte/cart-count.

Usage

By calling the URL /?cartId=123 you can retrieve the cart information. 123 is the page configured in the cart plugins where the order is saved.

This extension does not any JS to fetch the data but one example can be

$.get("/?cartId=195", function (data) {
    if (data.count > 0) {
        $(".cart__icon__wrapper").append("<span class='cart__count cart__count--big'>" + data.count + "</span>");
    }
});