Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getStreet example
return
RuleComparison::
isNegativeOperator
(
$this
->operator
)
;
}
if
(
!
$address
=
$customer
->
getActiveBillingAddress
(
)
)
{
return
RuleComparison::
isNegativeOperator
(
$this
->operator
)
;
}
if
(
!\
is_string
(
$this
->streetName
)
&&
$this
->operator !== self::OPERATOR_EMPTY
)
{
throw
new
UnsupportedValueException
(
\
gettype
(
$this
->streetName
)
, self::
class
)
;
}
return
RuleComparison::
string
(
$address
->
getStreet
(
)
,
$this
->streetName ?? '',
$this
->operator
)
;
}
public
function
getConstraints
(
)
: array
{
$constraints
=
[
'operator' => RuleConstraints::
stringOperators
(
)
,
]
;
if
(
$this
->operator === self::OPERATOR_EMPTY
)
{
return
$constraints
;
}
if
(
!\
is_array
(
$debitData
)
)
{
$debitData
=
[
]
;
}
$date
=
new
DateTime
(
)
;
$data
=
[
'payment_mean_id' =>
$paymentId
,
'order_id' =>
$orderId
,
'user_id' =>
$userId
,
'firstname' =>
$addressData
->
getFirstname
(
)
,
'lastname' =>
$addressData
->
getLastname
(
)
,
'address' =>
$addressData
->
getStreet
(
)
,
'zipcode' =>
$addressData
->
getZipcode
(
)
,
'city' =>
$addressData
->
getCity
(
)
,
'account_number' =>
$debitData
[
'sDebitAccount'
]
,
'bank_code' =>
$debitData
[
'sDebitBankcode'
]
,
'bank_name' =>
$debitData
[
'sDebitBankName'
]
,
'account_holder' =>
$debitData
[
'sDebitBankHolder'
]
,
'amount' =>
$orderAmount
,
'created_at' =>
$date
->
format
(
'Y-m-d'
)
,
]
;
Shopware
(
)
->
Db
(
)
->
insert
(
's_core_payment_instance',
$data
)
;
$addressData
=
Shopware
(
)
->
Models
(
)
->
getRepository
(
Customer::
class
)
->
find
(
$userId
)
->
getDefaultBillingAddress
(
)
;
$date
=
new
DateTime
(
)
;
$data
=
[
'payment_mean_id' =>
$paymentId
,
'order_id' =>
$orderId
,
'user_id' =>
$userId
,
'firstname' =>
$addressData
->
getFirstname
(
)
,
'lastname' =>
$addressData
->
getLastname
(
)
,
'address' =>
$addressData
->
getStreet
(
)
,
'zipcode' =>
$addressData
->
getZipcode
(
)
,
'city' =>
$addressData
->
getCity
(
)
,
'amount' =>
$orderAmount
,
'created_at' =>
$date
->
format
(
'Y-m-d'
)
,
]
;
Shopware
(
)
->
Db
(
)
->
insert
(
's_core_payment_instance',
$data
)
;
return
true;
}
}
'title' =>
$customer
->
getTitle
(
)
,
'salutation' =>
$customer
->
getSalutation
(
)
,
'firstname' =>
$customer
->
getFirstname
(
)
,
'lastname' =>
$customer
->
getLastname
(
)
,
'birthday' =>
$this
->
formatDate
(
$customer
->
getBirthday
(
)
)
,
'customernumber' =>
$customer
->
getNumber
(
)
,
'customer_group_id' =>
$customer
->
getCustomerGroup
(
)
?
$customer
->
getCustomerGroup
(
)
->
getId
(
)
: null,
'customer_group_name' =>
$customer
->
getCustomerGroup
(
)
?
$customer
->
getCustomerGroup
(
)
->
getName
(
)
: '',
'payment_id' =>
$customer
->
getPaymentId
(
)
,
'company' =>
$customer
->
getBillingAddress
(
)
?
$customer
->
getBillingAddress
(
)
->
getCompany
(
)
: '',
'department' =>
$customer
->
getBillingAddress
(
)
?
$customer
->
getBillingAddress
(
)
->
getDepartment
(
)
: '',
'street' =>
$customer
->
getBillingAddress
(
)
?
$customer
->
getBillingAddress
(
)
->
getStreet
(
)
: '',
'zipcode' =>
$customer
->
getBillingAddress
(
)
?
$customer
->
getBillingAddress
(
)
->
getZipcode
(
)
: '',
'city' =>
$customer
->
getBillingAddress
(
)
?
$customer
->
getBillingAddress
(
)
->
getCity
(
)
: '',
'phone' =>
$customer
->
getBillingAddress
(
)
?
$customer
->
getBillingAddress
(
)
->
getPhone
(
)
: '',
'additional_address_line1' =>
$customer
->
getBillingAddress
(
)
?
$customer
->
getBillingAddress
(
)
->
getAdditionalAddressLine1
(
)
: '',
'additional_address_line2' =>
$customer
->
getBillingAddress
(
)
?
$customer
->
getBillingAddress
(
)
->
getAdditionalAddressLine2
(
)
: '',
'country_id' =>
$customer
->
getBillingAddress
(
)
?
$customer
->
getBillingAddress
(
)
->
getCountryId
(
)
: null,
'country_name' =>
$customer
->
getBillingAddress
(
)
?
$customer
->
getBillingAddress
(
)
->
getCountry
(
)
->
getName
(
)
: '',
'state_id' =>
$customer
->
getBillingAddress
(
)
?
$customer
->
getBillingAddress
(
)
->
getStateId
(
)
: '',
'age' =>
$customer
->
getAge
(
)
,
'count_orders' =>
(int)
$customer
->
getOrderInformation
(
)
->
getOrderCount
(
)
,
'product_avg' =>
(float)
$customer
->
getOrderInformation
(
)
->
getAvgProductPrice
(
)
,
]
)
;
}
,
function
DRenderedDocument
$rendered
, OrderEntity
$order
)
: void
{
static
::
assertNotNull
(
$orderDeliveries
=
$order
->
getDeliveries
(
)
)
;
$shippingAddress
=
$orderDeliveries
->
getShippingAddress
(
)
->
first
(
)
;
static
::
assertNotNull
(
$shippingAddress
)
;
$rendered
=
$rendered
->
getHtml
(
)
;
static
::
assertStringContainsString
(
'Shipping address',
$rendered
)
;
static
::
assertStringContainsString
(
$shippingAddress
->
getStreet
(
)
,
$rendered
)
;
static
::
assertStringContainsString
(
$shippingAddress
->
getCity
(
)
,
$rendered
)
;
static
::
assertStringContainsString
(
$shippingAddress
->
getFirstName
(
)
,
$rendered
)
;
static
::
assertStringContainsString
(
$shippingAddress
->
getLastName
(
)
,
$rendered
)
;
static
::
assertStringContainsString
(
$shippingAddress
->
getZipcode
(
)
,
$rendered
)
;
static
::
assertStringContainsString
(
'Intra-community delivery (EU)',
$rendered
)
;
static
::
assertStringContainsString
(
'123123123',
$rendered
)
;
}
,
]
;
yield
'render with billing address' =>
[
[
7
]
,
return
false;
}
if
(
!
$location
=
$scope
->
getSalesChannelContext
(
)
->
getShippingLocation
(
)
->
getAddress
(
)
)
{
return
RuleComparison::
isNegativeOperator
(
$this
->operator
)
;
}
if
(
!\
is_string
(
$this
->streetName
)
&&
$this
->operator !== self::OPERATOR_EMPTY
)
{
throw
new
UnsupportedValueException
(
\
gettype
(
$this
->streetName
)
, self::
class
)
;
}
return
RuleComparison::
string
(
$location
->
getStreet
(
)
,
$this
->streetName ?? '',
$this
->operator
)
;
}
public
function
getConstraints
(
)
: array
{
$constraints
=
[
'operator' => RuleConstraints::
stringOperators
(
)
,
]
;
if
(
$this
->operator === self::OPERATOR_EMPTY
)
{
return
$constraints
;
}
$dataBag
->
set
(
'lastName',
$customer
->
getLastName
(
)
)
;
$dataBag
->
set
(
'zipCode',
$customer
->
getDefaultShippingAddress
(
)
?
$customer
->
getDefaultShippingAddress
(
)
->
getZipCode
(
)
: ''
)
;
$dataBag
->
set
(
'city',
$customer
->
getDefaultShippingAddress
(
)
?
$customer
->
getDefaultShippingAddress
(
)
->
getCity
(
)
: ''
)
;
$dataBag
->
set
(
'street',
$customer
->
getDefaultShippingAddress
(
)
?
$customer
->
getDefaultShippingAddress
(
)
->
getStreet
(
)
: ''
)
;
return
$dataBag
;
}
}
$output
=
Shopware
(
)
->
Models
(
)
->
toArray
(
$address
)
;
$output
=
array_merge
(
$output
,
[
'id' =>
$address
->
getId
(
)
,
'userID' =>
$address
->
getCustomer
(
)
->
getId
(
)
,
'company' =>
$address
->
getCompany
(
)
,
'department' =>
$address
->
getDepartment
(
)
,
'salutation' =>
$address
->
getSalutation
(
)
,
'title' =>
$address
->
getTitle
(
)
,
'firstname' =>
$address
->
getFirstname
(
)
,
'lastname' =>
$address
->
getLastname
(
)
,
'street' =>
$address
->
getStreet
(
)
,
'zipcode' =>
$address
->
getZipcode
(
)
,
'city' =>
$address
->
getCity
(
)
,
'phone' =>
$address
->
getPhone
(
)
,
'countryID' =>
$address
->
getCountry
(
)
->
getId
(
)
,
'stateID' =>
$address
->
getState
(
)
?
$address
->
getState
(
)
->
getId
(
)
: null,
'ustid' =>
$address
->
getVatId
(
)
,
'additional_address_line1' =>
$address
->
getAdditionalAddressLine1
(
)
,
'additional_address_line2' =>
$address
->
getAdditionalAddressLine2
(
)
,
'attributes' =>
[
]
,
]
)
;
public
static
function
transform
(
CustomerAddressEntity
$address
)
: array
{
return
array_filter
(
[
'id' => Uuid::
randomHex
(
)
,
'company' =>
$address
->
getCompany
(
)
,
'department' =>
$address
->
getDepartment
(
)
,
'salutationId' =>
$address
->
getSalutationId
(
)
,
'title' =>
$address
->
getTitle
(
)
,
'firstName' =>
$address
->
getFirstName
(
)
,
'lastName' =>
$address
->
getLastName
(
)
,
'street' =>
$address
->
getStreet
(
)
,
'zipcode' =>
$address
->
getZipcode
(
)
,
'city' =>
$address
->
getCity
(
)
,
'phoneNumber' =>
$address
->
getPhoneNumber
(
)
,
'additionalAddressLine1' =>
$address
->
getAdditionalAddressLine1
(
)
,
'additionalAddressLine2' =>
$address
->
getAdditionalAddressLine2
(
)
,
'countryId' =>
$address
->
getCountryId
(
)
,
'countryStateId' =>
$address
->
getCountryStateId
(
)
,
'customFields' =>
$address
->
getCustomFields
(
)
,
]
)
;
}
}
/** @var OrderEntity $order */
$order
=
$this
->
getContainer
(
)
->
get
(
'order.repository'
)
->
search
(
$criteria
,
$this
->context->
createWithVersionId
(
$versionId
)
)
->
get
(
$orderId
)
;
static
::
assertNotNull
(
$order
)
;
static
::
assertNotNull
(
$order
->
getAddresses
(
)
)
;
/** @var OrderAddressEntity $orderAddress */
$orderAddress
=
$order
->
getAddresses
(
)
->
first
(
)
;
static
::
assertSame
(
$orderAddressId
,
$orderAddress
->
getId
(
)
)
;
static
::
assertSame
(
$firstName
,
$orderAddress
->
getFirstName
(
)
)
;
static
::
assertSame
(
$lastName
,
$orderAddress
->
getLastName
(
)
)
;
static
::
assertSame
(
$street
,
$orderAddress
->
getStreet
(
)
)
;
static
::
assertSame
(
$city
,
$orderAddress
->
getCity
(
)
)
;
static
::
assertSame
(
$zipcode
,
$orderAddress
->
getZipcode
(
)
)
;
}
protected
function
getValidCountryIdWithTaxes
(
)
: string
{
/** @var EntityRepository $repository */
$repository
=
$this
->
getContainer
(
)
->
get
(
'country.repository'
)
;
$countryId
=
$this
->
getValidCountryId
(
)
;
/** * Transfer values from the new address object */
public
function
fromAddress
(
Address
$address
)
{
$this
->
setCompany
(
(string)
$address
->
getCompany
(
)
)
;
$this
->
setDepartment
(
(string)
$address
->
getDepartment
(
)
)
;
$this
->
setSalutation
(
(string)
$address
->
getSalutation
(
)
)
;
$this
->
setFirstName
(
(string)
$address
->
getFirstname
(
)
)
;
$this
->
setLastName
(
(string)
$address
->
getLastname
(
)
)
;
$this
->
setStreet
(
(string)
$address
->
getStreet
(
)
)
;
$this
->
setCity
(
(string)
$address
->
getCity
(
)
)
;
$this
->
setZipCode
(
(string)
$address
->
getZipcode
(
)
)
;
$this
->
setAdditionalAddressLine1
(
(string)
$address
->
getAdditionalAddressLine1
(
)
)
;
$this
->
setAdditionalAddressLine2
(
(string)
$address
->
getAdditionalAddressLine2
(
)
)
;
$this
->
setCountry
(
$address
->
getCountry
(
)
)
;
$this
->
setPhone
(
$address
->
getPhone
(
)
)
;
$this
->
setTitle
(
$address
->
getTitle
(
)
)
;
if
(
$address
->
getState
(
)
)
{
$this
->
setState
(
$address
->
getState
(
)
)
;
}
else
{
$this
->
setState
(
null
)
;
}
/** * Transfer values from the new address object */
public
function
fromAddress
(
Address
$address
)
{
$this
->
setCompany
(
(string)
$address
->
getCompany
(
)
)
;
$this
->
setDepartment
(
(string)
$address
->
getDepartment
(
)
)
;
$this
->
setSalutation
(
(string)
$address
->
getSalutation
(
)
)
;
$this
->
setFirstName
(
(string)
$address
->
getFirstname
(
)
)
;
$this
->
setLastName
(
(string)
$address
->
getLastname
(
)
)
;
$this
->
setStreet
(
(string)
$address
->
getStreet
(
)
)
;
$this
->
setCity
(
(string)
$address
->
getCity
(
)
)
;
$this
->
setZipCode
(
(string)
$address
->
getZipcode
(
)
)
;
$this
->
setAdditionalAddressLine1
(
(string)
$address
->
getAdditionalAddressLine1
(
)
)
;
$this
->
setAdditionalAddressLine2
(
(string)
$address
->
getAdditionalAddressLine2
(
)
)
;
$this
->
setCountry
(
$address
->
getCountry
(
)
)
;
$this
->
setPhone
(
(string)
$address
->
getPhone
(
)
)
;
$this
->
setVatId
(
(string)
$address
->
getVatId
(
)
)
;
$this
->
setTitle
(
$address
->
getTitle
(
)
)
;
if
(
$address
->
getState
(
)
)
{
$this
->
setState
(
$address
->
getState
(
)
)
;
}
private
function
validateRecipientData
(
NewsletterRecipientEntity
$recipientEntry
)
: void
{
static
::
assertSame
(
$this
->customerData
[
'email'
]
,
$recipientEntry
->
getEmail
(
)
)
;
static
::
assertSame
(
$this
->customerData
[
'salutationId'
]
,
$recipientEntry
->
getSalutationId
(
)
)
;
static
::
assertSame
(
$this
->customerData
[
'title'
]
,
$recipientEntry
->
getTitle
(
)
)
;
static
::
assertSame
(
$this
->customerData
[
'firstName'
]
,
$recipientEntry
->
getFirstName
(
)
)
;
static
::
assertSame
(
$this
->customerData
[
'lastName'
]
,
$recipientEntry
->
getLastName
(
)
)
;
static
::
assertSame
(
$this
->customerData
[
'defaultShippingAddress'
]
[
'zipcode'
]
,
$recipientEntry
->
getZipCode
(
)
)
;
static
::
assertSame
(
$this
->customerData
[
'defaultShippingAddress'
]
[
'city'
]
,
$recipientEntry
->
getCity
(
)
)
;
static
::
assertSame
(
$this
->customerData
[
'defaultShippingAddress'
]
[
'street'
]
,
$recipientEntry
->
getStreet
(
)
)
;
}
}
$this
->validationContext =
$this
->validator->
startContext
(
)
;
$additional
=
$address
->
getAdditional
(
)
;
$customerType
= !
empty
(
$additional
[
'customer_type'
]
)
?
$additional
[
'customer_type'
]
: null;
if
(
$this
->config->
get
(
'shopSalutationRequired'
)
)
{
$this
->
validateField
(
'salutation',
$address
->
getSalutation
(
)
,
[
new
NotBlank
(
)
]
)
;
}
$this
->
validateField
(
'firstname',
$address
->
getFirstname
(
)
,
[
new
NotBlank
(
)
]
)
;
$this
->
validateField
(
'lastname',
$address
->
getLastname
(
)
,
[
new
NotBlank
(
)
]
)
;
$this
->
validateField
(
'street',
$address
->
getStreet
(
)
,
[
new
NotBlank
(
)
]
)
;
$this
->
validateField
(
'zipcode',
$address
->
getZipcode
(
)
,
[
new
NotBlank
(
)
]
)
;
$this
->
validateField
(
'city',
$address
->
getCity
(
)
,
[
new
NotBlank
(
)
]
)
;
$this
->
validateField
(
'country',
$address
->
getCountry
(
)
?
$address
->
getCountry
(
)
: null,
[
new
NotBlank
(
)
]
)
;
$this
->
validateField
(
'phone',
$address
->
getPhone
(
)
,
$this
->
getPhoneConstraints
(
)
)
;
$this
->
validateField
(
'additionalAddressLine1',
$address
->
getAdditionalAddressLine1
(
)
,
$this
->
getAdditionalAddressline1Constraints
(
)
)
;
$this
->
validateField
(
'additionalAddressLine2',
$address
->
getAdditionalAddressLine2
(
)
,
$this
->
getAdditionalAddressline2Constraints
(
)
)
;
if
(
$address
->
getCountry
(
)
&&
$address
->
getCountry
(
)
->
getForceStateInRegistration
(
)
)
{
$this
->
validateField
(
'state',
$address
->
getState
(
)
,
[
new
NotBlank
(
)
]
)
;
}
static
::
assertSame
(
$serialized
[
'id'
]
,
$order
->
getId
(
)
)
;
static
::
assertSame
(
$serialized
[
'orderNumber'
]
,
$order
->
getOrderNumber
(
)
)
;
static
::
assertSame
(
$serialized
[
'salesChannelId'
]
,
$order
->
getSalesChannelId
(
)
)
;
static
::
assertInstanceOf
(
OrderCustomerEntity::
class
,
$orderCustomer
=
$serialized
[
'orderCustomer'
]
)
;
static
::
assertSame
(
$orderCustomer
->
getFirstName
(
)
,
$order
->
getOrderCustomer
(
)
->
getFirstName
(
)
)
;
static
::
assertSame
(
$orderCustomer
->
getLastName
(
)
,
$order
->
getOrderCustomer
(
)
->
getLastName
(
)
)
;
static
::
assertSame
(
$orderCustomer
->
getEmail
(
)
,
$order
->
getOrderCustomer
(
)
->
getEmail
(
)
)
;
static
::
assertInstanceOf
(
OrderAddressEntity::
class
,
$billingAddress
=
$serialized
[
'billingAddress'
]
)
;
static
::
assertSame
(
$billingAddress
->
getZipcode
(
)
,
$order
->
getBillingAddress
(
)
->
getZipcode
(
)
)
;
static
::
assertSame
(
$billingAddress
->
getStreet
(
)
,
$order
->
getBillingAddress
(
)
->
getStreet
(
)
)
;
static
::
assertSame
(
$billingAddress
->
getCity
(
)
,
$order
->
getBillingAddress
(
)
->
getCity
(
)
)
;
static
::
assertSame
(
$billingAddress
->
getCompany
(
)
,
$order
->
getBillingAddress
(
)
->
getCompany
(
)
)
;
static
::
assertSame
(
$billingAddress
->
getDepartment
(
)
,
$order
->
getBillingAddress
(
)
->
getDepartment
(
)
)
;
static
::
assertSame
(
$billingAddress
->
getCountryId
(
)
,
$order
->
getBillingAddress
(
)
->
getCountryId
(
)
)
;
static
::
assertSame
(
$billingAddress
->
getCountryStateId
(
)
,
$order
->
getBillingAddress
(
)
->
getCountryStateId
(
)
)
;
static
::
assertNotNull
(
$deliveries
=
$order
->
getDeliveries
(
)
)
;
static
::
assertNotNull
(
$delivery
=
$deliveries
->
first
(
)
)
;
$shippingAddress
=
$delivery
->
getShippingOrderAddress
(
)
;
static
::
assertNotNull
(
$shippingAddress
)
;