Esempio n. 1
0
 /**
  * Return custom options from item
  * 
  * @see Mage_Sales_Block_Order_Item_Renderer_Default::getItemOptions()
  * @return array
  */
 protected function _getItemOptions(Mage_Sales_Model_Order_Item $item)
 {
     $result = array();
     if ($options = $item->getProductOptions()) {
         if (isset($options['options'])) {
             $result = array_merge($result, $options['options']);
         }
         if (isset($options['additional_options'])) {
             $result = array_merge($result, $options['additional_options']);
         }
         if (isset($options['attributes_info'])) {
             $result = array_merge($result, $options['attributes_info']);
         }
     }
     return $result;
 }
Esempio n. 2
0
/**
 * Returns all the product options of the given item including additional_options and
 * attributes_info.
 *
 * @param Mage_Sales_Model_Order_Item $item The item to return info from
 * @return Array The item options
 */
function getItemOrderOptions($item)
{
    $result = array();
    if ($options = $item->getProductOptions()) {
        if (isset($options['options'])) {
            $result = array_merge($result, $options['options']);
        }
        if (isset($options['additional_options'])) {
            $result = array_merge($result, $options['additional_options']);
        }
        if (!empty($options['attributes_info'])) {
            $result = array_merge($options['attributes_info'], $result);
        }
    }
    return $result;
}
Esempio n. 3
0
 /**
  * Test if order item must be included in
  * @param Mage_Sales_Model_Order_Item $OrderItem
  */
 public function hasSubscriptionOptions($OrderItem)
 {
     $options = $OrderItem->getProductOptions();
     if (isset($options['info_buyRequest'])) {
         $periodTypeId = @$options['info_buyRequest']['aw_sarp_subscription_type'];
     } else {
         $periodTypeId = -1;
     }
     return $periodTypeId > 0;
 }
Esempio n. 4
0
 /**
  * Send email to giftcard recipient
  *
  * @param Mage_Sales_Model_Order_Item $item
  * @param int $numGiftCardsToSend
  * @return void
  */
 protected function _sendEmail($item, $numGiftCardsToSend)
 {
     if ($numGiftCardsToSend <= 0) {
         return;
     }
     $options = $item->getProductOptions();
     $createdGiftCardCodes = isset($options['giftcard_created_codes']) ? $options['giftcard_created_codes'] : array();
     $sentCodes = isset($options['giftcard_sent_codes']) ? $options['giftcard_sent_codes'] : array();
     $sentCodesQty = count($sentCodes);
     $availableCodes = $sentCodesQty > 0 ? array_diff($createdGiftCardCodes, $sentCodes) : $createdGiftCardCodes;
     if (count($availableCodes) <= 0) {
         return;
     }
     $newlySentCodes = array();
     $numNewlySentCodes = 0;
     foreach ($availableCodes as $code) {
         $newlySentCodes[] = $code;
         $sentCodes[] = $code;
         $numNewlySentCodes++;
         if ($numNewlySentCodes == $numGiftCardsToSend) {
             break;
         }
     }
     $sender = $item->getProductOptionByCode('giftcard_sender_name');
     $senderName = $item->getProductOptionByCode('giftcard_sender_name');
     $senderEmail = $item->getProductOptionByCode('giftcard_sender_email');
     if ($senderEmail) {
         $sender = "{$sender} <{$senderEmail}>";
     }
     $isRedeemable = $this->_isGiftCardRedeemable($item);
     $amount = $item->getBasePrice();
     $store = Mage::app()->getStore($item->getOrder()->getStoreId());
     $codeList = Mage::helper('enterprise_giftcard')->getEmailGeneratedItemsBlock()->setCodes($newlySentCodes)->setIsRedeemable($isRedeemable)->setStore($store);
     $balance = Mage::app()->getLocale()->currency($store->getBaseCurrencyCode())->toCurrency($amount);
     $templateData = array('name' => $item->getProductOptionByCode('giftcard_recipient_name'), 'email' => $item->getProductOptionByCode('giftcard_recipient_email'), 'sender_name_with_email' => $sender, 'sender_name' => $senderName, 'gift_message' => $item->getProductOptionByCode('giftcard_message'), 'giftcards' => $codeList->toHtml(), 'balance' => $balance, 'is_multiple_codes' => 1 < $numNewlySentCodes, 'store' => $store, 'store_name' => $store->getName(), 'is_redeemable' => $isRedeemable);
     $email = Mage::getModel('core/email_template')->setDesignConfig(array('store' => $store->getId()));
     $email->sendTransactional($item->getProductOptionByCode('giftcard_email_template'), Mage::getStoreConfig(Enterprise_GiftCard_Model_Giftcard::XML_PATH_EMAIL_IDENTITY, $store->getId()), $item->getProductOptionByCode('giftcard_recipient_email'), $item->getProductOptionByCode('giftcard_recipient_name'), $templateData);
     $options['giftcard_sent_codes'] = $sentCodes;
     if ($email->getSentSuccess()) {
         $options['email_sent'] = 1;
     }
     $item->setProductOptions($options);
     return;
 }
 /**
  * @param Mage_Sales_Model_Order_Item $orderItem
  *
  * @return array
  */
 protected function _getOrderItemOptions($orderItem)
 {
     $orderItemOptions = $orderItem->getProductOptions();
     //if product doesn't have options
     if (!array_key_exists('options', $orderItemOptions)) {
         return array();
     }
     $orderItemOptions = $orderItemOptions['options'];
     //if product options isn't array
     if (!is_array($orderItemOptions)) {
         return array();
     }
     $options = array();
     foreach ($orderItemOptions as $orderItemOption) {
         if (array_key_exists('value', $orderItemOption) && array_key_exists('label', $orderItemOption)) {
             $label = str_replace(' ', '-', $orderItemOption['label']);
             $options[][$label] = $orderItemOption['value'];
         }
     }
     return $options;
 }
Esempio n. 6
0
 /**
  * Retrieves RMA item sku for backend
  *
  * @param  Mage_Sales_Model_Order_Item $item
  * @return string
  */
 public function getAdminProductSku($item)
 {
     $name = $item->getSku();
     if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
         $productOptions = $item->getProductOptions();
         return $productOptions['simple_sku'];
     }
     return $name;
 }