/** * Set fields from a product record * @return InvoiceItem provides fluent interface */ public function copyProductSettings(IProduct $p) { foreach (self::$_productInvoiceFields as $kp => $ki) { $this->{$ki} = call_user_func(array($p, 'get' . ucfirst($kp))); if (strpos($kp, 'is') === 0) { $this->{$ki} = (bool) $this->{$ki}; } } if (!$p->getRebillTimes()) { $this->second_price = null; $this->second_period = null; } $options = $p->getOptions(); if ($options) { $this->option1 = array_shift($options); } if ($options) { $this->option2 = array_shift($options); } if ($options) { $this->option3 = array_shift($options); } $this->setBillingPlanData($p->getBillingPlanData()); return $this; }