Ejemplo n.º 1
0
 public function render(Varien_Object $row)
 {
     $actions = array();
     $curWebsite = $this->getRequest()->getParam('website');
     $curStore = $this->getRequest()->getParam('store');
     $aParams = array();
     if ($curWebsite) {
         $aParams['website'] = $curWebsite;
     }
     if ($curStore) {
         $aParams['store'] = $curStore;
     }
     if (!$aParams) {
         list($aParams['scope'], $aParams['scopeid']) = Mage::getModel('aitemails/aitemails')->getCurrentScope();
     }
     $aParams['fromaitemails'] = 1;
     if ($row->getCustomTemplate()) {
         $aParams['id'] = $row->getCustomTemplateId();
         $actions[] = array('url' => $this->getUrl('adminhtml/system_email_template/edit', $aParams), 'caption' => $this->__('Edit Custom Template'));
     } else {
         $aParams['templatecode'] = $row->getCode();
         $aParams['localecode'] = Mage::registry('aitemails_email_template_scope_locale');
         $aParams['scope'] = $row->getScope();
         $aParams['scopeid'] = $row->getScopeId();
         $actions[] = array('url' => $this->getUrl('adminhtml/system_email_template/new', $aParams), 'caption' => $this->__('Create Custom Template'));
     }
     $this->getColumn()->setActions($actions);
     return parent::render($row);
 }
Ejemplo n.º 2
0
 /**
  * Renders qty column
  *
  * @param   Varien_Object $row
  * @return  string
  */
 public function render(Varien_Object $row)
 {
     $isDisabled = $row->getCode() == Enterprise_Checkout_Helper_Data::ADD_ITEM_STATUS_FAILED_SKU || $row->getIsConfigureDisabled() || $row->getIsQtyDisabled();
     $html = '<input type="text" ';
     $html .= 'name="' . $this->getColumn()->getId() . '" ';
     $html .= 'value="' . $row->getData($this->getColumn()->getIndex()) . '" ';
     $html .= $isDisabled ? 'disabled="disabled" ' : '';
     $html .= 'class="input-text ' . $this->getColumn()->getInlineCss() . '"/>';
     return $html;
 }
 /**
  * Redirects to custom url after logout if set in system > configuration > customer > startup
  *
  * @param Varien_Event_Observer $observer
  * @return $this
  */
 public function logoutRedirect(Varien_Event_Observer $observer)
 {
     if (!Mage::getStoreConfigFlag('customer/startup/redirect_logout')) {
         return $this;
     }
     $transportObj = new Varien_Object(array('url' => Mage::getStoreConfig('customer/startup/redirect_logout_url'), 'code' => 302));
     Mage::dispatchEvent('ambimax_logoutredirect', array('data' => $transportObj));
     /** @var Mage_Customer_AccountController $controller */
     $controller = $observer->getControllerAction();
     $controller->getResponse()->setRedirect($transportObj->getUrl(), $transportObj->getCode());
 }
Ejemplo n.º 4
0
 /**
  * Additionally check for session messages in several domains case
  *
  * @param string $url
  * @param int $code
  * @return Mage_Core_Controller_Response_Http
  */
 public function setRedirect($url, $code = 302)
 {
     /**
      * Use single transport object instance
      */
     if (self::$_transportObject === null) {
         self::$_transportObject = new Varien_Object();
     }
     self::$_transportObject->setUrl($url);
     self::$_transportObject->setCode($code);
     Mage::dispatchEvent('controller_response_redirect', array('response' => $this, 'transport' => self::$_transportObject));
     return parent::setRedirect(self::$_transportObject->getUrl(), self::$_transportObject->getCode());
 }
