1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
<?php
namespace Commercetools\Core\Model\Order;
use Commercetools\Core\Model\Cart\DiscountedLineItemPrice;
use Commercetools\Core\Model\Common\Context;
use Commercetools\Core\Model\Common\JsonObject;
use Commercetools\Core\Model\Common\Money;
use Commercetools\Core\Model\ShippingMethod\ShippingMethodReference;
use Commercetools\Core\Model\ShippingMethod\ShippingRate;
use Commercetools\Core\Model\TaxCategory\TaxCategoryReference;
use Commercetools\Core\Model\TaxCategory\TaxRate;
class ShippingInfoImportDraft extends JsonObject
{
const SHIPPING_METHOD_MATCH = 'MatchesCart';
const SHIPPING_METHOD_DONT_MATCH = 'DoesNotMatchCart';
public function fieldDefinitions()
{
return [
'shippingMethodName' => [static::TYPE => 'string'],
'price' => [static::TYPE => Money::class],
'shippingRate' => [static::TYPE => ShippingRate::class],
'taxRate' => [static::TYPE => TaxRate::class, static::OPTIONAL => true],
'taxCategory' => [static::TYPE => TaxCategoryReference::class, static::OPTIONAL => true],
'shippingMethod' => [static::TYPE => ShippingMethodReference::class, static::OPTIONAL => true],
'deliveries' => [static::TYPE => DeliveryCollection::class, static::OPTIONAL => true],
'discountedPrice' => [static::TYPE => DiscountedLineItemPrice::class, static::OPTIONAL => true],
'shippingMethodState' => [static::TYPE => 'string', static::OPTIONAL => true],
];
}
public static function ofNamePriceRateAndState(
$shippingMethodName,
Money $price,
ShippingRate $shippingRate,
$shippingMethodState,
$context = null
) {
return static::of($context)
->setShippingMethodName($shippingMethodName)
->setPrice($price)
->setShippingRate($shippingRate)
->setShippingMethodState($shippingMethodState);
}
}