Download the PHP package tandrezone/cart-officer without Composer

On this page you can find all versions of the php package tandrezone/cart-officer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cart-officer

CartOfficer

A lightweight, session-based PHP shopping cart composer package.
Supports adding products (with variants), updating quantities, deleting items and creating an order that POSTs the cart payload to your own endpoint — all with a polished, accessible slide-in UI.


Requirements

Requirement Version
PHP ≥ 7.4
Composer any

No framework required — works with any PHP project.


Installation


Quick Start

1. Create the cart endpoint (e.g. cart.php)

2. Add the CSS in your <head>

Tip: copy public/css/cart.css and public/js/cart.js to your own public/ folder if you need to serve assets from a different path.

3. Configure the JS (optional, before the script tag)

4. Include the templates

Place the cart button wherever you want it (header, navbar, etc.):

Place the sidebar (and overlay) once, just before </body>:

5. Add the JS before </body>


Adding an "Add to Cart" Button to a Product

Add the class co-add-btn and the required data-* attributes to any button:

Attribute Required Description
data-product-id Unique product identifier
data-product-name Product name shown in the cart
data-price Unit price (numeric, e.g. 29.99)
data-product-variant optional Variant string (colour, size, SKU…)
data-quantity optional Units to add per click (default 1)

Clicking the button fires an AJAX request to cartEndpoint and updates the cart badge and sidebar automatically — no page reload.


Complete Page Example


Cart Sidebar Features

When the cart icon is clicked a slide-in panel opens with:

Feature Description
Product table Lists product name, variant, unit price, quantity, line total
Quantity controls / + buttons and a direct input field; changes commit on blur or button press
Delete item Trash-icon button removes the line from the cart
Grand total Recalculated automatically after every change
Create Order POSTs the full cart payload as cart_payload JSON to your orderRoute
Clear cart Empties the cart in one click (with confirmation)

Handling the Order on Your Server

When the user clicks Create Order, CartOfficer POSTs a form to your orderRoute with the field cart_payload (JSON string).

Each item in $payload['items'] has:


PHP API

Cart

CartItem

CartController

Request parameters (POST body or JSON):

Action Required params
add product_id, product_name, price (+ optional product_variant, quantity)
update key, quantity
delete key
clear (none)
order (none)
get (none)

All actions return JSON:


CSRF Protection

The JS automatically reads <meta name="csrf-token" content="…"> and includes the token as _token in the order form POST. For AJAX cart operations you may add your own middleware or validate the X-Requested-With header.


Customising Styles

Override CSS custom properties in your own stylesheet:


License

MIT


All versions of cart-officer with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tandrezone/cart-officer contains the following files

Loading the files please wait ...