Ejemplo n.º 5
0
 /**
  * Renders grid column
  *
  * @param   Varien_Object $row
  * @return  string
  */
 public function render(Varien_Object $row)
 {
     $links = array();
     if ($row->getChangelog()) {
         $links[] = sprintf('<a href="javascript:void(0)" onclick="%s">%s</a><div style="display:none" class="changelog"><div class="title">%s</div><div class="content">%s</div></div>', "tmcoreWindow.update(this.next('.changelog').down('.content').innerHTML, this.next('.changelog').down('.title').innerHTML).show()", Mage::helper('tmcore')->__('Changelog'), strip_tags($row->getCode()), nl2br(htmlspecialchars($row->getChangelog())));
     }
     if ($row->getDownloadLink()) {
         $links[] = sprintf('<a href="%s" title="%s" onclick="window.open(this.href); return false;">%s</a>', $row->getDownloadLink(), Mage::helper('tmcore')->__('Download Latest Version'), Mage::helper('tmcore')->__('Download'));
     }
     if ($row->hasUpgradesDir() || $row->getIdentityKeyLink()) {
         $links[] = sprintf('<a href="%s">%s</a>', $this->getUrl('*/*/manage/', array('_current' => true, 'id' => $row->getId())), Mage::helper('tmcore')->__('Manage'));
     }
     return implode(' | ', $links);
 }
Ejemplo n.º 6
0
 public function getActiveMethodRate()
 {
     if ($this->getCustomMethodCode() == $this->getOrder()->getShippingMethod()) {
         $rate = new Varien_Object();
         $rate->setCode($this->getCustomMethodCode());
         $rate->setPrice($this->getOrder()->getShippingAmount());
         $rate->setMethodTitle(Mage::helper('iwd_ordermanager')->__("Custom"));
         $rate->setMethodDescription($this->getOrder()->getShippingDescription());
         return $rate;
     }
     if (is_array($this->shipping_rates)) {
         foreach ($this->shipping_rates as $group) {
             foreach ($group as $code => $rate) {
                 if ($rate->getCode() == $this->getOrder()->getShippingMethod()) {
                     return $rate;
                 }
             }
         }
     }
     return false;
 }
Ejemplo n.º 7
0
 public function getShippingRates($order)
 {
     $request = $this->prepareShippingRequest($order);
     $shipping = Mage::getModel('shipping/shipping');
     $result = $shipping->collectRates($request)->getResult();
     if ($result) {
         $rates = array();
         foreach ($result->getAllRates() as $_rate) {
             $rate = new Varien_Object();
             $rate->setData($_rate->getData());
             $carrier = $rate->getCarrier();
             if (!isset($rates[$carrier])) {
                 $rates[$carrier] = array();
             }
             $rate->setCode($carrier . '_' . $rate->getMethod());
             $rates[$carrier][$rate->getCode()] = $rate;
         }
         return $rates;
     }
     return null;
 }
