{"id":36398236,"url":"https://github.com/joseph-montanez/phpcartload","last_synced_at":"2026-01-11T16:01:22.650Z","repository":{"id":39177645,"uuid":"57108447","full_name":"joseph-montanez/PHPCartLoad","owner":"joseph-montanez","description":"E-Commerce without the framework or database","archived":false,"fork":false,"pushed_at":"2022-06-28T01:28:40.000Z","size":185,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-13T16:00:04.168Z","etag":null,"topics":["carts","pricing","shopping-cart","sku-variations","storefront","variants","weight"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joseph-montanez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-26T07:46:24.000Z","updated_at":"2022-03-15T15:03:58.000Z","dependencies_parsed_at":"2022-09-04T19:50:41.413Z","dependency_job_id":null,"html_url":"https://github.com/joseph-montanez/PHPCartLoad","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/joseph-montanez/PHPCartLoad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-montanez%2FPHPCartLoad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-montanez%2FPHPCartLoad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-montanez%2FPHPCartLoad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-montanez%2FPHPCartLoad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joseph-montanez","download_url":"https://codeload.github.com/joseph-montanez/PHPCartLoad/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseph-montanez%2FPHPCartLoad/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28312133,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carts","pricing","shopping-cart","sku-variations","storefront","variants","weight"],"created_at":"2026-01-11T16:00:28.588Z","updated_at":"2026-01-11T16:01:22.645Z","avatar_url":"https://github.com/joseph-montanez.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHPCartLoad [![Build Status](https://travis-ci.org/joseph-montanez/PHPCartLoad.svg?branch=master)](https://travis-ci.org/joseph-montanez/PHPCartLoad) #\n\n[![codecov](https://codecov.io/gh/joseph-montanez/PHPCartLoad/branch/master/graph/badge.svg)](https://codecov.io/gh/joseph-montanez/PHPCartLoad)\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/326e83e2-7e5b-4071-a44d-a3ce71117982/mini.png)](https://insight.sensiolabs.com/projects/326e83e2-7e5b-4071-a44d-a3ce71117982)\n\nInspired by [Satchless](http://satchless.com/) for Python, PHPCartLoad is a feature rich library intended to help build shopping carts and general e-commerce applications. This library is to provide a foundation of easy to use classes to manage inventory pricing and carts. There is zero database requirements and is completely data driven.\n\n## License\n\nThe library is MIT, do what you want with it.\n\n## To Do\n\nThis is still alpha and undergoing changes for a better API. The following is to come:\n\n - Reach 100% code coverage\n - Create tests for weight\n - Finish Cart API\n    - Additional events for find, delete\n    - Provide default duplicate logic\n    - Taxes or just any price breakdown per item\n    - Discounts, coupons via Pricing Rules (Mangento does a good job here)\n - Consider multi-currency, multi-lingual support\n - Stock API\n   - In Stock\n   - Drop-Shipped\n   - Back Ordered (Including support for limiting to the amount back ordered)\n - Shipping API\n   - Initial Support For USPS\n   - Guidelines for more shipping providers\n   - Math stuff for calculating box sizes based on product dimensions and weight\n - Order API\n - Invoice API\n\n## Examples\n\nHere are some examples of what is current available in the library.\n\n - [Simple Pricing](#simple-pricing)\n - [Bulk Pricing](#bulk-pricing)\n - [SKU Variations](#sku-variations)\n - [Combinations](#combinations)\n - [Cart Events](#cart-events)\n\n### Simple Pricing\n\nThis is the Hello World of this library, showing you how little you have to do to start to get the library working with your existing code base.\n\n    \u003c?php\n    require_once __DIR__ . '/../vendor/autoload.php';\n    \n    use CartLoad\\Product\\Product;\n    \n    \n    $apple = Product::make([\n        'name' =\u003e 'Apple',\n        'sku' =\u003e 'a',\n        'price' =\u003e 19.95\n    ]);\n    \n    $qty = 10;\n    \n    \n    //-- This will return the simple price: 19.95\n    var_dump($apple-\u003egetPrice($qty));\n\n### Bulk Pricing\n\nYou can also expand on pricing to include bulk pricing, again keeping with something as simple as possible.\n\n    \u003c?php\n    require_once __DIR__ . '/../vendor/autoload.php';\n    \n    use CartLoad\\Product\\Product;\n\n    $apple = new Product([\n        'name' =\u003e 'Apple',\n        'sku' =\u003e 'a',\n        'price' =\u003e [\n            ['min_qty' =\u003e 1, 'max_qty' =\u003e 9, 'price' =\u003e 19.95],\n            ['min_qty' =\u003e 10, 'price' =\u003e 14.95],\n        ]\n    ]);\n\n    $qty = 10;\n\n    //-- This will return the simple price: 14.95\n    var_dump($apple-\u003egetPrice($qty));\n\n### SKU Variations\n\nSKU Variations, or options are ways to let a base product serve as a platform for all the variations. So if you have a shirt with several sizes and colors, then you can have custom pricing for each of those variants / options.\n\n    \u003c?php\n    require_once __DIR__ . '/../vendor/autoload.php';\n    \n    use CartLoad\\Product\\Product;\n    use CartLoad\\Cart\\Item;\n    \n    $shirt = Product::make([\n        'id' =\u003e 1,\n        'name' =\u003e 'Shirt',\n        'sku' =\u003e 'shirt',\n        'price' =\u003e [\n            ['min_qty' =\u003e 1, 'max_qty' =\u003e 9, 'price' =\u003e 4.95],\n            ['min_qty' =\u003e 10, 'max_qty' =\u003e 19, 'price' =\u003e 3.95],\n        ],\n        'variations' =\u003e [\n            [\n                'id' =\u003e 1,\n                'name' =\u003e 'Color',\n                'required' =\u003e true,\n                'items' =\u003e [\n                    ['id' =\u003e 1, 'name' =\u003e 'Red', 'price' =\u003e 0.5, 'sku' =\u003e 'r'],\n                    ['id' =\u003e 2, 'name' =\u003e 'Blue', 'price' =\u003e 0.4, 'sku' =\u003e 'b'],\n                    ['id' =\u003e 3, 'name' =\u003e 'Green', 'price' =\u003e 0.6, 'sku' =\u003e 'g'],\n                ]\n            ],\n            [\n                'id' =\u003e 2,\n                'name' =\u003e 'Size',\n                'required' =\u003e true,\n                'items' =\u003e [\n                    ['id' =\u003e 4, 'name' =\u003e 'Small', 'price' =\u003e 1.0, 'sku' =\u003e 's'],\n                    ['id' =\u003e 5, 'name' =\u003e 'Medium', 'price' =\u003e 1.1, 'sku' =\u003e 'm'],\n                    ['id' =\u003e 6, 'name' =\u003e 'Large', 'price' =\u003e 1.2, 'sku' =\u003e 'l'],\n                ]\n            ],\n        ]\n    ]);\n    \n    //-- Blue Medium Shirt\n    $cartItem = Item::make([\n        'id'         =\u003e 1,\n        'product_id' =\u003e 1, //Shirt product ID\n        'qty'        =\u003e 1,\n        'variations' =\u003e [2, 5] // Blue, Medium\n    ]);\n    \n    //-- The unit price of a blue medium shirt is 6.45\n    $unit_price = $cartItem-\u003egetPrice($shirt);\n    //-- The resulting SKU is then \"shirt-b-m\"\n    $unit_sku = $cartItem-\u003egetSku($shirt);\n    \n### Combinations\n\nCombinations are ways to customize the resulting product variants. This could be as simple as saying a certain product\nconfiguration is not available, or maybe you need a special price, SKU or weight for a specific combination. Another\npossibility if you need to track stock for the variations, instead these can be linked to individual products for\ngreater customizations.\n\n    \u003c?php\n    \n    require_once __DIR__ . '/../vendor/autoload.php';\n    \n    use CartLoad\\Product\\Product;\n    use CartLoad\\Cart\\Item;\n    \n    $shirt = Product::make([\n        'id' =\u003e 1,\n        'name' =\u003e 'Shirt',\n        'sku' =\u003e 'shirt',\n        'price' =\u003e [\n            ['min_qty' =\u003e 1, 'max_qty' =\u003e 9, 'price' =\u003e 4.95],\n            ['min_qty' =\u003e 10, 'max_qty' =\u003e 19, 'price' =\u003e 3.95],\n        ],\n        'variations' =\u003e [\n            [\n                'id' =\u003e 1,\n                'name' =\u003e 'Color',\n                'required' =\u003e true,\n                'items' =\u003e [\n                    ['id' =\u003e 1, 'name' =\u003e 'Red', 'price' =\u003e 0.5, 'sku' =\u003e 'r'],\n                    ['id' =\u003e 2, 'name' =\u003e 'Blue', 'price' =\u003e 0.4, 'sku' =\u003e 'b'],\n                    ['id' =\u003e 3, 'name' =\u003e 'Green', 'price' =\u003e 0.6, 'sku' =\u003e 'g'],\n                ]\n            ],\n            [\n                'id' =\u003e 2,\n                'name' =\u003e 'Size',\n                'required' =\u003e true,\n                'items' =\u003e [\n                    ['id' =\u003e 4, 'name' =\u003e 'Small', 'price' =\u003e 1.0, 'sku' =\u003e 's'],\n                    ['id' =\u003e 5, 'name' =\u003e 'Medium', 'price' =\u003e 1.1, 'sku' =\u003e 'm'],\n                    ['id' =\u003e 6, 'name' =\u003e 'Large', 'price' =\u003e 1.2, 'sku' =\u003e 'l'],\n                ]\n            ],\n        ],\n        'combinations' =\u003e [\n            //-- Blue Medium Shirt on Sale with special SKU to track all blue shirt sales in main system\n            [\n                'id' =\u003e 1,\n                'variations' =\u003e [2, 5],\n                'price' =\u003e 5.00,\n                'sku' =\u003e 'shirt-b-m-sale',\n            ]\n        ]\n    ]);\n    \n    //-- Blue Medium Shirt\n    $cartItem = Item::make([\n        'id'         =\u003e 1,\n        'product_id' =\u003e 1, //Shirt product ID\n        'qty'        =\u003e 1,\n        'variations' =\u003e [2, 5] // Blue, Medium\n    ]);\n    \n    //-- The unit price of a blue medium shirt is 5.00\n    $unit_price = $shirt-\u003egetCartPrice($cartItem);\n    //-- The resulting SKU is then \"shirt-b-m-sale\"\n    $unit_sku = $shirt-\u003egetCartSku($cartItem);\n    \n    echo $unit_sku, ' - ', $unit_price;\n\n### Cart Events\n\nA generic cart system is provided with a PHP Session ($_SESSION) driver. Its possible to interject events to provide basic features like validation.\n\n    \u003c?php\n    \n    use CartLoad\\Cart\\Container;\n    use CartLoad\\Cart\\Events\\CartAddItemBeforeEvent;\n    use CartLoad\\Cart\\Events\\CartGetItemAfterEvent;\n    use CartLoad\\Cart\\Item;\n    use CartLoad\\Cart\\Repositories\\Session;\n    use CartLoad\\Product\\Product;\n    \n    require_once __DIR__ . '/../vendor/autoload.php';\n    \n    //--------------------------------------------------------------------------------------------------------------\n    //-- Products\n    //--------------------------------------------------------------------------------------------------------------\n    $products = [\n        'd97c4f2f-fd06-4e7d-b161-51f4038ee898' =\u003e Product::make([\n            'id' =\u003e 'd97c4f2f-fd06-4e7d-b161-51f4038ee898',\n            'name' =\u003e 'Apple',\n            'sku' =\u003e 'a',\n            'price' =\u003e 19.95\n        ]),\n        'b99cb34e-7edb-45d3-9dfe-5e39f6b71587' =\u003e Product::make([\n            'id' =\u003e 'b99cb34e-7edb-45d3-9dfe-5e39f6b71587',\n            'name' =\u003e 'Orange',\n            'sku' =\u003e 'o',\n            'price' =\u003e 21.99\n        ]),\n    ];\n    \n    \n    //--------------------------------------------------------------------------------------------------------------\n    //-- Cart\n    //--------------------------------------------------------------------------------------------------------------\n    $repository = new Session();\n    $container = new Container($repository);\n    \n    //--------------------------------------------------------------------------------------------------------------\n    //-- Validation\n    //--------------------------------------------------------------------------------------------------------------\n    //-- @ before adding to cart\n    $container-\u003eaddListener(CartAddItemBeforeEvent::NAME, function (CartAddItemBeforeEvent $event) use ($products) {\n        /**\n         * @var $item CartLoad\\Cart\\Item\n         */\n        $item = $event-\u003egetItem();\n    \n        /** @var CartLoad\\Product\\Product $product */\n        $product = isset($products[$item-\u003egetProductId()]) ? $products[$item-\u003egetProductId()] : null;\n    \n        if ($product === null) {\n            $event-\u003eaddError('Sorry this product \"' . $item-\u003egetProductId() . '\" does not exist', 'does-not-exist');\n        }\n    });\n    \n    //-- @ after getting an item\n    $container-\u003eaddListener(CartGetItemAfterEvent::NAME, function (CartGetItemAfterEvent $event) {\n        /**\n         * @var $item CartLoad\\Cart\\Item\n         */\n        $item = $event-\u003egetItem();\n    \n        if ($item-\u003egetQty() \u003c 1) {\n            $event-\u003eaddError('Please enter a quantity', 'qty');\n        }\n    });\n    \n    //-- Example of a good cart add\n    $apple = $products['d97c4f2f-fd06-4e7d-b161-51f4038ee898'];\n    $cartAppleData = [\n        'id'         =\u003e uniqid(),\n        'product_id' =\u003e $apple-\u003egetId(),\n        'qty'        =\u003e 3,\n    ];\n    $cartAppleItem = Item::make($cartAppleData);\n    $appleAdded = $container-\u003eaddItem($cartAppleItem); //-- returns true\n    \n    //-- Example of a bad cart add\n    $cartBadAppleData = [\n        'id'         =\u003e uniqid(),\n        'product_id' =\u003e 'i do not exist',\n        'qty'        =\u003e 3,\n    ];\n    $cartBadAppleItem = Item::make($cartBadAppleData);\n    $badAppleAdded = $container-\u003eaddItem($cartBadAppleItem); //-- returns false\n    \n    if (!$badAppleAdded) {\n        $errors = $container-\u003egetErrors();\n        // array(1) {\n        //    [\"does-not-exist\"]=\u003e string(33) \"Sorry this product \"i do not exist\" does not exist\"\n        // }\n    \n        foreach ($errors as $key =\u003e $error) {\n            echo '\"', $key, '\" - ', $error, PHP_EOL;\n        }\n    }\n\n## How To Build The Documentation\n\nYou will need python install on your computer.\n\n    cd docs\n    pip install -r requirements.txt\n    make","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoseph-montanez%2Fphpcartload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoseph-montanez%2Fphpcartload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoseph-montanez%2Fphpcartload/lists"}