Ecommerce cart types

On sites like Amazon I can add items to my cart or wish list before logging-in, but once logged-in the items are remembered even when using a different computer.

Is it possible to replicate this functionalit using Pimcore Ecommerce bundle? It seems like I have to use either session or database carts.

If I use a database cart it the user must log-in before adding anything to the cart. Does this mean I should always use session carts if I want users to be able to add items before logging-in (Log-in is required for checkout on my site)?

Works with CoreShop ;), you should give it a try

I am tempted however I’ve already spent a lot of time on the Ecommerce bundle. Our site is not primarily an ecommerce one. We don’t sell many products but each one we do sell works in a completely different way (usually bespoke and need to be customized before adding to the cart).

also possible with CoreShop :wink:

CoreShop comes with a big default implementation. If you don’t need a “default” commerce, cause you have custom price calculators or availability strategies, you can implement all of that yourself. CoreShop will then only handle very basic stuff for you.

yes, this is possible with ecommerce framework as well. Code snippet would look something like this:

        // init ecommerce framework
        $env = \Pimcore\Bundle\EcommerceFrameworkBundle\Factory::getInstance()->getEnvironment();

        // get session cart
        $sessionCart = \AppBundle\Website\Facade::getCurrentCart();

        // set current user
        $env->setCurrentUserId( $customer->getId() );
        $env->setUseGuestCart( false );

        // move cart items from session to the new cart
        if($sessionCart instanceof SessionCart && count($sessionCart->getItems()) > 0)
            $newCart = \AppBundle\Website\Facade::getCurrentCart();
            foreach($sessionCart->getItems() as $item)
                $newCart->addItem( $item->getProduct(), $item->getCount() );


Great, thanks fash.

Should I be okay to call this from an event subscriber on security.interactive.login event?

@dpfaffenbauer - full marks for the shameless plugs for Core Shop. Would definitely have given it a go if I hadn’t already invested so much time in Pimcore’s Ecommerce bundle :slight_smile: