PHPackages                             integer-net/magento2-addtocartgraphql - 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. [API Development](/categories/api)
4. /
5. integer-net/magento2-addtocartgraphql

ActiveMagento2-module[API Development](/categories/api)

integer-net/magento2-addtocartgraphql
=====================================

This module provides support to add products to cart via GraphQl

3611HTML

Since Jan 7Pushed 1y ago6 watchersCompare

[ Source](https://github.com/integer-net/magento2-addtocartgraphql)[ Packagist](https://packagist.org/packages/integer-net/magento2-addtocartgraphql)[ RSS](/packages/integer-net-magento2-addtocartgraphql/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

IntegerNet\_AddToCartGraphQl Magento Module
===========================================

[](#integernet_addtocartgraphql-magento-module)

[![Latest Version on Packagist](https://camo.githubusercontent.com/81e9ffa3df6e58094c107db610ef75e0ba1acaae9dd5107c6aeeaf9924449bf9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e74656765722d6e65742f6d6167656e746f322d616464746f636172746772617068716c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/integer-net/magento2-addtocartgraphql)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/71e2ac0436d9ff301a88e0a559b18595685284704c615981b50bb2eeff9c6c16/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f696e74656765722d6e65742f6d6167656e746f322d616464746f636172746772617068716c2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/integer-net/magento2-addtocartgraphql)[![Supported Magento Versions](https://camo.githubusercontent.com/2113b3a30955562f026a2b7dda3a09fee30d0c49aacbfce67193c5dc7b434617/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d6167656e746f2d322e342d627269676874677265656e2e7376673f6c6f676f3d6d6167656e746f266c6f6e6743616368653d74727565267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/2113b3a30955562f026a2b7dda3a09fee30d0c49aacbfce67193c5dc7b434617/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d6167656e746f2d322e342d627269676874677265656e2e7376673f6c6f676f3d6d6167656e746f266c6f6e6743616368653d74727565267374796c653d666c61742d737175617265)

[![Coverage Status](https://camo.githubusercontent.com/6e2ec02efdaf0722e9cb22cc7c0eb9346de2160b0876e328c642493ef10e582c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f696e74656765722d6e65742f6d6167656e746f322d616464746f636172746772617068716c3f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/integer-net/magento2-addtocartgraphql/code-structure)[![Quality Score](https://camo.githubusercontent.com/ef26fe650e88e1b0db1353f44b597ec1da778acd897a9da1b404c0d45773987e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f696e74656765722d6e65742f6d6167656e746f322d616464746f636172746772617068716c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/integer-net/magento2-addtocartgraphql)[![Maintainability](https://camo.githubusercontent.com/d0be104e7ca5144b68c548b0e14f439ee41b1a0fc2a66e0de83dcccf5103eae1/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f696e74656765722d6e65742f6d6167656e746f322d616464746f636172746772617068716c3f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/integer-net/magento2-addtocartgraphql)

---

This module provides support to add products to cart via GraphQl. For this to be available for guests, it is needed to force quote creation, which is done upon first checkout session creation.

Installation
------------

[](#installation)

1. Install it into your Magento 2 project with composer:

    ```
    composer require integer-net/magento2-addtocartgraphql

    ```
2. Enable module

    ```
    bin/magento setup:upgrade

    ```

For your reference, there is also an add to cart snippet included.

Usage
-----

[](#usage)

### Configurable Products (Hyvä)

[](#configurable-products-hyvä)

Please mind: if you plan to use this for configurable products in the Hyvä theme, you need to pass the product selection to the addtocart component.

The easiest way is to add a method to Magento\_ConfigurableProduct/templates/product/view/type/options/js/configurable-options.phtml

```
    updateCurrentSelection() {
        window.dispatchEvent(
            new CustomEvent(
                "update-currentSelection-" + this.productId,
                {
                    detail: this.selectedValues
                }
            )
        );
    },

```

This should be called whenever a selection is made, in Hyvä default you would prepend its call to the method

```
changeOption(optionId, value) {
    [...]
    this.updateCurrentSelection()
}

```

### Default Qty (Hyvä)

[](#default-qty-hyvä)

The default qty on init of add to cart button is set to 1 - ideally, you would rather change `Magento_Catalog/templates/product/view/quantity.phtml` to dispatch `updateChangeQty` on init, as addtocart component already listens to this event - this way, you would always get the correct default qty.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Testing
-------

[](#testing)

### Unit Tests

[](#unit-tests)

```
./vendor/bin/phpunit tests/unit

```

### Magento Integration Tests

[](#magento-integration-tests)

1. Configure test database in `dev/tests/integration/etc/install-config-mysql.php`. [Read more in the Magento docs.](https://devdocs.magento.com/guides/v2.4/test/integration/integration_test_execution.html)
2. Copy `tests/integration/phpunit.xml.dist` from the package to `dev/tests/integration/phpunit.xml` in your Magento installation.
3. In that directory, run

    ```
    ../../../vendor/bin/phpunit
    ```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Lisa Buchholz](https://github.com/lbuchholz)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

Top contributor holds 62.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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/78e73cb79c6200c1d74eb632e79da9d227041735160b9795a1146537ba58f386?d=identicon)[integer-net](/maintainers/integer-net)

---

Top Contributors

[![schmengler](https://avatars.githubusercontent.com/u/367320?v=4)](https://github.com/schmengler "schmengler (5 commits)")[![lbuchholz](https://avatars.githubusercontent.com/u/2143086?v=4)](https://github.com/lbuchholz "lbuchholz (3 commits)")

### Embed Badge

![Health badge](/badges/integer-net-magento2-addtocartgraphql/health.svg)

```
[![Health](https://phpackages.com/badges/integer-net-magento2-addtocartgraphql/health.svg)](https://phpackages.com/packages/integer-net-magento2-addtocartgraphql)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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