Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setShippingMethod example
$currency
->
setFactor
(
1
)
;
$country
=
new
CountryEntity
(
)
;
$country
->
setUniqueIdentifier
(
$countryId
)
;
$country
->
setId
(
$countryId
)
;
$paymentMethod
=
new
PaymentMethodEntity
(
)
;
$paymentMethod
->
setUniqueIdentifier
(
$paymentMethodId
)
;
$shippingMethod
=
new
ShippingMethodEntity
(
)
;
$shippingMethod
->
setUniqueIdentifier
(
$shippingMethodId
)
;
$salesChannelEntity
->
setShippingMethod
(
$shippingMethod
)
;
$customerGroup
=
new
CustomerGroupEntity
(
)
;
$customerGroup
->
setUniqueIdentifier
(
$customerGroupId
)
;
yield
'no context data' =>
[
'options' =>
[
]
,
'fetchDataResult' => false,
'fetchParentLanguageResult' => false,
'entitySearchResult' =>
[
]
,
'exceptionMessage' =>
sprintf
(
'No context data found for SalesChannel "%s"', TestDefaults::SALES_CHANNEL
)
,
]
;
// 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
)
;
}
// Transactions
$orderTransactionCollection
=
new
OrderTransactionCollection
(
)
;