Ejemplo n.º 8
0
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     $this->setForm($form);
     $fieldset = $form->addFieldset('feedback_form', array('legend' => Mage::helper('magenotification')->__('Feedback detail')));
     $data = array();
     if (Mage::getSingleton('adminhtml/session')->getFeedbackData()) {
         $data = Mage::getSingleton('adminhtml/session')->getFeedbackData();
         Mage::getSingleton('adminhtml/session')->setFeedbackData(null);
     } elseif (Mage::registry('feedback_data')) {
         $data = Mage::registry('feedback_data')->getData();
     }
     $dataObject = new Varien_Object($data);
     if ($dataObject->getFeedbackId()) {
         $fieldset->addField('is_sent', 'note', array('label' => '', 'name' => 'is_sent', 'text' => $dataObject->getIsSent() == '1' ? '<span style="width:250px;" class="grid-severity-notice"><span>' . $this->__('Sent to Magestore.com') . '</span></span>' : '<span style="width:250px;" class="grid-severity-critical"><span>' . $this->__('Not sent to Magestore.com') . '</span></span>'));
     }
     if ($dataObject->getFeedbackId()) {
         $fieldset->addField('code', 'note', array('label' => Mage::helper('magenotification')->__('Feedback Code'), 'name' => 'code', 'text' => $dataObject->getCode()));
         $fieldset->addField('extension', 'note', array('label' => Mage::helper('magenotification')->__('Extension'), 'name' => 'extension', 'text' => $dataObject->getExtension() . ' - version ' . $dataObject->getExtensionVersion()));
     } else {
         $fieldset->addField('extension', 'select', array('label' => Mage::helper('magenotification')->__('Extension'), 'name' => 'extension', 'values' => Mage::helper('magenotification')->getExtensionOption(), 'class' => 'required-entry', 'required' => true));
     }
     if ($dataObject->getFeedbackId()) {
         $fieldset->addField('created_time', 'note', array('label' => Mage::helper('magenotification')->__('Posted'), 'name' => 'created_time', 'text' => $this->formatDate($dataObject->getCreatedTime(), 'medium', true)));
         if ($dataObject->getCouponCode()) {
             $fieldset->addField('coupon_code', 'note', array('label' => Mage::helper('magenotification')->__('Coupon'), 'name' => 'coupon_code', 'text' => '<b>' . $dataObject->getCouponCode() . '</b> (' . Mage::helper('magenotification')->__('for discount') . ' ' . $dataObject->getCouponValue() . ' ' . Mage::helper('magenotification')->__('to') . ' ' . Mage::helper('core')->formatDate($dataObject->getExpiredCoupon(), 'medium', false) . ')'));
         }
         $fieldset->addField('status', 'select', array('label' => Mage::helper('magenotification')->__('Status'), 'name' => 'status', 'values' => Mage::helper('magenotification')->getFeedbackStatusOption(), 'disabled' => 'disabled', 'style' => 'width:600px;'));
         $fieldset->addField('content', 'note', array('name' => 'content', 'label' => Mage::helper('magenotification')->__('Feedback'), 'text' => $dataObject->getData('content')));
         $fieldset->addField('attached_file', 'note', array('name' => 'attached_file', 'label' => Mage::helper('magenotification')->__('Attached Files'), 'text' => $this->getLayout()->createBlock('magenotification/adminhtml_feedback_renderer_file')->setFeedback($dataObject)->getAttachedFilesHtml()));
     } else {
         $fieldset->addField('content', 'editor', array('name' => 'content', 'label' => Mage::helper('magenotification')->__('Feedback'), 'style' => 'width:600px;height:300px', 'class' => 'required-entry', 'required' => true));
         $fieldset->addField('attached_file', 'note', array('name' => 'attached_file', 'label' => Mage::helper('magenotification')->__('Attached Files'), 'text' => $this->getLayout()->createBlock('magenotification/adminhtml_feedback_renderer_file')->toHtml()));
     }
     $form->setValues($data);
     return parent::_prepareForm();
 }
