setShippingMethodId example

private SalesChannelContext $context;

    private ShippingMethodRouteResponse $response;

    protected function setUp(): void
    {
        $this->decorated = $this->createMock(AbstractShippingMethodRoute::class);
        $this->executor = $this->createMock(ScriptExecutor::class);
        $salesChannel = new SalesChannelEntity();
        $salesChannel->setId(Uuid::randomHex());
        $salesChannel->setShippingMethodId(Uuid::randomHex());
        $shippingMethod = new ShippingMethodEntity();
        $shippingMethod->setId($salesChannel->getShippingMethodId());
        $this->context = new SalesChannelContext(
            new Context(new SalesChannelApiSource(Uuid::randomHex())),
            Uuid::randomHex(),
            null,
            $salesChannel,
            new CurrencyEntity(),
            new CustomerGroupEntity(),
            new TaxCollection(),
            new PaymentMethodEntity(),
            


        return $errorCollection;
    }

    private function getSalesChannelContext(bool $dontReturnDefaultShippingMethod = false): SalesChannelContext
    {
        $salesChannel = new SalesChannelEntity();
        $salesChannel->setId(TestDefaults::SALES_CHANNEL);
        $salesChannel->setLanguageId(Defaults::LANGUAGE_SYSTEM);
        if ($dontReturnDefaultShippingMethod) {
            $salesChannel->setShippingMethodId('not-a-valid-id');
        } else {
            $salesChannel->setShippingMethodId('default-shipping-method-id');
        }

        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $salesChannelContext->method('getSalesChannel')->willReturn($salesChannel);
        $salesChannelContext->method('getContext')->willReturn(Context::createDefaultContext());
        $salesChannelContext->method('getShippingMethod')->willReturn($this->shippingMethodCollection->get('original-shipping-method-id'));

        return $salesChannelContext;
    }

    
$paymentMethodId = Uuid::randomHex();
        $customerGroupId = Uuid::randomHex();
        $shippingMethodId = Uuid::randomHex();
        $currencyId = Uuid::randomHex();
        $countryStateId = Uuid::randomHex();
        $countryId = Uuid::randomHex();

        $salesChannelEntity = new SalesChannelEntity();
        $salesChannelEntity->setUniqueIdentifier(TestDefaults::SALES_CHANNEL);
        $salesChannelEntity->setCustomerGroupId($customerGroupId);
        $salesChannelEntity->setPaymentMethodId($paymentMethodId);
        $salesChannelEntity->setShippingMethodId($shippingMethodId);

        $currency = new CurrencyEntity();
        $rounding = new CashRoundingConfig(1, 1, true);
        $currency->setUniqueIdentifier($currencyId);
        $currency->setTotalRounding($rounding);
        $currency->setItemRounding($rounding);
        $currency->setId($currencyId);
        $currency->setFactor(1);

        $country = new CountryEntity();
        $country->setUniqueIdentifier($countryId);
        
$orderDeliveryPosition->setId('order-delivery-position-id-1');
        $orderDeliveryPosition->setOrderLineItem($orderLineItem);
        $orderDeliveryPosition->setPrice(new CalculatedPrice(1, 1, new CalculatedTaxCollection()new TaxRuleCollection()));
        $orderDeliveryPositionCollection->add($orderDeliveryPosition);

        // Order delivery         $orderDeliveryCollection = new OrderDeliveryCollection();
        $orderDelivery = new OrderDeliveryEntity();
        $orderDelivery->setId('order-delivery-id');
        $orderDelivery->setShippingDateEarliest(new \DateTimeImmutable());
        $orderDelivery->setShippingDateLatest(new \DateTimeImmutable());
        $orderDelivery->setShippingMethodId('order-delivery-shipping-method-id');
        $orderDelivery->setShippingOrderAddress($this->getOrderAddress());
        $orderDelivery->setShippingCosts(new CalculatedPrice(1, 1, new CalculatedTaxCollection()new TaxRuleCollection()));
        if ($toManipulate !== 'order-delivery-no-shipping-method') {
            $orderDelivery->setShippingMethod(new ShippingMethodEntity());
        }
        if ($toManipulate !== 'order-delivery-no-position') {
            $orderDelivery->setPositions($orderDeliveryPositionCollection);
        }
        if ($toManipulate !== 'order-no-order-deliveries') {
            $orderDeliveryCollection->add($orderDelivery);
        }

        
Home | Imprint | This part of the site doesn't use cookies.