Example #1
0
 /**
  * Render minimal price for downloadable products
  *
  * @param   Varien_Object $row
  * @return  string
  */
 public function render(Varien_Object $row)
 {
     if ($row->getTypeId() == 'downloadable') {
         $row->setPrice($row->getPrice());
     }
     $Product = Mage::getModel('catalog/product')->load($row->getData('entity_id'));
     if (Mage::helper('request4quote')->isRentalInstalled()) {
         if ($row->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE || $Product->getIsReservation() != ITwebexperts_Payperrentals_Model_Product_Isreservation::STATUS_DISABLED) {
             $row->setPrice('');
         }
     }
     return parent::render($row);
 }
Example #2
0
 /**
  * Render minimal price for downloadable products
  *
  * @param   Varien_Object $row
  * @return  string
  */
 public function render(Varien_Object $row)
 {
     if ($row->getTypeId() == Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE) {
         $row->setPrice($row->getPrice());
     }
     return parent::render($row);
 }
Example #3
0
 /**
  * Render minimal price for downloadable products
  *
  * @param   Varien_Object $row
  * @return  string
  */
 public function render(Varien_Object $row)
 {
     if ($row->getTypeId() == 'downloadable') {
         $row->setPrice($row->getPrice());
     }
     return parent::render($row);
 }
Example #4
0
 /**
  * Overwrite this method to copy custom fields values to orders created by recurring profile
  */
 protected function _registerRecurringProfilePaymentCapture()
 {
     $price = $this->getRequestData('mc_gross') - $this->getRequestData('tax') - $this->getRequestData('shipping');
     $productItemInfo = new Varien_Object();
     $type = trim($this->getRequestData('period_type'));
     if ($type == 'Trial') {
         $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL);
     } elseif ($type == 'Regular') {
         $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
     }
     $productItemInfo->setTaxAmount($this->getRequestData('tax'));
     $productItemInfo->setShippingAmount($this->getRequestData('shipping'));
     $productItemInfo->setPrice($price);
     $order = $this->_recurringProfile->createOrder($productItemInfo);
     $payment = $order->getPayment();
     $payment->setTransactionId($this->getRequestData('txn_id'))->setPreparedMessage($this->_createIpnComment(''))->setIsTransactionClosed(0);
     $order->save();
     $this->_recurringProfile->addOrderRelation($order->getId());
     $payment->registerCaptureNotification($this->getRequestData('mc_gross'));
     $order->save();
     // notify customer
     if ($invoice = $payment->getCreatedInvoice()) {
         $message = Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId());
         $comment = $order->sendNewOrderEmail()->addStatusHistoryComment($message)->setIsCustomerNotified(true)->save();
     }
     //start aitoc modification
     Mage::getModel('aitcheckoutfields/aitcheckoutfields')->copyRecProfileFieldsToOrderFields($this->_recurringProfile->getId(), $order->getId());
     //end aitoc modification
 }
 /**
  * Converts map array to microdata Object
  *
  * @param array $map map array returned by the generator
  * @return null|Varien_Object
  */
 protected function _createRowObject($map)
 {
     if (empty($map['price']) || empty($map['availability']) || empty($map['title'])) {
         return null;
     }
     $microdata = new Varien_Object();
     $microdata->setName($map['title']);
     $microdata->setId($map['id']);
     if (!empty($map['sale_price'])) {
         $price = $map['sale_price'];
     } else {
         $price = $map['price'];
     }
     $microdata->setPrice(Zend_Locale_Format::toNumber($price, array('precision' => 2, 'number_format' => '#0.00')));
     $microdata->setCurrency(Mage::app()->getStore()->getCurrentCurrencyCode());
     if ($map['availability'] == 'in stock') {
         $microdata->setAvailability('http://schema.org/InStock');
     } else {
         $microdata->setAvailability('http://schema.org/OutOfStock');
     }
     if (array_key_exists('condition', $map)) {
         if (strcasecmp('new', $map['condition']) == 0) {
             $microdata->setCondition('http://schema.org/NewCondition');
         } else {
             if (strcasecmp('used', $map['condition']) == 0) {
                 $microdata->setCondition('http://schema.org/UsedCondition');
             } else {
                 if (strcasecmp('refurbished', $map['condition']) == 0) {
                     $microdata->setCondition('http://schema.org/RefurbishedCondition');
                 }
             }
         }
     }
     return $microdata;
 }
