-
-
Save AltayAkkus/409e0f51859859ed7a6e6bdb18bc5bc1 to your computer and use it in GitHub Desktop.
Example cart error with resubmit enabled in Shopware 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types=1); | |
namespace Shopware\Core\Checkout\Cart\Address\Error; | |
use Shopware\Core\Checkout\Cart\Error\Error; | |
/** | |
* @package checkout | |
*/ | |
class ShippingAddressBlockedError extends Error | |
{ | |
private const KEY = 'shipping-address-blocked'; | |
/** | |
* @var string | |
*/ | |
private $name; | |
public function __construct(string $name) | |
{ | |
$this->name = $name; | |
$this->message = sprintf( | |
'Shippings to shipping address %s are not possible.', | |
$name | |
); | |
parent::__construct($this->message); | |
} | |
public function getName(): string | |
{ | |
return $this->name; | |
} | |
public function blockOrder(): bool | |
{ | |
return true; | |
} | |
public function blockResubmit(): bool | |
{ | |
return false; | |
} | |
public function getKey(): string | |
{ | |
return sprintf('%s-%s', self::KEY, $this->name); | |
} | |
public function getLevel(): int | |
{ | |
return self::LEVEL_ERROR; | |
} | |
public function getMessageKey(): string | |
{ | |
return self::KEY; | |
} | |
public function getId(): string | |
{ | |
return $this->getKey(); | |
} | |
public function getParameters(): array | |
{ | |
return ['name' => $this->name]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment