public function isValid($elementsOnly = false)
{
if ($this->isEmpty()) {
return false;
}
foreach ($this->getBasketElements() as $element) {
if ($element->isValid() === false) {
return false;
}
}
if ($elementsOnly) {
return true;
}
if (!$this->getBillingAddress() instanceof AddressInterface) {
return false;
}
if (!$this->getPaymentMethod() instanceof PaymentInterface) {
return false;
}
if (!$this->getDeliveryMethod() instanceof ServiceDeliveryInterface) {
return false;
}
if (!$this->getDeliveryAddress() instanceof AddressInterface) {
if ($this->getDeliveryMethod()->isAddressRequired()) {
return false;
}
}
return true;
}