Example #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;
 }
Example #7
0
 /**
  * Prepare collection of errors
  *
  * @return Enterprise_Checkout_Block_Adminhtml_Sku_Errors_Grid
  */
 protected function _prepareCollection()
 {
     $collection = new Varien_Data_Collection();
     $removeButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button', '', array('class' => 'delete', 'label' => '', 'onclick' => 'addBySku.removeFailedItem(this)', 'type' => 'button'))->toHtml();
     /* @var $parentBlock Enterprise_Checkout_Block_Adminhtml_Sku_Errors_Abstract */
     $parentBlock = $this->getParentBlock();
     foreach ($parentBlock->getFailedItems() as $affectedItem) {
         // Escape user-submitted input
         if (isset($affectedItem['item']['qty'])) {
             $affectedItem['item']['qty'] = empty($affectedItem['item']['qty']) ? '' : (double) $affectedItem['item']['qty'];
         }
         $item = new Varien_Object();
         $item->setCode($affectedItem['code']);
         if (isset($affectedItem['error'])) {
             $item->setError($affectedItem['error']);
         }
         $item->addData($affectedItem['item']);
         $item->setId($item->getSku());
         /* @var $product Mage_Catalog_Model_Product */
         $product = Mage::getModel('catalog/product');
         if (isset($affectedItem['item']['id'])) {
             $productId = $affectedItem['item']['id'];
             $item->setProductId($productId);
             $product->load($productId);
             /* @var $stockStatus Mage_CatalogInventory_Model_Stock_Status */
             $stockStatus = Mage::getModel('cataloginventory/stock_status');
             $status = $stockStatus->getProductStatus($productId, $this->getWebsiteId());
             if (!empty($status[$productId])) {
                 $product->setIsSalable($status[$productId]);
             }
             $item->setPrice(Mage::helper('core')->formatPrice($product->getPrice()));
         }
         $descriptionBlock = $this->getLayout()->createBlock('enterprise_checkout/adminhtml_sku_errors_grid_description', '', array('product' => $product, 'item' => $item));
         $item->setDescription($descriptionBlock->toHtml());
         $item->setRemoveButton($removeButtonHtml);
         $collection->addItem($item);
     }
     $this->setCollection($collection);
     return $this;
 }
