function synchroniseUDatabase() { $sync = parent::synchroniseUDatabase(); if ($sync) { /*$status = $this->owner->getCustomerStatus(false); if(empty($status)) { return $this->notifyError('SS_FIELDS_MISSING', 'Status'); }*/ $member = $this->owner->Member(); if ($member->exists()) { $sync = $member->synchroniseUDatabase(); if ($sync) { $sync = $member->updateUDatabase(); } if (!$sync) { return $this->notifyError('SS_RELATION_INVALID', 'Member'); } } else { return $this->notifyError('SS_FIELDS_MISSING', 'Member'); } // Currency is not required to POST but it should be $currency = $this->getUCurrency(); if (empty($currency)) { return $this->notifyError('SS_FIELDS_MISSING', 'Currency'); } $tax = $this->getUTax(); if (!$tax) { return $this->notifyError('SS_FIELDS_MISSING', 'Unleashed Tax'); } $attributes = $this->owner->Attributes(); foreach ($attributes as $attribute) { if ($attribute->ClassName != self::$attribute_tax_class) { if ($attribute->CalculatedTotal != 0 || !in_array($attribute->ClassName, self::$exclude_attribute_classes)) { // Only exclude them if CalculatedTotal equals 0 // Precondition : Only order items $buyable = $attribute->Buyable(true); $extensions = array_keys($buyable->getExtensionInstances()); foreach ($extensions as $extension) { if (is_subclass_of($extension, 'UnleashedObjectDOD')) { $sync = $buyable->synchroniseUDatabase(); if ($sync) { $sync = $buyable->updateUDatabase(); } if (!$sync) { return $this->notifyError('SS_RELATION_INVALID', "{$buyable->ClassName} #{$buyable->ID}"); } break; } } // Todo : deal with other modifiers like delivery } } } return true; } }
function synchroniseUDatabase() { $sync = parent::synchroniseUDatabase(); $sync = $sync && !(Object::has_extension('Product', 'ProductWithVariationDecorator') && $this->owner->HasVariations()); if ($sync) { if (empty($this->owner->Title)) { return $this->notifyError('SS_FIELDS_MISSING', 'Title'); } return true; } }
function synchroniseUDatabase() { $sync = parent::synchroniseUDatabase(); $orders = DataObject::get('Order', "MemberID = {$this->owner->ID}"); // $this->owner->Orders() does not work. Has EcommerceRole been added properly ? if ($sync && $orders) { $name = $this->owner->Surname; // Company Name if (empty($name)) { return $this->notifyError('SS_FIELDS_MISSING', 'Company Name'); } return true; } }
function synchroniseUDatabase() { $sync = parent::synchroniseUDatabase(); if ($sync) { $description = $this->getUDescription(); if (empty($description)) { $names[] = 'Description'; if (self::$alternative_description) { $names[] = 'Alternative Description'; } return $this->notifyError('SS_FIELDS_MISSING', $names); } return true; } }