/**
  * @return array
  */
 public function display()
 {
     return ['id' => $this->id, 'name' => $this->name, 'price' => CurrencyHelper::formatWithCurrency($this->price), 'sku' => $this->sku, 'stockLevel' => $this->stockLevel, 'color' => $this->color ? $this->color->getName() : '', 'colorHex' => $this->color ? $this->color->getHex() : '', 'size' => $this->size ? $this->size->getName() : '', 'type' => $this->type ? $this->type->getName() : ''];
 }
 /**
  * @param View $view
  */
 public function propertyView(View $view)
 {
     $viewData = $view->getData();
     $property = $viewData['property'];
     if (isset($property->translations) && $property->translations) {
         $translations = json_decode($property->translations, true);
         if (isset($translations[App::getLocale()]['title']) && $translations[App::getLocale()]['title']) {
             $property->title = $translations[App::getLocale()]['title'];
         }
         if (isset($translations[App::getLocale()]['short_description']) && $translations[App::getLocale()]['short_description']) {
             $property->short_description = $translations[App::getLocale()]['short_description'];
         }
         if (isset($translations[App::getLocale()]['long_description']) && $translations[App::getLocale()]['long_description']) {
             $property->long_description = $translations[App::getLocale()]['long_description'];
         }
     }
     $newAttributes = [];
     foreach ($property->attributes as $attribute) {
         if (isset($attribute->translations) && $attribute->translations) {
             $translations = json_decode($attribute->translations, true);
             if (isset($translations[App::getLocale()]['attribute'])) {
                 $attribute->property_attribute_name = $translations[App::getLocale()]['attribute'];
             }
             if (isset($translations[App::getLocale()]['description'])) {
                 $attribute->property_attribute_description = $translations[App::getLocale()]['description'];
             }
         }
         $newAttributes[] = $attribute;
     }
     $property->attributes = $newAttributes;
     $view->with('property', $property);
     $view->with('price', CurrencyHelper::formatWithCurrency($property->price, true));
     $view->with('propertySlug', Str::slug($property->title));
 }
Exemplo n.º 3
0
 /**
  * @param CartValuesTransformer $cartValuesTransformer
  * @return array
  */
 public function toArray(CartValuesTransformer $cartValuesTransformer = null)
 {
     $items = [];
     foreach ($this->items as $cartItem) {
         /* @var $cartItem CartItem */
         $items[] = $cartItem->display();
     }
     $totals = [];
     $displayTotals = [];
     if ($cartValuesTransformer) {
         $totals = $this->getValues($cartValuesTransformer);
         $displayTotals = array_map(function ($item) {
             return CurrencyHelper::formatWithCurrency($item, false, '');
         }, $totals);
         if ($this->orderShippingPrice === null) {
             $displayTotals['displayShipping'] = 'NOT AVAILABLE';
         }
     }
     return ['shippingTypeId' => $this->getShippingType(), 'countryId' => $this->getCountryId(), 'availableShippingTypes' => $this->getAvailableShippingTypes(), 'items' => $items, 'itemCount' => $this->totalProducts(), 'totals' => $totals, 'displayTotals' => $displayTotals];
 }
Exemplo n.º 4
0
 /**
  * @return array
  */
 public function getDisplayArray()
 {
     return ['id' => $this->id, 'productName' => $this->productName, 'shortDescription' => $this->shortDescription, 'longDescription' => $this->longDescription, 'price' => CurrencyHelper::formatWithCurrency($this->getPrice()), 'keywords' => $this->keywords, 'images' => $this->images, 'video' => $this->video, 'variations' => $this->displayVariations()];
 }