private function generateCustomizeItemForm(array $item) { $defaultItem = array( 'name' => '', 'quantity' => 1, 'price' => '', 'productId' => '', 'variationOptions' => array(), 'variationId' => 0, 'configuration' => '', 'wrapping' => '', 'itemId' => '', 'quoteSession' => '', 'eventDate' => array(), 'eventName' => '', 'sku' => '', ); $item = array_merge($defaultItem, $item); $this->template->assign('item', $item); if($item['productId']) { $productClass = new ISC_PRODUCT($item['productId']); if(!$productClass->getProductId()) { $this->sendEditOrderResponse(array( 'errors' => array( getLang('InvalidProduct') ) )); } $this->template->assign('product', $productClass->getProduct()); $this->template->assign('variationOptions', $productClass->GetProductVariationOptions()); $this->template->assign('variationValues', $productClass->GetProductVariationOptionValues()); $configurableFields = $productClass->GetProductFields($item['productId']); foreach($configurableFields as &$field) { if($field['type'] == 'select') { $options = explode(',', $field['selectOptions']); $field['selectOptions'] = array_map('trim', $options); } } $this->template->assign('configurableFields', $configurableFields); // Event date if($productClass->getEventDateRequired()) { $eventDateFromStamp = $productClass->getEventDateLimitedStartDate(); $eventDateToStamp = $productClass->getEventDateLimitedEndDate(); $eventDate = array( 'fromStamp' => $eventDateFromStamp, 'toStamp' => $eventDateToStamp, 'yearFrom' => isc_date('Y', $eventDateFromStamp), 'yearTo' => isc_date('Y', $eventDateToStamp) ); // Generate a list of month options $eventDate['monthOptions'] = array(); for($i = 1; $i <= 12; ++$i) { $stamp = isc_gmmktime(0, 0, 0, $i, 1, 2000); $month = isc_date("M", $stamp); $eventDate['monthOptions'][$i] = $month; } $eventDateLimit = $productClass->getEventDateLimited(); if(empty($eventDateLimit)) { $eventDate['yearFrom'] = isc_date('Y'); $eventDate['yearTo'] = $eventDate['yearFrom'] + 5; } else { $eventDate['limitationType'] = $productClass->getEventDateLimitedType(); if($eventDate['limitationType'] == 1) { $eventDate['compDate'] = isc_date('Y/m/d', $eventDateFromStamp); $eventDate['compDateEnd'] = isc_date('Y/m/d', $eventDateToStamp); } else if($eventDate['limitationType'] == 2) { $eventDate['yearTo'] = $eventDate['yearFrom'] + 5; $eventDate['compDate'] = isc_date('Y/m/d', $eventDateFromStamp); } else if($eventDate['limitationType'] == 3) { $eventDate['yearFrom'] = isc_date('Y'); $eventDate['compDate'] = isc_date('Y/m/d', $eventDateToStamp); } } $this->template->assign('eventDate', $eventDate); } } if(!empty($item['quoteItem'])) { $allowableWrappingOptions = $item['quoteItem']->getGiftWrappingOptions(); } // Product still exists - get the gift wrapping options on the product if(isset($productClass)) { $product = $productClass->getProduct(); $allowableWrappingOptions = explode(',', $product['prodwrapoptions']); } if(!empty($allowableWrappingOptions)) { if(empty($allowableWrappingOptions) || in_array(0, $allowableWrappingOptions)) { $giftWrapWhere = "wrapvisible='1'"; } else { $wrappingOptions = implode(',', array_map('intval', $allowableWrappingOptions)); $giftWrapWhere = "wrapid IN (".$wrappingOptions.")"; } $query = " SELECT * FROM [|PREFIX|]gift_wrapping WHERE ".$giftWrapWhere." ORDER BY wrapname ASC "; $giftWrappingOptions = array(); $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while($wrap = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $giftWrappingOptions[$wrap['wrapid']] = $wrap; } $this->template->assign('giftWrappingOptions', $giftWrappingOptions); } return array( 'data' => $this->template->render('order.form.customizeitem.tpl'), 'width' => 600, 'height' => 500, ); }