Ejemplo n.º 9
0
 /**
  * Add total to totals XML. Api version 23.
  *
  * @param Varien_Object $total
  * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXml
  * @return null
  */
 protected function _addTotalToXmlApi23($total, Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
 {
     if ($total instanceof Varien_Object && $total->getCode() && $total->getLabel() && $total->hasData('value')) {
         $totalsXml->addCustomChild('item', $this->_formatPrice($total), array('id' => preg_replace('@[\\W]+@', '_', trim($total->getCode())), 'label' => $totalsXml->escapeXml($total->getLabel())));
     }
 }
Ejemplo n.º 10
0
 /**
  * Get either shipping rate code or empty value on error
  *
  * @param Varien_Object $rate
  * @return string
  */
 public function renderShippingRateValue(Varien_Object $rate)
 {
     if ($rate->getErrorMessage()) {
         return '';
     }
     return $rate->getCode();
 }
Ejemplo n.º 11
0
 /**
  * Force standard function as we want to use action code as id
  *
  * @param Varien_Object $item collection item
  *
  * @return mixed
  */
 protected function _getItemId(Varien_Object $item)
 {
     return $item->getCode();
 }
Ejemplo n.º 12
0
 /**
  * Method is needed for specific actions to change given quote options values
  * according current product type logic
  * Example: the cataloginventory validation of decimal qty can change qty to int,
  * so need to change quote item qty option value too.
  *
  * @param   array           $options
  * @param   Varien_Object   $option
  * @param   mixed           $value
  *
  * @return  object          Mage_Bundle_Model_Product_Type
  */
 public function updateQtyOption($options, Varien_Object $option, $value)
 {
     $optionProduct = $option->getProduct();
     $optionCollection = $this->getOptionsCollection();
     $selections = $this->getSelectionsCollection($optionCollection->getAllIds());
     foreach ($selections as $selection) {
         if ($selection->getProductId() == $optionProduct->getId()) {
             foreach ($options as &$option) {
                 if ($option->getCode() == 'selection_qty_' . $selection->getSelectionId()) {
                     $option->setValue($value);
                 }
             }
         }
     }
     return $this;
 }
Ejemplo n.º 13
0
 /**
  * Add total to totals XML
  *
  * @param Varien_Object $total
  * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXml
  * @return null
  */
 private function _addTotalToXml($total, Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
 {
     if ($total instanceof Varien_Object && $total->getCode() && $total->getLabel() && $total->hasData('value')) {
         $totalsXml->addCustomChild(preg_replace('@[\\W]+@', '_', trim($total->getCode())), $this->_formatPrice($total), array('label' => strip_tags($total->getLabel())));
     }
 }
Ejemplo n.º 14
0
 /**
  * Retrieve error message for the item
  *
  * @param Varien_Object $item
  * @return string
  */
 public function getMessageByItem(Varien_Object $item)
 {
     $message = $this->getMessage($item->getCode());
     return $message ? $message : $item->getError();
 }
Ejemplo n.º 15
0
 /**
  * Method is needed for specific actions to change given quote options values
  * according current product type logic
  * Example: the cataloginventory validation of decimal qty can change qty to int,
  * so need to change quote item qty option value too.
  *
  * @param   array           $options
  * @param   Varien_Object   $option
  * @param   mixed           $value
  * @param   Mage_Catalog_Model_Product $product
  * @return  Mage_Bundle_Model_Product_Type
  */
 public function updateQtyOption($options, Varien_Object $option, $value, $product = null)
 {
     $optionProduct = $option->getProduct($product);
     $optionUpdateFlag = $option->getHasQtyOptionUpdate();
     $optionCollection = $this->getOptionsCollection($product);
     $selections = $this->getSelectionsCollection($optionCollection->getAllIds(), $product);
     foreach ($selections as $selection) {
         if ($selection->getProductId() == $optionProduct->getId()) {
             foreach ($options as &$option) {
                 if ($option->getCode() == 'selection_qty_' . $selection->getSelectionId()) {
                     if ($optionUpdateFlag) {
                         $option->setValue(intval($option->getValue()));
                     } else {
                         $option->setValue($value);
                     }
                 }
             }
         }
     }
     return $this;
 }
Ejemplo n.º 16
0
 /**
  * Add new total to totals array before specific total or after first total by default
  *
  * @param   Varien_Object $total
  * @param   null|string $after
  * @return  Mage_Sales_Block_Order_Totals
  */
 public function addTotalBefore(Varien_Object $total, $before = null)
 {
     if ($before !== null) {
         if (!is_array($before)) {
             $before = array($before);
         }
         foreach ($before as $beforeTotals) {
             if (isset($this->_totals[$beforeTotals])) {
                 $totals = array();
                 foreach ($this->_totals as $code => $item) {
                     if ($code == $beforeTotals) {
                         $totals[$total->getCode()] = $total;
                     }
                     $totals[$code] = $item;
                 }
                 $this->_totals = $totals;
                 return $this;
             }
         }
     }
     $totals = array();
     $first = array_shift($this->_totals);
     $totals[$first->getCode()] = $first;
     $totals[$total->getCode()] = $total;
     foreach ($this->_totals as $code => $item) {
         $totals[$code] = $item;
     }
     $this->_totals = $totals;
     return $this;
 }
Ejemplo n.º 17
0
 /**
  * Generate gift card accounts after order save
  *
  * @param Varien_Event_Observer $observer
  * @return Enterprise_GiftCard_Model_Observer
  */
 public function generateGiftCardAccounts(Varien_Event_Observer $observer)
 {
     // sales_order_save_after
     $order = $observer->getEvent()->getOrder();
     $requiredStatus = Mage::getStoreConfig(Enterprise_GiftCard_Model_Giftcard::XML_PATH_ORDER_ITEM_STATUS, $order->getStore());
     $loadedInvoices = array();
     foreach ($order->getAllItems() as $item) {
         if ($item->getProductType() == Enterprise_GiftCard_Model_Catalog_Product_Type_Giftcard::TYPE_GIFTCARD) {
             $qty = 0;
             $options = $item->getProductOptions();
             switch ($requiredStatus) {
                 case Mage_Sales_Model_Order_Item::STATUS_INVOICED:
                     $paidInvoiceItems = isset($options['giftcard_paid_invoice_items']) ? $options['giftcard_paid_invoice_items'] : array();
                     // find invoice for this order item
                     $invoiceItemCollection = Mage::getResourceModel('sales/order_invoice_item_collection')->addFieldToFilter('order_item_id', $item->getId());
                     foreach ($invoiceItemCollection as $invoiceItem) {
                         $invoiceId = $invoiceItem->getParentId();
                         if (isset($loadedInvoices[$invoiceId])) {
                             $invoice = $loadedInvoices[$invoiceId];
                         } else {
                             $invoice = Mage::getModel('sales/order_invoice')->load($invoiceId);
                             $loadedInvoices[$invoiceId] = $invoice;
                         }
                         // check, if this order item has been paid
                         if ($invoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_PAID && !in_array($invoiceItem->getId(), $paidInvoiceItems)) {
                             $qty += $invoiceItem->getQty();
                             $paidInvoiceItems[] = $invoiceItem->getId();
                         }
                     }
                     $options['giftcard_paid_invoice_items'] = $paidInvoiceItems;
                     break;
                 default:
                     $qty = $item->getQtyOrdered();
                     if (isset($options['giftcard_created_codes'])) {
                         $qty -= count($options['giftcard_created_codes']);
                     }
                     break;
             }
             $hasFailedCodes = false;
             if ($qty > 0) {
                 $isRedeemable = 0;
                 if ($option = $item->getProductOptionByCode('giftcard_is_redeemable')) {
                     $isRedeemable = $option;
                 }
                 $lifetime = 0;
                 if ($option = $item->getProductOptionByCode('giftcard_lifetime')) {
                     $lifetime = $option;
                 }
                 $amount = $item->getBasePrice();
                 $websiteId = Mage::app()->getStore($order->getStoreId())->getWebsiteId();
                 $data = new Varien_Object();
                 $data->setWebsiteId($websiteId)->setAmount($amount)->setLifetime($lifetime)->setIsRedeemable($isRedeemable)->setOrderItem($item);
                 $codes = isset($options['giftcard_created_codes']) ? $options['giftcard_created_codes'] : array();
                 $goodCodes = 0;
                 for ($i = 0; $i < $qty; $i++) {
                     try {
                         $code = new Varien_Object();
                         Mage::dispatchEvent('enterprise_giftcardaccount_create', array('request' => $data, 'code' => $code));
                         $codes[] = $code->getCode();
                         $goodCodes++;
                     } catch (Mage_Core_Exception $e) {
                         $hasFailedCodes = true;
                         $codes[] = null;
                     }
                 }
                 if ($goodCodes && $item->getProductOptionByCode('giftcard_recipient_email')) {
                     $sender = $item->getProductOptionByCode('giftcard_sender_name');
                     $senderName = $item->getProductOptionByCode('giftcard_sender_name');
                     if ($senderEmail = $item->getProductOptionByCode('giftcard_sender_email')) {
                         $sender = "{$sender} <{$senderEmail}>";
                     }
                     $codeList = Mage::helper('enterprise_giftcard')->getEmailGeneratedItemsBlock()->setCodes($codes)->setIsRedeemable($isRedeemable)->setStore(Mage::app()->getStore($order->getStoreId()));
                     $balance = Mage::app()->getLocale()->currency(Mage::app()->getStore($order->getStoreId())->getBaseCurrencyCode())->toCurrency($amount);
                     $templateData = array('name' => $item->getProductOptionByCode('giftcard_recipient_name'), 'email' => $item->getProductOptionByCode('giftcard_recipient_email'), 'mobile' => $item->getProductOptionByCode('giftcard_recipient_mobile'), 'sender_name_with_email' => $sender, 'sender_name' => $senderName, 'gift_message' => $item->getProductOptionByCode('giftcard_message'), 'giftcards' => $codeList->toHtml(), 'balance' => $balance, 'is_multiple_codes' => 1 < $goodCodes, 'store' => $order->getStore(), 'store_name' => $order->getStore()->getName(), 'is_redeemable' => $isRedeemable);
                     $email = Mage::getModel('core/email_template')->setDesignConfig(array('store' => $item->getOrder()->getStoreId()));
                     $email->sendTransactional($item->getProductOptionByCode('giftcard_email_template'), Mage::getStoreConfig(Enterprise_GiftCard_Model_Giftcard::XML_PATH_EMAIL_IDENTITY, $item->getOrder()->getStoreId()), $item->getProductOptionByCode('giftcard_recipient_email'), $item->getProductOptionByCode('giftcard_recipient_name'), $templateData);
                     if ($email->getSentSuccess()) {
                         $options['email_sent'] = 1;
                         // Start Sending SMS for Giftcard
                         $templateData['send_to'] = $templateData['mobile'];
                         $templateData['giftcards'] = strip_tags($templateData['giftcards']);
                         $helper = Mage::helper('nosql/joker');
                         $helper->sendNow($templateData, 'sms', 'EVOUCHER');
                         // End Sending SMS for Giftcart
                     }
                 }
                 $options['giftcard_created_codes'] = $codes;
                 $item->setProductOptions($options);
                 $item->save();
             }
             if ($hasFailedCodes) {
                 $url = Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/giftcardaccount');
                 $message = Mage::helper('enterprise_giftcard')->__('Some of Gift Card Accounts were not generated properly. You can create Gift Card Accounts manually <a href="%s">here</a>.', $url);
                 Mage::getSingleton('adminhtml/session')->addError($message);
             }
         }
     }
     return $this;
 }
Ejemplo n.º 18
0
 /**
  * Create giftcard accounts and update the giftcard_created_codes in product option
  * Returns whether there is an error in creating giftcard
  *
  * @param Mage_Sales_Model_Order_Item $item
  * @param int $numAccounts number of accounts to create
  * @return boolean whether there is failure when creating gift card accounts
  */
 protected function _createGiftCardAccounts(Mage_Sales_Model_Order_Item $item, $numAccounts)
 {
     $options = $item->getProductOptions();
     $isRedeemable = $this->_isGiftcardRedeemable($item);
     $lifetime = $this->_getGiftcardLifeTime($item);
     $amount = $item->getBasePrice();
     $websiteId = Mage::app()->getStore($item->getOrder()->getStoreId())->getWebsiteId();
     $createdCodes = isset($options['giftcard_created_codes']) ? $options['giftcard_created_codes'] : array();
     $data = new Varien_Object();
     $data->setWebsiteId($websiteId)->setAmount($amount)->setLifetime($lifetime)->setIsRedeemable($isRedeemable)->setOrderItem($item);
     $hasFailedCodes = false;
     for ($i = 0; $i < $numAccounts; $i++) {
         try {
             $code = new Varien_Object();
             Mage::dispatchEvent('enterprise_giftcardaccount_create', array('request' => $data, 'code' => $code));
             $createdCodes[] = $code->getCode();
         } catch (Mage_Core_Exception $e) {
             $hasFailedCodes = true;
         }
     }
     $options['giftcard_created_codes'] = $createdCodes;
     $item->setProductOptions($options);
     return $hasFailedCodes;
 }
Ejemplo n.º 19
0
 /**
  * Gets the final price of the freight
  * Follows the rules of free shipping
  *
  * @param Varien_Object $method
  * @return boolean|int|float
  */
 protected function _getFinalPrice(Varien_Object $method, Mage_Shipping_Model_Rate_Request $request)
 {
     $freeMethod = $this->getConfigData('free_shipping_method');
     if ($method->hasError() && !$method->getShowMessage() || $method->getPrice() <= 0) {
         return false;
     }
     if ($request->getFreeShipping() === true) {
         if ($freeMethod == 'lower-price') {
             if ($bestMethod = $this->getLowerPriceMethod($this->_getClientRequest())) {
                 if ($bestMethod->getCode() == $method->getCode()) {
                     return 0;
                 }
             }
         }
         if ($freeMethod == $method->getCode()) {
             return 0;
         }
     }
     $finalPrice = $method->getPrice();
     if ($handlingFee = $this->getConfigData('handling_fee')) {
         switch ($this->getConfigData('handling_type')) {
             case 'F':
                 $finalPrice += $handlingFee;
                 break;
             case 'P':
                 $finalPrice = $handlingFee * $finalPrice / 100 + $finalPrice;
                 break;
         }
     }
     return $finalPrice;
 }
Ejemplo n.º 20
0
 /**
  * Retrieve row css class for specified item
  *
  * @param Varien_Object $item
  * @return string
  */
 public function getRowClass(Varien_Object $item)
 {
     if ($item->getCode() == Enterprise_Checkout_Helper_Data::ADD_ITEM_STATUS_FAILED_QTY_ALLOWED) {
         return 'qty-not-available';
     }
     return '';
 }
Ejemplo n.º 21
0
 public function getOptionValues()
 {
     $data = array();
     $optionsArr = '';
     $session = Mage::getSingleton('adminhtml/session');
     if ($data = $session->getData('customoptions_data')) {
         if (isset($data['general']['hash_options'])) {
             $optionsArr = $data['general']['hash_options'];
         }
     } elseif (Mage::registry('customoptions_data')) {
         $data = Mage::registry('customoptions_data')->getData();
         if (isset($data['hash_options'])) {
             $optionsArr = $data['hash_options'];
         }
     }
     $groupId = (int) $this->getRequest()->getParam('group_id');
     if ($optionsArr) {
         $optionsArr = unserialize($optionsArr);
     }
     $storeOptionsArr = array();
     $groupStore = Mage::getSingleton('customoptions/group_store')->loadByGroupAndStore($groupId, $this->getStoreId());
     if ($groupStore->getHashOptions()) {
         $storeOptionsArr = unserialize($groupStore->getHashOptions());
     }
     $product = Mage::getSingleton('catalog/product_option');
     if (!$this->_values && $optionsArr) {
         $values = array();
         $sortOrder = array();
         $scope = (int) Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE);
         $optionItemCount = count($optionsArr);
         foreach ($optionsArr as $optionId => $option) {
             $option = new Varien_Object($option);
             $value = array();
             if ($option->getIsDelete() != '1') {
                 $value['id'] = $option->getOptionId();
                 $value['item_count'] = $optionItemCount;
                 $value['option_id'] = $option->getOptionId();
                 $value['title'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['title']) ? $storeOptionsArr[$optionId]['title'] : $option->getTitle());
                 $value['type'] = $option->getType();
                 $value['is_require'] = $option->getIsRequire();
                 $value['is_enabled'] = $option->getIsEnabled();
                 $value['is_dependent'] = $option->getIsDependent();
                 $value['code'] = $this->htmlEscape($option->getCode());
                 $value['option_code'] = $option->getOptionCode();
                 $value['customoptions_is_onetime'] = $option->getCustomoptionsIsOnetime();
                 $value['qnty_input'] = $option->getQntyInput() ? 'checked' : '';
                 $value['qnty_input_disabled'] = $option->getType() == 'drop_down' || $option->getType() == 'radio' || $option->getType() == 'checkbox' ? '' : 'disabled';
                 $value['description'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['description']) ? $storeOptionsArr[$optionId]['description'] : $option->getDescription());
                 $value['block_title'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['block_title']) ? $storeOptionsArr[$optionId]['block_title'] : $option->getBlockTitle());
                 if (Mage::helper('customoptions')->isCustomerGroupsEnabled() && $option->getCustomerGroups() != null) {
                     $value['customer_groups'] = implode(',', $option->getCustomerGroups());
                 }
                 $value['in_group_id'] = $option->getInGroupId();
                 $value['in_group_id_view'] = $option->getInGroupId();
                 $value['sort_order'] = $this->_getSortOrder($option);
                 if ($this->getStoreId() != '0') {
                     $value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', !isset($storeOptionsArr[$optionId]['title']));
                     $value['scopeTitleDisabled'] = !isset($storeOptionsArr[$optionId]['title']) ? 'disabled' : null;
                     $value['checkboxScopeDescription'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'description', !isset($storeOptionsArr[$optionId]['description']));
                     $value['scopeDescriptionDisabled'] = !isset($storeOptionsArr[$optionId]['description']) ? 'disabled' : null;
                     $value['checkboxScopeBlockTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'block_title', !isset($storeOptionsArr[$optionId]['block_title']));
                     $value['scopeBlockTitleDisabled'] = !isset($storeOptionsArr[$optionId]['block_title']) ? 'disabled' : null;
                 }
                 if ($product->getGroupByType($option->getType()) == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) {
                     $countValues = count($option->getValues());
                     if ($countValues > 0) {
                         foreach ($option->getValues() as $key => $_value) {
                             $_value = new Varien_Object($_value);
                             $_value->setOptionTypeId($key);
                             if ($_value->getIsDelete() != '1') {
                                 $defaultArray = $option->getDefault() !== null ? $option->getDefault() : array();
                                 $value['optionValues'][$key] = array('item_count' => $countValues, 'option_id' => $option->getOptionId(), 'option_type_id' => $_value->getOptionTypeId(), 'title' => $this->htmlEscape(isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title'] : $_value->getTitle()), 'price' => $this->getPriceValue(isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price'] : $_value->getPrice(), $_value->getPriceType()), 'price_type' => isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type'] : $_value->getPriceType(), 'sku' => $this->htmlEscape($_value->getSku()), 'code' => $this->htmlEscape($_value->getCode()), 'tier' => $_value->getTier(), 'sort_order' => $this->_getSortOrder($_value), 'customoptions_qty' => $_value->getCustomoptionsQty(), 'checked' => array_search($_value->getOptionTypeId(), $defaultArray) !== false ? 'checked' : '', 'default_type' => $option->getType() == 'checkbox' || $option->getType() == 'multiple' ? 'checkbox' : 'radio', 'in_group_id' => $_value->getInGroupId(), 'in_group_id_view' => $_value->getInGroupId(), 'dependent_ids' => $_value->getDependentIds());
                                 $value['optionValues'][$key]['image_button_label'] = Mage::helper('customoptions')->__('Add Image');
                                 $imgHtml = Mage::helper('customoptions')->getImgHtml($_value->getImagePath(), $option->getId(), $_value->getOptionTypeId());
                                 if ($imgHtml) {
                                     $value['optionValues'][$key]['image'] = $imgHtml;
                                     $value['optionValues'][$key]['image_button_label'] = Mage::helper('customoptions')->__('Change Image');
                                 }
                                 if ($this->getStoreId() != '0') {
                                     $value['optionValues'][$key]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']), $_value->getOptionTypeId());
                                     $value['optionValues'][$key]['scopeTitleDisabled'] = !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']) ? 'disabled' : null;
                                     if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) {
                                         $value['optionValues'][$key]['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', is_null($_value->getstorePrice()), $_value->getOptionTypeId());
                                         $value['optionValues'][$key]['scopePriceDisabled'] = is_null($_value->getStorePrice()) ? 'disabled' : null;
                                     }
                                 }
                             }
                         }
                         $value['optionValues'] = array_values($value['optionValues']);
                     }
                 } else {
                     $value['price'] = $this->getPriceValue(isset($storeOptionsArr[$optionId]['price']) ? $storeOptionsArr[$optionId]['price'] : $option->getPrice(), $option->getPriceType());
                     $value['price_type'] = isset($storeOptionsArr[$optionId]['price_type']) ? $storeOptionsArr[$optionId]['price_type'] : $option->getPriceType();
                     $value['sku'] = $this->htmlEscape($option->getSku());
                     $value['code'] = $this->htmlEscape($option->getCode());
                     $value['max_characters'] = $option->getMaxCharacters();
                     $value['file_extension'] = $option->getFileExtension();
                     $value['image_size_x'] = $option->getImageSizeX();
                     $value['image_size_y'] = $option->getImageSizeY();
                     $value['image_button_label'] = Mage::helper('customoptions')->__('Add Image');
                     $imgHtml = Mage::helper('customoptions')->getImgHtml($option->getImagePath(), $option->getId());
                     if ($imgHtml) {
                         $value['image'] = $imgHtml;
                         $value['image_button_label'] = Mage::helper('customoptions')->__('Change Image');
                     }
                     if ($this->getStoreId() != '0' && $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) {
                         $value['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', is_null($option->getStorePrice()));
                         $value['scopePriceDisabled'] = is_null($option->getStorePrice()) ? 'disabled' : null;
                     }
                 }
                 $values[] = new Varien_Object($value);
             }
         }
         $this->_values = $values;
     }
     return $this->_values ? $this->_values : array();
 }