Coder Social home page Coder Social logo

demo-cart's Issues

Adding UserEventHandler causes no items to be added to cart

Hello,

I'm currently having an issue with the UserEventHandler, on a laravel 5.1 application.
Everything up until the point to added this class is working fine. Ie: added / removing / updating items to the cart.

Now I would like to sync these carts to the database, when a user logs in.

When adding the UserEventHandler class to the $subscribe property, no more items are added to the carts.

I don't why this is, as the method onUserAuthenticated is not called when already logged in / or when not yet logged in. Yet it prevents items to be added to the cart.

Did I miss something ?

Thank you

DbSync: Cart coupons/vat not stored

Hello,

I see this demo doesn't handle storing the cart coupon/vat amounts in database. Meaning that if I come back to the site a day later, and I'm logged out with an empty cart, if I log back in, my cart is synced, but without any vat or coupons applied.

Would you have any suggestions on to how to handle this ?

Thanks

Problem with the UserEventHandler

So today i have used to merge the new events tweak into my eCommerce project and i got this error raised by UserEventHandler.php:

Argument 1 passed to App\Handlers\UserEventHandler::onUserAuthenticated() must be an instance of Cartalyst\Sentinel\Users\EloquentUser, instance of User given

In the past I have to Override the User Model with the Platform User Model instead of Sentinel to be able to use the Cart package:

$app['Platform\Users\Models\User'] = new User;

So I guess the error is caused by the Override action but still didn't know how to fix this one.

Wrong item quantity after sync back from database

So I just find out that when the cart getting synced back from database it will use the static quantity here:

if (count($search) === 0)
                {
                    $items[$_cart->instance][] = [
                        'id'       => $id,
                        'name'     => $item->product->name,
                        'price'    => $item->product->price,
                        'quantity' => 1,
                    ];
                }

for example cart_items table have an item with quantity of 5, if user logged in it will sync with the quantity of 1 instead, and the database still have 5 unless i do Cart::update

Problem Demo installation via composer

Hi, I'm using php 7.4, when I try to install the demo and run the composer install command, I get this error

Generating optimized autoload files
Deprecation Notice: Class Cartalyst\Cart\Exceptions\CartInvalidAttributesException located in ./vendor/cartalyst/cart/src/Exceptions.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Cartalyst\Cart\Exceptions\CartInvalidPriceException located in ./vendor/cartalyst/cart/src/Exceptions.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Cartalyst\Cart\Exceptions\CartInvalidQuantityException located in ./vendor/cartalyst/cart/src/Exceptions.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Cartalyst\Cart\Exceptions\CartItemNotFoundException located in ./vendor/cartalyst/cart/src/Exceptions.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Cartalyst\Cart\Exceptions\CartMissingRequiredIndexException located in ./vendor/cartalyst/cart/src/Exceptions.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   ErrorException  : Trying to access array offset on value of type null

  at /Applications/MAMP/htdocs/cartalyst/cart/app/Providers/AppServiceProvider.php:21
    17|     {
    18|         $this->app->singleton('wishlist', function ($app) {
    19|             $config = $app['config']->get('cartalyst/cart::config');
    20| 
  > 21|             $storage = new IlluminateSession($app['session.store'], 'wishlist', $config['session_key']);
    22| 
    23|             return new Cart($storage, $app['events']);
    24|         });
    25|     }

  Exception trace:

  1   Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Trying to access array offset on value of type null", "/Applications/MAMP/htdocs/cartalyst/cart/app/Providers/AppServiceProvider.php", [Object(Illuminate\Foundation\Application)])
      /Applications/MAMP/htdocs/cartalyst/cart/app/Providers/AppServiceProvider.php:21

  2   App\Providers\AppServiceProvider::App\Providers\{closure}(Object(Illuminate\Foundation\Application), [])
      /Applications/MAMP/htdocs/cartalyst/cart/vendor/laravel/framework/src/Illuminate/Container/Container.php:799

  Please use the argument -v to see more details.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Cloning failed

Hi,
I am trying to install the cartalyst/cart for my laravel application and I am getting downloading failed error, The error is as follows.

Downloading: connection...Failed to download cartalyst/conditions from dist: The "https://api.gi
thub.com/repos/cartalyst/conditions/zipball/2c62887ae04e18b0219ed5c2455898629d06b3fd" file        could not be downloaded (HTTP/1.1 404 Not Found)

Restore Items from Database

So using this as a base, i have replicated the database sync, but upon connecting to the application with a new browser and using the same user, the cart is empty on the one instance and has something in there on the other instance

Problem i see is if i grab the information out of the database for the cart/user instance, it will re-call the same events that sync the cart, and will duplicate the products and i will end up with a merged quantity between the two.

If there any real way to get around this issue?

Weird bug?

I was busy with syncing carts with logged in users just like the demo code... I noticed something something weird.

https://github.com/cartalyst/demo-cart/blob/6.x/app/Listeners/UserEventListener.php#L60

this code works

public function subscribe(Dispatcher $dispatcher): void
    {
        $dispatcher->listen('Illuminate\Auth\Events\Login', __CLASS__ . '@onUserAuthenticated');
    }

The cart is synced and the items in the database is also synced... But when I use a closure, this doesnt seem to work anymore...

public function subscribe(Dispatcher $dispatcher): void
    {
        $dispatcher->listen('Illuminate\Auth\Events\Login', function ($event) {
            $this->onUserAuthenticated();
        });
    }

Any idea why this is not working?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.