Example #8
0
 protected function _registerRecurringProfilePaymentCapture()
 {
     $price = $this->getRequestData('mc_gross') - $this->getRequestData('tax') - $this->getRequestData('shipping');
     $productItemInfo = new Varien_Object();
     $type = trim($this->getRequestData('period_type'));
     if ($type == 'Trial') {
         $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL);
     } elseif ($type == 'Regular') {
         $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
     }
     $productItemInfo->setTaxAmount($this->getRequestData('tax'));
     $productItemInfo->setShippingAmount($this->getRequestData('shipping'));
     $productItemInfo->setPrice($price);
     $order = $this->_recurringProfile->createOrder($productItemInfo);
     $payment = $order->getPayment();
     $payment->setTransactionId($this->getRequestData('txn_id'))->setPreparedMessage($this->_createIpnComment(''))->setIsTransactionClosed(0);
     $order->save();
     $this->_recurringProfile->addOrderRelation($order->getId());
     $payment->registerCaptureNotification($this->getRequestData('mc_gross'));
     $order->save();
     /*----------- add by KK --------*/
     $profile = $this->_recurringProfile;
     $plugin = Mage::helper('usermanagement/plugin')->load($profile->getId(), 'profile_id');
     $oldExpiredTime = $plugin->getExpiredTime();
     if ($type == 'Trial') {
         $trialPeriodUnit = $profile->getTrialPeriodUnit();
         $trialPeriodFrequency = $profile->getTrialPeriodFrequency();
         switch ($trialPeriodUnit) {
             case 'day':
                 $expiredTime = strtotime("+{$trialPeriodFrequency} day", strtotime($oldExpiredTime));
                 break;
             case 'week':
                 $expiredTime = strtotime("+{$trialPeriodFrequency} week", strtotime($oldExpiredTime));
                 break;
             case 'semi_month':
                 $df = $trialPeriodFrequency * 2;
                 $expiredTime = strtotime("+{$df} week", strtotime($oldExpiredTime));
                 break;
             case 'month':
                 $expiredTime = strtotime("+{$trialPeriodFrequency} month", strtotime($oldExpiredTime));
                 break;
             case 'year':
                 $expiredTime = strtotime("+{$trialPeriodFrequency} year", strtotime($oldExpiredTime));
                 break;
         }
     } elseif ($type == 'Regular') {
         $periodUnit = $recurringProfile->getPeriodUnit();
         $periodFrequency = $recurringProfile->getPeriodFrequency();
         switch ($periodUnit) {
             case 'day':
                 $expiredTime = strtotime("+{$periodFrequency} day", strtotime($oldExpiredTime));
                 break;
             case 'week':
                 $expiredTime = strtotime("+{$periodFrequency} week", strtotime($oldExpiredTime));
                 break;
             case 'semi_month':
                 $df = $periodFrequency * 2;
                 $expiredTime = strtotime("+{$df} week", strtotime($oldExpiredTime));
                 break;
             case 'month':
                 $expiredTime = strtotime("+{$periodFrequency} month", strtotime($oldExpiredTime));
                 break;
             case 'year':
                 $expiredTime = strtotime("+{$periodFrequency} year", strtotime($oldExpiredTime));
                 break;
         }
         $plugin->setStatus(Simicart_UserManagement_Model_Plugin::STATUS_ENABLED);
     }
     $plugin->setExpiredTime($expiredTime);
     try {
         $plugin->save();
     } catch (Exception $e) {
     }
     /*--------------end-------------*/
     $invoice = $payment->getCreatedInvoice();
     if ($invoice) {
         // notify customer
         $message = Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId());
         $order->sendNewOrderEmail()->addStatusHistoryComment($message)->setIsCustomerNotified(true)->save();
     }
 }
 /**
  * Register recurring payment notification, create and process order
  */
 protected function _registerRecurringProfilePaymentCapture()
 {
     $price = $this->_price;
     $tax = $this->_taxAmount;
     $shipping = $this->_shippingAmount;
     $grandTotal = $this->_amount;
     $periodType = $this->_periodType;
     $transactionId = $this->_txdId;
     $ewayMessage = '';
     $productItemInfo = new Varien_Object();
     /** @todo: response doesn't contain period type / payment type */
     $productItemInfo->setPaymentType($periodType);
     $productItemInfo->setTaxAmount($tax);
     $productItemInfo->setShippingAmount($shipping);
     $productItemInfo->setPrice($price);
     /** @var Mage_Sales_Model_Recurring_Profile $recurringProfile */
     $recurringProfile = $this->_recurringProfile;
     $order = $recurringProfile->createOrder($productItemInfo);
     $payment = $order->getPayment();
     $payment->setTransactionId($transactionId)->setPreparedMessage($ewayMessage)->setIsTransactionClosed(0);
     $order->save();
     $this->_recurringProfile->addOrderRelation($order->getId());
     $payment->registerCaptureNotification($grandTotal);
     $order->save();
     // notify customer
     if ($invoice = $payment->getCreatedInvoice()) {
         $message = Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId());
         $comment = $order->sendNewOrderEmail()->addStatusHistoryComment($message)->setIsCustomerNotified(true)->save();
     }
     if (!$recurringProfile->getIsCronJob()) {
         $session = Mage::getSingleton('checkout/type_onepage')->getCheckout();
         $session->setLastOrderId($order->getId());
     }
 }
 /**
  *
  * @param Mage_Sales_Model_Recurring_Profile $profile
  * @param Allopass_Hipay_Model_Api_Response_Notification $response
  * @return Mage_Sales_Model_Order
  */
 protected function createProfileOrder(Mage_Sales_Model_Recurring_Profile $profile, Allopass_Hipay_Model_Api_Response_Notification $response)
 {
     $amount = $this->getAmountFromProfile($profile);
     $productItemInfo = new Varien_Object();
     $type = "Regular";
     if ($type == 'Trial') {
         $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL);
     } elseif ($type == 'Regular') {
         $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
     }
     if ($this->isInitialProfileOrder($profile)) {
         // because is not additonned in prodile obj
         $productItemInfo->setPrice($profile->getBillingAmount() + $profile->getInitAmount());
     }
     /* @var $order Mage_Sales_Model_Order */
     $order = $profile->createOrder($productItemInfo);
     //$this->responseToPayment($order->getPayment(),$response);
     $additionalInfo = $profile->getAdditionalInfo();
     $order->getPayment()->setCcType($additionalInfo['ccType']);
     $order->getPayment()->setCcExpMonth($additionalInfo['ccExpMonth']);
     $order->getPayment()->setCcExpYear($additionalInfo['ccExpYear']);
     $order->getPayment()->setAdditionalInformation('token', $additionalInfo['token']);
     $order->getPayment()->setAdditionalInformation('create_oneclick', $additionalInfo['create_oneclick']);
     $order->getPayment()->setAdditionalInformation('use_oneclick', $additionalInfo['use_oneclick']);
     //$order->getPayment()->setAdditionalInformation('selected_oneclick_card', $additionalInfo['selected_oneclick_card']);
     $order->setState(Mage_Sales_Model_Order::STATE_NEW, 'pending', Mage::helper('hipay')->__("New Order Recurring!"));
     $order->save();
     $profile->addOrderRelation($order->getId());
     $profile->save();
     return $order;
     $order->getPayment()->registerCaptureNotification($amount);
     $order->save();
     // notify customer
     if ($invoice = $order->getPayment()->getCreatedInvoice()) {
         $message = Mage::helper('hipay')->__('Notified customer about invoice #%s.', $invoice->getIncrementId());
         $comment = $order->sendNewOrderEmail()->addStatusHistoryComment($message)->setIsCustomerNotified(true)->save();
         /* Add this to send invoice to customer */
         $invoice->setEmailSent(true);
         $invoice->save();
         $invoice->sendEmail();
     }
     return $order;
 }
 public function getOptionValues()
 {
     $data = array();
     $optionsArr = '';
     $data = $this->getTemplateData();
     if (isset($data['hash_options'])) {
         $optionsArr = $data['hash_options'];
     }
     $zendDate = new Zend_Date();
     $dateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
     $helper = Mage::helper('customoptions');
     $helper->getCustomerGroups();
     // init customer_groups for sort prices
     $groupId = (int) $this->getRequest()->getParam('group_id');
     if ($optionsArr) {
         $optionsArr = unserialize($optionsArr);
     }
     $store = Mage::app()->getStore($this->getStoreId());
     $storeOptionsArr = array();
     $groupStore = Mage::getSingleton('customoptions/group_store')->loadByGroupAndStore($groupId, $this->getStoreId());
     if ($groupStore->getHashOptions()) {
         $storeOptionsArr = unserialize($groupStore->getHashOptions());
     }
     //print_r($storeOptionsArr); exit;
     $optionModel = 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());
                 // old view_mode = hidden => to new type = 'hidden';
                 if ($optionModel->getGroupByType($option->getType()) == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT && $option->getViewMode() == 2) {
                     $option->setType('hidden');
                     $option->setViewMode(1);
                 }
                 $value['type'] = $option->getType();
                 $value['is_require'] = $option->getIsRequire();
                 $value['view_mode'] = isset($storeOptionsArr[$optionId]['view_mode']) ? $storeOptionsArr[$optionId]['view_mode'] : $option->getViewMode();
                 $value['is_dependent'] = $option->getIsDependent();
                 $value['div_class'] = $option->getDivClass();
                 $value['sku_policy'] = $option->getSkuPolicy();
                 $value['customoptions_is_onetime'] = $option->getCustomoptionsIsOnetime();
                 $value['qnty_input'] = $option->getQntyInput() ? 'checked' : '';
                 $value['qnty_input_disabled'] = $option->getType() == 'multiple' || $option->getType() == 'hidden' ? 'disabled' : '';
                 $value['image_mode'] = $option->getImageMode();
                 $value['image_mode_disabled'] = $optionModel->getGroupByType($option->getType()) != Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT ? 'disabled' : '';
                 $value['exclude_first_image'] = $option->getExcludeFirstImage() ? 'checked' : '';
                 $value['description'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['description']) ? $storeOptionsArr[$optionId]['description'] : $option->getDescription());
                 if ($helper->isCustomerGroupsEnabled() && $option->getCustomerGroups() != null) {
                     $value['customer_groups'] = implode(',', $option->getCustomerGroups());
                 }
                 if ($helper->isStoreViewsEnabled() && $option->getStoreViews() != null) {
                     $value['store_views'] = implode(',', $option->getStoreViews());
                 }
                 $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['checkboxScopeViewMode'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'view_mode', !isset($storeOptionsArr[$optionId]['view_mode']));
                     $value['scopeViewModeDisabled'] = !isset($storeOptionsArr[$optionId]['view_mode']) ? 'disabled' : null;
                     $value['checkboxScopeDescription'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'description', !isset($storeOptionsArr[$optionId]['description']));
                     $value['scopeDescriptionDisabled'] = !isset($storeOptionsArr[$optionId]['description']) ? 'disabled' : null;
                 }
                 if ($optionModel->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();
                                 if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price'])) {
                                     $_value->setPrice(floatval($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price']));
                                 }
                                 if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type'])) {
                                     $_value->setPriceType($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type']);
                                 }
                                 // for support old format:
                                 if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_price'])) {
                                     $_value->setSpecialPrice(floatval($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_price']));
                                 }
                                 if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_comment'])) {
                                     $_value->setSpecialComment($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_comment']);
                                 }
                                 if ($_value->getSpecialPrice()) {
                                     $_value->setSpecials(array(array('customer_group_id' => 32000, 'price' => $_value->getSpecialPrice(), 'price_type' => 'fixed', 'comment' => $_value->getSpecialComment(), 'date_from' => '', 'date_to' => '')));
                                 }
                                 $helper->applyLinkedBySkuDataToOption($_value, $_value->getSku(), $store, 0);
                                 $helper->calculateOptionSpecialPrice($_value, null, $helper->isSpecialPriceEnabled());
                                 $priceDisabled = $_value->getIsSkuPrice();
                                 list($skuClass, $viewProductBySkuHtml) = $this->getViewSkuData($_value->getSku());
                                 if (!$helper->isSkuQtyLinkingEnabled() || $helper->getProductIdBySku($_value->getSku()) == 0) {
                                     $customoptionsQty = $_value->getCustomoptionsQty();
                                 } else {
                                     list($customoptionsQty, $backorders) = $helper->getCustomoptionsQty($_value->getCustomoptionsQty(), $_value->getSku(), 0, null, null, null, true);
                                 }
                                 $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($_value->getPrice(), $_value->getPriceType()), 'price_type' => $_value->getPriceType(), 'price_disabled' => $priceDisabled, 'description' => $this->htmlEscape(isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['description']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['description'] : $_value->getDescription()), 'cost' => $this->getPriceValue($_value->getCost(), 'fixed'), 'cost_disabled' => $_value->getIsSkuCost() ? 'disabled' : '', 'customoptions_qty' => $customoptionsQty, 'customoptions_qty_disabled' => $helper->isSkuQtyLinkingEnabled() && $helper->getProductIdBySku($_value->getSku()) ? 'disabled="disabled"' : '', 'sku' => $this->htmlEscape($_value->getSku()), 'sku_class' => $skuClass, 'view_product_by_sku_html' => $viewProductBySkuHtml, 'image_button_label' => $helper->__('Add Image'), 'sort_order' => $this->_getSortOrder($_value), 'checked' => array_search($_value->getOptionTypeId(), $defaultArray) !== false ? 'checked' : '', 'default_type' => $option->getType() == 'checkbox' || $option->getType() == 'multiple' || $option->getType() == 'multiswatch' || $option->getType() == 'hidden' ? 'checkbox' : 'radio', 'in_group_id' => $_value->getInGroupId(), 'in_group_id_view' => $_value->getInGroupId(), 'dependent_ids' => $_value->getDependentIds(), 'weight' => number_format(floatval($_value->getWeight()), 4, null, ''), 'weight_disabled' => $_value->getIsSkuWeight() ? 'disabled' : '');
                                 // getImages
                                 $images = $_value->getImages();
                                 if ($images) {
                                     $imagePath = $groupId . DS . $option->getId() . DS . $_value->getOptionTypeId() . DS;
                                     foreach ($images as $fileName) {
                                         if (substr($fileName, 0, 1) == '#') {
                                             // color
                                             $colorArr = array('id' => $option->getId(), 'select_id' => $_value->getOptionTypeId(), 'image_file' => $fileName, 'option_type_image_id' => $fileName, 'source' => 2);
                                             $value['optionValues'][$key]['images'][] = $colorArr;
                                         } else {
                                             // file
                                             $imgArr = $helper->getImgData($imagePath . $fileName, $option->getId(), $_value->getOptionTypeId());
                                             if ($imgArr) {
                                                 $imgArr['option_type_image_id'] = $imgArr['file_name'];
                                                 $value['optionValues'][$key]['images'][] = $imgArr;
                                             }
                                         }
                                     }
                                 } elseif ($_value->getImagePath()) {
                                     // old format
                                     $imgArr = $helper->getImgData($_value->getImagePath(), $option->getId(), $_value->getOptionTypeId());
                                     if ($imgArr) {
                                         $imgArr['option_type_image_id'] = $imgArr['file_name'];
                                         $value['optionValues'][$key]['images'][] = $imgArr;
                                     }
                                 } else {
                                     $value['optionValues'][$key]['image_tr_style'] = 'display:none';
                                 }
                                 //getOptionValueSpecialPrices
                                 $specialPrices = isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['specials']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['specials'] : $_value->getSpecials();
                                 if ($specialPrices) {
                                     foreach ($specialPrices as $specialKey => $specialPrice) {
                                         $specialPrices[$specialKey]['price'] = $this->getPriceValue($specialPrice['price'], $specialPrice['price_type']);
                                         if (isset($specialPrice['date_from']) && $specialPrice['date_from']) {
                                             $specialPrices[$specialKey]['date_from'] = $zendDate->setDate($specialPrice['date_from'], Varien_Date::DATE_INTERNAL_FORMAT)->toString($dateFormat);
                                         } else {
                                             $specialPrices[$specialKey]['date_from'] = '';
                                         }
                                         if (isset($specialPrice['date_to']) && $specialPrice['date_to']) {
                                             $specialPrices[$specialKey]['date_to'] = $zendDate->setDate($specialPrice['date_to'], Varien_Date::DATE_INTERNAL_FORMAT)->toString($dateFormat);
                                         } else {
                                             $specialPrices[$specialKey]['date_to'] = '';
                                         }
                                     }
                                     usort($specialPrices, array($helper, '_sortPrices'));
                                     $value['optionValues'][$key]['specials'] = $specialPrices;
                                 }
                                 //getOptionValueTierPrices
                                 $tierPrices = isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['tiers']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['tiers'] : $_value->getTiers();
                                 if ($tierPrices) {
                                     foreach ($tierPrices as $tierKey => $tierPrice) {
                                         $tierPrices[$tierKey]['price'] = $this->getPriceValue($tierPrice['price'], $tierPrice['price_type']);
                                     }
                                     usort($tierPrices, array($helper, '_sortPrices'));
                                     $value['optionValues'][$key]['tiers'] = $tierPrices;
                                 }
                                 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;
                                     $value['optionValues'][$key]['checkboxScopeDescription'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'description', !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['description']), $_value->getOptionTypeId());
                                     $value['optionValues'][$key]['scopeDescriptionDisabled'] = !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['description']) ? 'disabled' : null;
                                     //if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) {
                                     if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price'])) {
                                         $scopePrice = true;
                                     } else {
                                         $scopePrice = false;
                                     }
                                     if (!$priceDisabled) {
                                         $value['optionValues'][$key]['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', !$scopePrice, $_value->getOptionTypeId());
                                     }
                                     $value['optionValues'][$key]['scopePriceDisabled'] = !$scopePrice ? 'disabled' : null;
                                     //}
                                 }
                             }
                         }
                         $value['optionValues'] = array_values($value['optionValues']);
                     }
                 } else {
                     if (isset($storeOptionsArr[$optionId]['price'])) {
                         $option->setPrice(floatval($storeOptionsArr[$optionId]['price']));
                     }
                     if (isset($storeOptionsArr[$optionId]['price_type'])) {
                         $option->setPriceType($storeOptionsArr[$optionId]['price_type']);
                     }
                     $helper->applyLinkedBySkuDataToOption($option, $option->getSku(), $store, 0);
                     $helper->calculateOptionSpecialPrice($option, null, false);
                     $priceDisabled = $option->getIsSkuPrice();
                     list($skuClass, $viewProductBySkuHtml) = $this->getViewSkuData($option->getSku());
                     $value['price'] = $this->getPriceValue($option->getPrice(), $option->getPriceType());
                     $value['price_type'] = $option->getPriceType();
                     $value['price_disabled'] = $priceDisabled;
                     $value['sku'] = $this->htmlEscape($option->getSku());
                     $value['sku_class'] = $skuClass;
                     $value['view_product_by_sku_html'] = $viewProductBySkuHtml;
                     $value['max_characters'] = $option->getMaxCharacters();
                     $value['default_text'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['default_text']) ? $storeOptionsArr[$optionId]['default_text'] : $option->getDefaultText());
                     $value['file_extension'] = $option->getFileExtension();
                     $value['image_size_x'] = $option->getImageSizeX();
                     $value['image_size_y'] = $option->getImageSizeY();
                     $value['image_button_label'] = $helper->__('Add Image');
                     $imgHtml = $helper->getImgHtml($helper->getImgData($option->getImagePath(), $option->getId()));
                     if ($imgHtml) {
                         $value['image'] = $imgHtml;
                         $value['image_button_label'] = $helper->__('Change Image');
                     }
                     if ($this->getStoreId() != '0') {
                         //&& $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE
                         if (!$priceDisabled) {
                             $value['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', !isset($storeOptionsArr[$optionId]['price']));
                         }
                         $value['scopePriceDisabled'] = !isset($storeOptionsArr[$optionId]['price']) ? 'disabled' : null;
                         $value['checkboxScopeDefaultText'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'default_text', !isset($storeOptionsArr[$optionId]['default_text']));
                         $value['scopeDefaultTextDisabled'] = !isset($storeOptionsArr[$optionId]['default_text']) ? 'disabled' : null;
                     }
                 }
                 $values[] = new Varien_Object($value);
             }
         }
         $this->_values = $values;
     }
     return $this->_values ? $this->_values : array();
 }
