Skip to content

Commit

Permalink
NTR: fix sw 6.4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalij Mik committed Oct 23, 2024
1 parent a1e8a43 commit 51a12aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 37 deletions.
31 changes: 0 additions & 31 deletions polyfill/Shopware/Core/Checkout/Cart/AbstractCartPersister.php

This file was deleted.

17 changes: 11 additions & 6 deletions src/Service/Cart/CartBackupService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Shopware\Core\Checkout\Cart\AbstractCartPersister;
use Shopware\Core\Checkout\Cart\Cart;
use Shopware\Core\Checkout\Cart\CartPersisterInterface;
use Shopware\Core\Checkout\Cart\LineItem\LineItemCollection;
use Shopware\Core\Checkout\Cart\SalesChannel\CartService;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
Expand All @@ -21,7 +22,7 @@ class CartBackupService
private $cartService;

/**
* @var AbstractCartPersister
* @var AbstractCartPersister|CartPersisterInterface
*/
private $cartPersister;
/**
Expand All @@ -30,12 +31,13 @@ class CartBackupService
private array $backupExistingCache;

/**
*
* @param CartService $cartService
* @param AbstractCartPersister|CartPersisterInterface $cartPersister
*/
public function __construct(CartService $cartService, AbstractCartPersister $cartPersister)
public function __construct(CartService $cartService, $cartPersister)
{
$this->cartService = $cartService;

$this->cartPersister = $cartPersister;
}

Expand Down Expand Up @@ -126,8 +128,11 @@ public function clearBackup(SalesChannelContext $context): void

public function replaceToken(string $oldToken, string $currentToken, SalesChannelContext $context): void
{
$oldToken = $this->getToken($oldToken);
$currentToken = $this->getToken($currentToken);
$this->cartPersister->replace($oldToken, $currentToken, $context);
#only cart persister has replace method, so it wont work in shopware 6.4.1.0
if ($this->cartPersister instanceof AbstractCartPersister) {
$oldToken = $this->getToken($oldToken);
$currentToken = $this->getToken($currentToken);
$this->cartPersister->replace($oldToken, $currentToken, $context);
}
}
}

0 comments on commit 51a12aa

Please sign in to comment.