Example #1
0
 public function toArray()
 {
     $array = parent::toArray();
     if (!$this->isLoaded()) {
         $this->loadFile();
         $lang = self::getApplication()->getLocaleCode();
         $array['title_lang'] = $this->getValueByLang('title', $lang);
         $array['text_lang'] = $this->getValueByLang('text', $lang);
     }
     // when the instance is not loaded
     if (!$array['handle']) {
         $array['handle'] = $this->handle->get();
     }
     $array['menuInformation'] = false;
     $array['menuRootCategories'] = false;
     if (array_key_exists('menuData', $array)) {
         if (array_key_exists('INFORMATION', $array['menuData'])) {
             $array['menuInformation'] = (bool) $array['menuData']['INFORMATION'];
         }
         if (array_key_exists('ROOT_CATEGORIES', $array['menuData'])) {
             $array['menuRootCategories'] = (bool) $array['menuData']['ROOT_CATEGORIES'];
         }
     }
     return $array;
 }
Example #2
0
 public function toArray()
 {
     $array = parent::toArray();
     $array['attributes'] = $this->getSpecification()->toArray();
     if ($this->isLoaded()) {
         self::sortAttributesByHandle($array);
         $array = array_merge($array, $this->getPricesFields());
     }
     if ($this->parent->get()) {
         $array = array_merge($this->parent->get()->toArray(), array_filter($array));
     }
     foreach ($this->variations as $variation) {
         $array['variations'][$variation->getID()] = $variation->toArray();
     }
     $this->setArrayData($array);
     return $array;
 }
 public function toArray($currencyID = null)
 {
     $array = parent::toArray();
     $rs = ProductPrice::getRecurringProductPeriodPrices($this, $currencyID);
     $currencies = array();
     if ($rs && $rs->size()) {
         $mapping = array(ProductPrice::TYPE_PERIOD_PRICE => 'ProductPrice_period', ProductPrice::TYPE_SETUP_PRICE => 'ProductPrice_setup');
         while (false != ($item = $rs->shift())) {
             $itemArray = $item->toArray();
             if ($itemArray['type'] == ProductPrice::TYPE_SETUP_PRICE || $itemArray['type'] == ProductPrice::TYPE_PERIOD_PRICE) {
                 $array[$mapping[$itemArray['type']]][$itemArray['currencyID']] = $itemArray;
                 if (array_key_exists($itemArray['currencyID'], $currencies) == false) {
                     $currencies[$itemArray['currencyID']] = Currency::getInstanceByID($itemArray['currencyID']);
                 }
                 $array[$mapping[$itemArray['type']]]['formated_price'][$itemArray['currencyID']] = $currencies[$itemArray['currencyID']]->getFormattedPrice($itemArray['price']);
             }
         }
     }
     return $array;
 }
Example #4
0
 public function toArray()
 {
     $this->getSpecification();
     return parent::toArray();
 }
Example #5
0
 /**
  *	Returns array representations
  *
  *	@return array
  */
 public function toArray()
 {
     $array = parent::toArray();
     $imagePath = $this->getImagePath();
     if (file_exists($imagePath)) {
         $array['imagePath'] = $imagePath;
     }
     $this->setArrayData($array);
     return $array;
 }
Example #6
0
 public function toArray()
 {
     $array = parent::toArray();
     if ($this->choices) {
         $array['choices'] = array();
         foreach ($this->choices as $choice) {
             $array['choices'][] = $choice->toArray();
         }
     }
     $this->setArrayData($array);
     return $array;
 }
Example #7
0
 public function toArray()
 {
     $array = parent::toArray();
     $array['priceCurrencyID'] = $this->getCurrency()->getID();
     $isTaxIncludedInPrice = $this->customerOrder->get()->getTaxZone()->isTaxIncludedInPrice();
     if (isset($array['price'])) {
         $currency = $this->getCurrency();
         $array['itemBasePrice'] = (double) self::getApplication()->getDisplayTaxPrice($array['price'], isset($array['Product']) ? $array['Product'] : array());
         $array['displayPrice'] = (double) $this->getDisplayPrice($currency, $isTaxIncludedInPrice);
         $array['displayPriceWithoutTax'] = (double) $this->getItemPrice();
         $array['displaySubTotalWithoutTax'] = (double) $this->getSubTotalBeforeTax();
         $array['displaySubTotal'] = (double) $this->getSubTotal($isTaxIncludedInPrice);
         $array['itemPrice'] = $array['displaySubTotal'] / $array['count'];
         $isTaxIncludedInPrice = $isTaxIncludedInPrice || $array['itemPrice'] != $array['itemBasePrice'] && $array['itemPrice'] == $this->getSubTotal(false) && $array['itemBasePrice'] == $this->getSubTotal(true);
         // display price changed by tax exclusion
         if ((string) $array['itemPrice'] != (string) $array['itemBasePrice'] && (string) $array['itemPrice'] == (string) ($this->getSubTotal(false) / $array['count']) && (string) $array['itemBasePrice'] == (string) ($this->getSubTotal(true) / $array['count'])) {
             $array['itemPrice'] = $array['itemBasePrice'];
         }
         // kind of a workaround for completed orders that have default zone taxes, could be a better fix
         if ((string) ($this->getSubTotal(false) / $array['count']) == (string) $array['itemBasePrice'] && (string) ($this->getSubTotal(true) / $array['count']) == (string) $array['itemPrice']) {
             $array['itemBasePrice'] = $array['itemPrice'];
         }
         if ($this->optionChoices && !$this->customerOrder->get()->isFinalized->get()) {
             foreach ($this->optionChoices as $choice) {
                 $array['itemBasePrice'] += $choice->choice->get()->getPriceDiff($this->getCurrency());
             }
         }
         $array['formattedBasePrice'] = $currency->getFormattedPrice($array['itemBasePrice']);
         $array['formattedPrice'] = $currency->getFormattedPrice($array['itemPrice']);
         $array['formattedDisplayPrice'] = $currency->getFormattedPrice($array['displayPrice']);
         $array['formattedDisplaySubTotal'] = $currency->getFormattedPrice($array['displaySubTotal']);
         $array['formattedPriceWithoutTax'] = $currency->getFormattedPrice($array['displayPriceWithoutTax']);
         $array['formattedSubTotalWithoutTax'] = $currency->getFormattedPrice($array['displaySubTotalWithoutTax']);
     }
     $array['options'] = array();
     foreach ($this->optionChoices as $id => $choice) {
         $array['options'][$id] = $choice->toArray();
     }
     $array['subItems'] = array();
     if ($this->subItems) {
         foreach ($this->subItems as $subItem) {
             $array['subItems'][] = $subItem->toArray();
         }
     }
     if ($array && is_array($array) && array_key_exists('Product', $array) && array_key_exists('type', $array['Product']) && $array['Product']['type'] == Product::TYPE_RECURRING) {
         $ritemArray = RecurringItem::getRecordSetArrayByOrderedItem($this);
         if (count($ritemArray)) {
             $array['recurringID'] = $ritemArray[0]['recurringID'];
         }
     }
     $this->setArrayData($array);
     return $array;
 }
Example #8
0
 /**
  *	Returns SpecField array representations
  *
  *	@return array
  */
 public function toArray()
 {
     $array = parent::toArray();
     $array['fieldName'] = $this->getFormFieldName();
     $this->setArrayData($array);
     return $array;
 }