Example #12
0
 /**
  * Converts the data returned from webservice to the object
  * Varien_Object using the parameter names in English
  *
  * @param stdClass $data
  * @return Varien_Object
  */
 private function _convertWebserviceValues(stdClass $data)
 {
     $result = new Varien_Object();
     $result->setCode($data->Codigo);
     $canShowMessage = $this->_isAllowedError($data->Erro);
     if ($data->Erro) {
         $result->setError($data->Erro)->setErrorMessage($data->MsgErro)->setShowMessage($canShowMessage);
     }
     $result->setPrice($this->_getHelper()->convertToFloat($data->Valor))->setDeliveryTime($data->PrazoEntrega + intval($this->_getHelper()->getConfigData('add_delivery_time')))->setHomeDelivery($data->EntregaDomiciliar == 'S' ? true : false)->setSaturdayDelivery($data->EntregaSabado == 'S' ? true : false);
     return $result;
 }
 public function extractRefundLine($order, $amount)
 {
     $_extract = new Varien_Object();
     $_extract->setName('Refund / Correction');
     $_extract->setPrice($amount);
     $_extract->setTaxAmount(0);
     $_extract->setQtyOrdered(1);
     return $_extract;
 }
Example #14
0
 public function getDealPricesSpare($orig, $deal)
 {
     $priceInfo = new Varien_Object();
     $price = $this->_currencyHelper->currency($deal->getPrice());
     $save = $this->_currencyHelper->currency($orig->getFinalPrice() - $deal->getPrice(), true, false);
     /* Avoide devision by zero */
     $discount = 0;
     if ($orig->getFinalPrice()) {
         $discount = ($orig->getFinalPrice() - $deal->getPrice()) / $orig->getFinalPrice() * 100;
     }
     $priceInfo->setPrice($price)->setSaveAmount($save)->setPercentDiscount(round($discount, 1));
     return $priceInfo;
 }