I’m trying to change shipping method in shopware6 programmatically, but I’m not succeeding. I will not get any error or exception, there just will not be changed anything.
class:
<?php declare(strict_types=1);
namespace WtShippingCalcCoreCheckoutCart;
use JetBrainsPhpStormNoReturn;
use ShopwareCoreCheckoutCartCart;
use ShopwareCoreCheckoutCartCartBehavior;
use ShopwareCoreCheckoutCartCartProcessorInterface;
use ShopwareCoreCheckoutCartLineItemCartDataCollection;
use ShopwareCoreSystemSystemConfigSystemConfigService;
use ShopwareCoreSystemSalesChannelSalesChannelContext;
use WtShippingCalcServiceContactDatabaseShipping;
use ShopwareCoreFrameworkContext;
use ShopwareCoreSystemSalesChannelSalesChannelSalesChannelContextSwitcher;
use ShopwareCoreFrameworkValidationDataBagDataBag;
class ShippingProcessor implements CartProcessorInterface
{
private SalesChannelContextSwitcher $contextSwitcher;
private SystemConfigService $systemConfigService;
private ContactDatabaseShipping $database;
public function __construct(SalesChannelContextSwitcher $contextSwitcher, SystemConfigService $systemConfigService, ContactDatabaseShipping $database)
{
$this->contextSwitcher = $contextSwitcher;
$this->systemConfigService = $systemConfigService;
$this->database = $database;
}
Any ideas, how to fix this issue?
3
Answers
first method:
second method:
third method: