createShippingMethod example



        $this->createLanguage($connection);
        $this->createLocale($connection);

        $this->createDocumentTypes($connection);
        $this->createSalutation($connection);
        $this->createCountry($connection);
        $this->createCurrency($connection);
        $this->createCustomerGroup($connection);
        $this->createPaymentMethod($connection);
        $this->createShippingMethod($connection);
        $this->createTax($connection);
        $this->createRootCategory($connection);
        $this->createSalesChannelTypes($connection);
        $this->createSalesChannel($connection);
        $this->createProductManufacturer($connection);
        $this->createDefaultSnippetSets($connection);
        $this->createDefaultMediaFolders($connection);
        $this->createRules($connection);
        $this->createMailTemplateTypes($connection);
        $this->createNewsletterMailTemplate($connection);
        $this->createDocumentConfiguration($connection);
        
public function testHandlingTaxFreeInStorefrontWithBaseCurrencyEuro(
        string $testCase,
        float $currencyTaxFreeFrom,
        bool $countryTaxFree,
        bool $countryCompanyTaxFree,
        float $countryTaxFreeFrom,
        float $countryCompanyTaxFreeFrom,
        int $quantity,
        ?array $vatIds = null,
        bool $checkVatIdPattern = true
    ): void {
        $this->createShippingMethod();

        $this->browser = $this->createCustomSalesChannelBrowser([
            'id' => $this->ids->create('sales-channel'),
            'shippingMethodId' => $this->ids->get('shipping'),
        ]);

        $this->browser->setServerParameter('HTTP_SW_CONTEXT_TOKEN', $this->ids->create('token'));

        $this->createProduct();

        $countryId = Uuid::fromBytesToHex($this->getCountryIdByIso());

        
public function testOrderCartDe(): void
    {
        $context = Context::createDefaultContext();
        $customerId = $this->createCustomer($context);

        $cartService = $this->getContainer()->get(CartService::class);

        $options = [
            SalesChannelContextService::LANGUAGE_ID => $this->getDeDeLanguageId(),
            SalesChannelContextService::CUSTOMER_ID => $customerId,
            SalesChannelContextService::SHIPPING_METHOD_ID => $this->createShippingMethod(),
        ];

        $salesChannelContext = $this->getContainer()->get(SalesChannelContextFactory::class)
            ->create(Uuid::randomHex(), TestDefaults::SALES_CHANNEL, $options);

        $productId = Uuid::randomHex();
        $product = [
            'id' => $productId,
            'productNumber' => $productId,
            'name' => [
                'de-DE' => 'test',
                
protected string $customerId;

    protected function setUp(): void
    {
        parent::setUp();
        $this->context = Context::createDefaultContext();

        $priceRuleId = Uuid::randomHex();

        $this->customerId = $this->createCustomer();
        $shippingMethodId = $this->createShippingMethod($priceRuleId);
        $paymentMethodId = $this->createPaymentMethod($priceRuleId);
        $this->addCountriesToSalesChannel([$this->getValidCountryIdWithTaxes()]);
        $this->salesChannelContext = $this->getContainer()->get(SalesChannelContextFactory::class)->create(
            Uuid::randomHex(),
            TestDefaults::SALES_CHANNEL,
            [
                SalesChannelContextService::CUSTOMER_ID => $this->customerId,
                SalesChannelContextService::SHIPPING_METHOD_ID => $shippingMethodId,
                SalesChannelContextService::PAYMENT_METHOD_ID => $paymentMethodId,
            ]
        );

        
private CartService $cartService;

    private DocumentGenerator $documentGenerator;

    protected function setUp(): void
    {
        parent::setUp();

        $this->context = Context::createDefaultContext();

        $priceRuleId = Uuid::randomHex();
        $shippingMethodId = $this->createShippingMethod($priceRuleId);
        $paymentMethodId = $this->createPaymentMethod($priceRuleId);

        $this->salesChannelContext = $this->getContainer()->get(SalesChannelContextFactory::class)->create(
            Uuid::randomHex(),
            TestDefaults::SALES_CHANNEL,
            [
                SalesChannelContextService::CUSTOMER_ID => $this->createCustomer(),
                SalesChannelContextService::SHIPPING_METHOD_ID => $shippingMethodId,
                SalesChannelContextService::PAYMENT_METHOD_ID => $paymentMethodId,
            ]
        );

        
$cart = $this->getCart($browser, TestDefaults::SALES_CHANNEL);

        // assert shipping costs in cart         static::assertArrayHasKey('unitPrice', $cart['deliveries'][0]['shippingCosts']);
        static::assertEquals(20, $cart['deliveries'][0]['shippingCosts']['unitPrice']);

        static::assertArrayHasKey('totalPrice', $cart['deliveries'][0]['shippingCosts']);
        static::assertEquals(20, $cart['deliveries'][0]['shippingCosts']['totalPrice']);

        // create a new shipping method and request to change         $shippingMethodId = $this->createShippingMethod();

        $browser->request(
            'PATCH',
            $this->getUrl(TestDefaults::SALES_CHANNEL, '/context'),
            [],
            [],
            [],
            json_encode([
                'shippingMethodId' => $shippingMethodId,
            ], \JSON_THROW_ON_ERROR) ?: ''
        );

        
static::assertContains($ids->get('position2')$affected['order_delivery_position']);
    }

    public function testOnlyIncludesAffectedDeleteRestrictionsWithDirectRelation(): void
    {
        $ids = new IdsCollection();
        $context = Context::createDefaultContext();

        $ruleDefinition = $this->getContainer()->get(RuleDefinition::class);

        $this->createRule($ids);
        $this->createShippingMethod($ids);
        $this->createSalesChannel($ids);

        $deleteIds = [
            'id' => $ids->get('rule'),
        ];

        $affected = $this->getContainer()->get(EntityForeignKeyResolver::class)
            ->getAffectedDeleteRestrictions($ruleDefinition$deleteIds$context, true);

        static::assertCount(1, $affected);
        static::assertArrayHasKey('shipping_method', $affected);
        
Home | Imprint | This part of the site doesn't use cookies.