PHPackages                             jsnlib/cart - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. jsnlib/cart

ActiveLibrary

jsnlib/cart
===========

1.3.0(6y ago)015MITPHPPHP &gt;=7.0.0

Since Mar 8Pushed 6y agoCompare

[ Source](https://github.com/fdjkgh580/jsnlib-cart)[ Packagist](https://packagist.org/packages/jsnlib/cart)[ RSS](/packages/jsnlib-cart/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

jsnlib-cart
===========

[](#jsnlib-cart)

這是一個簡單的購物車，不依賴任何 framework。

\_\_construct($param = \[\])
----------------------------

[](#__constructparam--)

建構子

- sess (選)使用的 session 名稱，預設是 'jsnlib\_cart'

```
require_once 'vendor/autoload.php';
session_start();
$cart = new Jsnlib\Cart('jsnlibCart');
```

insert(array $param): bool
--------------------------

[](#insertarray-param-bool)

將產品放入購物車

- primaryid (string) 唯一編號
- name (string) 產品名稱
- quantity (int) 產品數量
- price (int) 產品金額
- option (array) 夾帶參數

```
$ary =
[
    'primaryid' => 'JSN5000000',
    'name'      => 'A款衣服',
    'price'     => 399,
    'quantity'  => 2,
    'option'    =>
    [
        'productid' => 'A00001',
        'size'      => 'XL',
    ]
];
$cart->insert($ary);
```

update(array $param): bool
--------------------------

[](#updatearray-param-bool)

修改購物車的產品項目。如果指定參數數量 quantity 為 0 時，視同刪除。

- primaryid (string) 唯一編號

```
$ary =
[
    'primaryid' => 'JSN5000003',
    'quantity'  => 12
];
$cart->update($ary);
```

isnew($primaryid): bool
-----------------------

[](#isnewprimaryid-bool)

加入購物車的是新商品？

```
$cart->isnew('JSN5000003');
```

delete($primaryid): bool
------------------------

[](#deleteprimaryid-bool)

刪除購物車中的某個產品

```
$cart->delete('JSN5000003');
```

get($primaryid)
---------------

[](#getprimaryid)

取得已在購物車的產品資訊

```
$cart->get('JSN5000000');
```

find($param = \[\])
-------------------

[](#findparam--)

尋找參數相符合的列表

```
$cart->insert(
[
    'primaryid' => '0001',
    'name'      => 'A款衣服',
    'price'     => 100,
    'quantity'  => 10,
    'option'    =>
    [
        'size'      => 's',
    ]
]);

$cart->insert(
[
    'primaryid' => '0002',
    'name'      => 'B款衣服',
    'price'     => 200,
    'quantity'  => 10,
    'option'    =>
    [
        'size'      => 'xl',
    ]
]);

$cart->find(['quantity' => 10]); // A款衣服 + B款衣服
$cart->find(['option' => ['size' => 'xl']]); // B款衣服
```

truncate(): bool
----------------

[](#truncate-bool)

清空購物車

```
$cart->truncate();
```

order(array $exclude = NULL): array
-----------------------------------

[](#orderarray-exclude--null-array)

取得帳單

```
$cart->order();
```

取得排除某些列表，例如排除運費的帳單

```
$cart->order(['Transport']);
```

total(array $exclude = NULL): int
---------------------------------

[](#totalarray-exclude--null-int)

合計

```
$cart->total();
```

取得排除某些列表，例如排除運費的合計

```
$cart->total(['Transport']);
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 89.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~108 days

Recently: every ~161 days

Total

7

Last Release

2342d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.2.4

1.1.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b4161e8ee5212efdcdaa6a42183109f397f25c852655ec4b73cce9920cf94f2a?d=identicon)[fdjkgh580](/maintainers/fdjkgh580)

---

Top Contributors

[![fdjkgh580-2](https://avatars.githubusercontent.com/u/60056647?v=4)](https://github.com/fdjkgh580-2 "fdjkgh580-2 (17 commits)")[![fdjkgh580](https://avatars.githubusercontent.com/u/4414580?v=4)](https://github.com/fdjkgh580 "fdjkgh580 (2 commits)")

---

Tags

shopecommercecartcarts

### Embed Badge

![Health badge](/badges/jsnlib-cart/health.svg)

```
[![Health](https://phpackages.com/badges/jsnlib-cart/health.svg)](https://phpackages.com/packages/jsnlib-cart)
```

###  Alternatives

[pixelpeter/laravel5-woocommerce-api-client

Laravel 5 wrapper for the Woocommerce REST API

125103.4k](/packages/pixelpeter-laravel5-woocommerce-api-client)[amsgames/laravel-shop

Package set to provide shop or e-commerce functionality (such as CART, ORDERS, TRANSACTIONS and ITEMS) to Laravel for customizable builds.

4845.9k](/packages/amsgames-laravel-shop)[lunarphp/stripe

Stripe payment driver for Lunar.

2055.8k4](/packages/lunarphp-stripe)[sunnysideup/ecommerce

Silverstripe E-commerce Application

257.2k79](/packages/sunnysideup-ecommerce)[getcandy/core

GetCandy Laravel e-commerce core functionality.

156.6k3](/packages/getcandy-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
