sRefreshBasket example



        // Start session in frontend controllers         $session = $this->get('session');

        if ($cookieKey !== null) {
            $session->set($cookieKey$cookieValue);
        }

        // Refresh basket on currency change         if ($session->has('sBasketCurrency') && $shop->getCurrency()->getId() != $session->get('sBasketCurrency')) {
            Shopware()->Modules()->Basket()->sRefreshBasket();
        }

        // Upgrade template         if ($session->has('template') && !empty($session->get('Admin'))) {
            $repository = $this->get(ModelManager::class)->getRepository(Template::class);
            $template = $session->get('template');
            $template = $repository->findOneBy(['template' => $template]);

            $this->get(Enlight_Template_Manager::class)->setTemplateDir([]);

            if ($template !== null) {
                
->update(
                's_order_basket',
                [
                    'sessionID' => $this->session->get('sessionId'),
                ],
                [
                    'userID' => $this->session->get('sUserId'),
                    'modus' => 0,
                ]
            );

        $this->cart->sRefreshBasket();
    }

    private function canBeMigrated(): bool
    {
        return !$this->connection->createQueryBuilder()
            ->select('1')
            ->from('s_order_basket', 'cart')
            ->where('sessionId = :sessionId')
            ->setParameter('sessionId', $this->session->get('sessionId'))
            ->execute()
            ->fetchColumn();
    }
/** * Used during the checkout process * Returns the user to the shop homepage * If the user has a noAccount account, it is automatically logged out * * @return void */
    public function returnAction()
    {
        if ($this->View()->getAssign('sUserData')['additional']['user']['accountmode'] == 1) {
            $this->Request()->getSession()->clear();
            Shopware()->Modules()->Basket()->sRefreshBasket();
        }

        $this->redirect(['controller' => 'index']);
    }

    /** * If any external payment mean chooses by customer * Forward to payment page after order submitting * * @return void */
    
$modules = $this->container->get('modules');
        $customerData = $modules->Admin()->sGetUserData();
        $session = $this->container->get('session');

        if (\is_array($customerData)) {
            $session->offsetSet('sCountry', (int) $customerData['additional']['countryShipping']['id']);
            $session->offsetSet('sArea', (int) $customerData['additional']['countryShipping']['areaID']);
        }

        $this->container->get(ContextServiceInterface::class)->initializeContext();

        $modules->Basket()->sRefreshBasket();
    }

    private function forwardDownloadError(int $errorCode): void
    {
        $this->View()->assign('sErrorCode', $errorCode);

        $this->forward('downloads');
    }

    /** * @param array<string, mixed> $orderData * * @return array<string, mixed> */
$shop = Shopware()->Shop();

        $this->sSYSTEM->sUSERGROUP = $shop->getCustomerGroup()->getKey();
        $this->sSYSTEM->sUSERGROUPDATA = $shop->getCustomerGroup()->toArray();
        $this->sSYSTEM->sCurrency = $shop->getCurrency()->toArray();

        $this->contextService->initializeContext();

        $this->csrfTokenValidator->clearExistingCookie();

        if (!$this->config->get('clearBasketAfterLogout')) {
            $this->moduleManager->Basket()->sRefreshBasket();

            $countries = $this->sGetCountryList();
            $country = reset($countries);
            if (!\is_array($country)) {
                $country = null;
            }

            $this->sGetPremiumShippingcosts($country);

            $amount = $this->moduleManager->Basket()->sGetAmount();
            $this->session->offsetSet('sBasketAmount', empty($amount) ? 0 : array_shift($amount));
        }
Home | Imprint | This part of the site doesn't use cookies.