Example #1
0
 /**
  * Renders grid column
  *
  * @param   Varien_Object $row
  * @return  string
  */
 public function render(Varien_Object $row)
 {
     $action_name = $this->getRequest()->getActionName();
     if ($action_name == 'exportCsv' || $action_name == 'exportXml') {
         return $row->getName();
     }
     $href = $this->getUrl('*/catalog_product/edit', array('store' => $this->getRequest()->getParam('store'), 'id' => $row->getId()));
     $html = '<a href="' . $href . '">' . $row->getName() . '</a>';
     return $html;
 }
Example #2
0
 public function render(Varien_Object $row)
 {
     $content = "";
     $content .= "<b>" . $row->getName() . ' [' . $row->getStoreCode() . ']</b><br>';
     $content .= Mage::helper('pointofsale')->getStoreDescription($row);
     return $content;
 }
 protected function _checkPost($requireAccessToken = true)
 {
     if (Mage::helper('storealerts')->isDebug() || Mage::app()->getStore()->isCurrentlySecure()) {
         if ($data = $this->getRequest()->getPost()) {
             $dataObj = new Varien_Object();
             $dataObj->setData($data);
             $deviceToken = $dataObj->getDeviceToken();
             $name = $dataObj->getName();
             $username = $dataObj->getUsername();
             $password = $dataObj->getPassword();
             $accessToken = $requireAccessToken ? $dataObj->getAccessToken() : true;
             if ($deviceToken && $username && $password && $accessToken) {
                 $admin = Mage::helper('storealerts')->login($username, $password);
                 if ($admin->getId()) {
                     try {
                         $datetime = date("Y-m-d H:i:s");
                         $preference = Mage::getModel('extensions_store_storealerts/preference');
                         $preference->load($admin->getId());
                         if (!$preference->getId()) {
                             $preference->setUserId($admin->getId())->setCreatedAt($datetime)->setUpdatedAt($datetime)->save();
                         }
                         $dataObj->setPreference($preference);
                         $device = Mage::getModel('extensions_store_storealerts/device');
                         $device->load($deviceToken, 'device_token');
                         if (!$device->getId()) {
                             $device->setName($name)->setDeviceToken($deviceToken)->setUserId($admin->getId())->setCreatedAt($datetime)->setUpdatedAt($datetime)->save();
                         }
                         $dataObj->setDevice($device);
                         $result['error'] = false;
                         $result['data'] = $dataObj;
                     } catch (Exception $e) {
                         $result['error'] = true;
                         $result['data'] = $e->getMessage();
                     }
                 } else {
                     $result['error'] = true;
                     $result['data'] = 'Could not login admin';
                 }
             } else {
                 $result['error'] = true;
                 $result['data'] = 'No device token, username, password or access token.';
             }
         } else {
             $result['error'] = true;
             $result['data'] = 'No admin login credentials posted.';
         }
     } else {
         $result['error'] = true;
         $result['data'] = 'Request is not over HTTPS.';
     }
     if ($result['error'] === true) {
         $errorMessage = $result['data'];
         Mage::helper('storealerts')->log($errorMessage);
     }
     return $result;
 }
 public function validate(Varien_Object $object)
 {
     if (!$object instanceof Mage_Sales_Model_Quote_Item) {
         return false;
     }
     if ($this->getValue() && stristr($object->getName(), $this->getValue())) {
         return true;
     }
     return false;
 }
Example #5
0
 /**
  * Before save
  *
  * @param Varien_Object $object
  * @return Mage_Catalog_Model_Resource_Product_Attribute_Backend_Urlkey
  */
 public function beforeSave($object)
 {
     $attributeName = $this->getAttribute()->getName();
     $urlKey = $object->getData($attributeName);
     if ($urlKey == '') {
         $urlKey = $object->getName();
     }
     $object->setData($attributeName, $object->formatUrlKey($urlKey));
     return $this;
 }
 public function postAction()
 {
     $post = $this->getRequest()->getPost();
     if ($post) {
         $translate = Mage::getSingleton('core/translate');
         /* @var $translate Mage_Core_Model_Translate */
         $translate->setTranslateInline(false);
         try {
             $postObject = new Varien_Object();
             $postObject->setData($post);
             $error = false;
             if (!Zend_Validate::is(trim($post['name']), 'NotEmpty')) {
                 $error = true;
             }
             if (!Zend_Validate::is(trim($post['comment']), 'NotEmpty')) {
                 $error = true;
             }
             if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
                 $error = true;
             }
             if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
                 $error = true;
             }
             $akismet = Mage::getSingleton('mgt_akismet/akismet');
             if ($akismet->isActive()) {
                 $data = array('name' => $postObject->getName(), 'email' => $postObject->getEmail(), 'comment' => $postObject->getComment());
                 if ($akismet->isSpam($data)) {
                     $error = true;
                 }
             }
             if ($error) {
                 throw new Exception();
             }
             $mailTemplate = Mage::getModel('core/email_template');
             /* @var $mailTemplate Mage_Core_Model_Email_Template */
             $mailTemplate->setDesignConfig(array('area' => 'frontend'))->setReplyTo($post['email'])->sendTransactional(Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE), Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT), null, array('data' => $postObject));
             if (!$mailTemplate->getSentSuccess()) {
                 throw new Exception();
             }
             $translate->setTranslateInline(true);
             Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
             $this->_redirect('*/*/');
             return;
         } catch (Exception $e) {
             $translate->setTranslateInline(true);
             Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
             $this->_redirect('*/*/');
             return;
         }
     } else {
         $this->_redirect('*/*/');
     }
 }
Example #7
0
 /**
  * initialize
  *
  * @access public
  * @author Ultimate Module Creator
  */
 public function __construct()
 {
     $customerSession = Mage::getSingleton('customer/session');
     parent::__construct();
     $data = Mage::getSingleton('customer/session')->getPopupCommentFormData(true);
     $data = new Varien_Object($data);
     // add logged in customer name as nickname
     if (!$data->getName()) {
         $customer = $customerSession->getCustomer();
         if ($customer && $customer->getId()) {
             $data->setName($customer->getFirstname());
             $data->setEmail($customer->getEmail());
         }
     }
     $this->setAllowWriteCommentFlag($customerSession->isLoggedIn() || Mage::getStoreConfigFlag('iou_ultimatepopup/popup/allow_guest_comment'));
     if (!$this->getAllowWriteCommentFlag()) {
         $this->setLoginLink(Mage::getUrl('customer/account/login/', array(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME => Mage::helper('core')->urlEncode(Mage::getUrl('*/*/*', array('_current' => true)) . '#comment-form'))));
     }
     $this->setCommentData($data);
 }
Example #8
0
 public function renderExport(Varien_Object $_item)
 {
     $res = '';
     $prefix = ',';
     $separator = ':';
     $helper = Mage::helper('mageworx_customerplus');
     $res .= $_item->getName();
     $res .= $prefix . $this->helper('mageworx_customerplus')->__('SKU') . $separator . implode($prefix, Mage::helper('catalog')->splitSku($helper->getSku($_item)));
     $_orderOptions = $helper->getOrderOptions($_item);
     if ($_orderOptions) {
         foreach ($_orderOptions as $_option) {
             $res .= $prefix . $_option['label'] . $separator;
             if (isset($_option['custom_view']) && $_option['custom_view']) {
                 $res .= $helper->getCustomizedOptionValue($_option);
             } else {
                 $res .= Mage::helper('core/string')->truncate($_option['value'], 55, '');
             }
         }
     }
     return $res;
 }
Example #9
0
    /**
     * Retrieve quote items in XML format
     *
     * @return string
     */
    protected function _getItemsXml()
    {
        $xml = <<<EOT
        <items>

EOT;
        foreach ($this->getQuote()->getAllItems() as $item) {
            if ($item->getParentItem()) {
                continue;
            }
            $taxClass = $item->getTaxClassId() == 0 ? 'none' : $item->getTaxClassId();
            $weight = (double) $item->getWeight();
            $weightUnit = self::ITEM_WEIGHT_UNIT;
            $unitPrice = $item->getBaseCalculationPrice();
            if (Mage::helper('Mage_Weee_Helper_Data')->includeInSubtotal()) {
                $unitPrice += $item->getBaseWeeeTaxAppliedAmount();
            }
            $xml .= <<<EOT
            <item>
                <merchant-item-id><![CDATA[{$item->getSku()}]]></merchant-item-id>
                <item-name><![CDATA[{$item->getName()}]]></item-name>
                <item-description><![CDATA[{$item->getDescription()}]]></item-description>
                <unit-price currency="{$this->getCurrency()}">{$unitPrice}</unit-price>
                <quantity>{$item->getQty()}</quantity>
                <item-weight unit="{$weightUnit}" value="{$weight}" />
                <tax-table-selector>{$taxClass}</tax-table-selector>
                {$this->_getDigitalContentXml($item->getIsVirtual())}
                {$this->_getMerchantPrivateItemDataXml($item)}
            </item>

EOT;
        }
        $billingAddress = $this->getQuote()->getBillingAddress();
        $shippingAddress = $this->getQuote()->getShippingAddress();
        $shippingDiscount = (double) $shippingAddress->getBaseDiscountAmount();
        $billingDiscount = (double) $billingAddress->getBaseDiscountAmount();
        $discount = $billingDiscount + $shippingDiscount;
        // Exclude shipping discount
        // Discount is negative value
        $discount += $shippingAddress->getBaseShippingDiscountAmount();
        $discountItem = new Varien_Object(array('price' => $discount, 'name' => $this->__('Cart Discount'), 'description' => $this->__('A virtual item to reflect the discount total')));
        Mage::dispatchEvent('google_checkout_discount_item_price', array('quote' => $this->getQuote(), 'discount_item' => $discountItem));
        $discount = $discountItem->getPrice();
        if ($discount) {
            $xml .= <<<EOT
            <item>
                <merchant-item-id>_INTERNAL_DISCOUNT_</merchant-item-id>
                <item-name>{$discountItem->getName()}</item-name>
                <item-description>{$discountItem->getDescription()}</item-description>
                <unit-price currency="{$this->getCurrency()}">{$discount}</unit-price>
                <quantity>1</quantity>
                <item-weight unit="{$weightUnit}" value="0.00" />
                <tax-table-selector>none</tax-table-selector>
                {$this->_getDigitalContentXml($this->getQuote()->isVirtual())}
            </item>

EOT;
        }
        $hiddenTax = $shippingAddress->getBaseHiddenTaxAmount() + $billingAddress->getBaseHiddenTaxAmount();
        if ($hiddenTax) {
            $xml .= <<<EOT
            <item>
                <merchant-item-id>_INTERNAL_TAX_</merchant-item-id>
                <item-name>{$this->__('Discount Tax')}</item-name>
                <item-description>{$this->__('A virtual item to reflect the tax total')}</item-description>
                <unit-price currency="{$this->getCurrency()}">{$hiddenTax}</unit-price>
                <quantity>1</quantity>
                <item-weight unit="{$weightUnit}" value="0.00" />
                <tax-table-selector>none</tax-table-selector>
                {$this->_getDigitalContentXml($this->getQuote()->isVirtual())}
            </item>
EOT;
        }
        $xml .= <<<EOT
        </items>
EOT;
        return $xml;
    }
Example #10
0
 /**
  * Get category name
  *
  * @param Varien_Object $node
  * @return string
  */
 public function buildNodeName($node)
 {
     $result = $this->htmlEscape($node->getName());
     if ($this->_withProductCount) {
         $result .= ' (' . $node->getProductCount() . ')';
     }
     return $result;
 }
Example #11
0
 /**
  * Generate either id path, request path or target path for product and/or category
  *
  * For generating id or system path, either product or category is required
  * For generating request path - category is required
  * $parentPath used only for generating category path
  *
  * @param string $type
  * @param Varien_Object $product
  * @param Varien_Object $category
  * @param string $parentPath
  * @return string
  * @throws Mage_Core_Exception
  */
 public function generatePath($type = 'target', $product = null, $category = null, $parentPath = null)
 {
     if (!$product && !$category) {
         Mage::throwException(Mage::helper('core')->__('Please specify either a category or a product, or both.'));
     }
     // generate id_path
     if ('id' === $type) {
         if (!$product) {
             return 'category/' . $category->getId();
         }
         if ($category && $category->getLevel() > 1) {
             return 'product/' . $product->getId() . '/' . $category->getId();
         }
         return 'product/' . $product->getId();
     }
     // generate request_path
     if ('request' === $type) {
         // for category
         if (!$product) {
             if ($category->getUrlKey() == '') {
                 $urlKey = $this->getCategoryModel()->formatUrlKey($category->getName());
             } else {
                 $urlKey = $this->getCategoryModel()->formatUrlKey($category->getUrlKey());
             }
             $categoryUrlSuffix = $this->getCategoryUrlSuffix($category->getStoreId());
             if (null === $parentPath) {
                 $parentPath = $this->getResource()->getCategoryParentPath($category);
             } elseif ($parentPath == '/') {
                 $parentPath = '';
             }
             $parentPath = Mage::helper('catalog/category')->getCategoryUrlPath($parentPath, true, $category->getStoreId());
             return $this->getUnusedPath($category->getStoreId(), $parentPath . $urlKey . $categoryUrlSuffix, $this->generatePath('id', null, $category));
         }
         // for product & category
         if (!$category) {
             Mage::throwException(Mage::helper('core')->__('A category object is required for determining the product request path.'));
             // why?
         }
         if ($product->getUrlKey() == '') {
             $urlKey = $this->getProductModel()->formatUrlKey($product->getName());
         } else {
             $urlKey = $this->getProductModel()->formatUrlKey($product->getUrlKey());
         }
         $productUrlSuffix = $this->getProductUrlSuffix($category->getStoreId());
         if ($category->getLevel() > 1) {
             // To ensure, that category has url path either from attribute or generated now
             $this->_addCategoryUrlPath($category);
             $categoryUrl = Mage::helper('catalog/category')->getCategoryUrlPath($category->getUrlPath(), false, $category->getStoreId());
             return $this->getUnusedPath($category->getStoreId(), $categoryUrl . '/' . $urlKey . $productUrlSuffix, $this->generatePath('id', $product, $category));
         }
         // for product only
         return $this->getUnusedPath($category->getStoreId(), $urlKey . $productUrlSuffix, $this->generatePath('id', $product));
     }
     // generate target_path
     if (!$product) {
         return 'catalog/category/view/id/' . $category->getId();
     }
     if ($category && $category->getLevel() > 1) {
         return 'catalog/product/view/id/' . $product->getId() . '/category/' . $category->getId();
     }
     return 'catalog/product/view/id/' . $product->getId();
 }
 /**
  * Get unique product request path
  *
  * @param   Varien_Object $product
  * @param   Varien_Object $category
  * @return  string
  */
 public function getProductRequestPath($product, $category)
 {
     if ($product->getUrlKey() == '') {
         $urlKey = $this->getProductModel()->formatUrlKey($product->getName());
     } else {
         $urlKey = $this->getProductModel()->formatUrlKey($product->getUrlKey());
     }
     $storeId = $category->getStoreId();
     $suffix = $this->getProductUrlSuffix($storeId);
     $idPath = $this->generatePath('id', $product, $category);
     /**
      * Prepare product base request path
      */
     if ($category->getLevel() > 1) {
         // To ensure, that category has path either from attribute or generated now
         $this->_addCategoryUrlPath($category);
         $categoryUrl = Mage::helper('catalog/category')->getCategoryUrlPath($category->getUrlPath(), false, $storeId);
         $requestPath = $categoryUrl . '/' . $urlKey;
     } else {
         $requestPath = $urlKey;
     }
     if (strlen($requestPath) > self::MAX_REQUEST_PATH_LENGTH + self::ALLOWED_REQUEST_PATH_OVERFLOW) {
         $requestPath = substr($requestPath, 0, self::MAX_REQUEST_PATH_LENGTH);
     }
     $this->_rewrite = null;
     /**
      * Check $requestPath should be unique
      */
     if (isset($this->_rewrites[$idPath])) {
         $this->_rewrite = $this->_rewrites[$idPath];
         $existingRequestPath = $this->_rewrites[$idPath]->getRequestPath();
         $existingRequestPath = str_replace($suffix, '', $existingRequestPath);
         if ($existingRequestPath == $requestPath) {
             return $requestPath . $suffix;
         }
         /**
          * Check if existing request past can be used
          */
         if (!empty($requestPath) && strpos($existingRequestPath, $requestPath) !== false) {
             $existingRequestPath = str_replace($requestPath, '', $existingRequestPath);
             if (preg_match('#^-([0-9]+)$#i', $existingRequestPath)) {
                 return $this->_rewrites[$idPath]->getRequestPath();
             }
         }
         /**
          * check if current generated request path is one of the old paths
          */
         $fullPath = $requestPath . $suffix;
         $finalOldTargetPath = $this->getResource()->findFinalTargetPath($fullPath, $storeId);
         if ($finalOldTargetPath && $finalOldTargetPath == $idPath) {
             $this->getResource()->deleteRewrite($fullPath, $storeId);
             return $fullPath;
         }
     }
     /**
      * Check 2 variants: $requestPath and $requestPath . '-' . $productId
      */
     $validatedPath = $this->getResource()->checkRequestPaths(array($requestPath . $suffix, $requestPath . '-' . $product->getId() . $suffix), $storeId);
     if ($validatedPath) {
         return $validatedPath;
     }
     /**
      * Use unique path generator
      */
     return $this->getUnusedPath($storeId, $requestPath . $suffix, $idPath);
 }
Example #13
0
 /**
  * Test if message matches criterion
  *
  * @param Varien_Object $criterion Matching criterion
  * @return boolean
  */
 public function matchesCriterion(Varien_Object $criterion)
 {
     $meta = $this->getMeta();
     $name = isset($meta['name']) ? $meta['name'] : null;
     return $criterion->getName() && $criterion->getName() == $name;
 }
Example #14
0
 /**
  * Add a usual line item with amount and qty
  *
  * @param Varien_Object $salesItem
  * @return Varien_Object
  */
 protected function _addRegularItem(Varien_Object $salesItem)
 {
     if ($this->_salesEntity instanceof Mage_Sales_Model_Order) {
         $qty = (int) $salesItem->getQtyOrdered();
         $amount = (double) $salesItem->getBasePrice();
         // TODO: nominal item for order
     } else {
         $qty = (int) $salesItem->getTotalQty();
         $amount = $salesItem->isNominal() ? 0 : (double) $salesItem->getBaseCalculationPrice();
     }
     // workaround in case if item subtotal precision is not compatible with PayPal (.2)
     $subAggregatedLabel = '';
     if ($amount - round($amount, 2)) {
         $amount = $amount * $qty;
         $subAggregatedLabel = ' x' . $qty;
         $qty = 1;
     }
     // aggregate item price if item qty * price does not match row total
     if ($amount * $qty != $salesItem->getBaseRowTotal()) {
         $amount = (double) $salesItem->getBaseRowTotal();
         $subAggregatedLabel = ' x' . $qty;
         $qty = 1;
     }
     return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getSku());
 }
Example #15
0
 public function sendAction()
 {
     // todo check validity;
     $template = new Varien_Object();
     $template->setData($this->getRequest()->getParams());
     $customersIds = $this->getRequest()->getParam('customers');
     $ordersIds = $this->getRequest()->getParam('orders');
     if ($customersIds) {
         $collection = Mage::getResourceModel('customer/customer_collection')->addNameToSelect()->addAttributeToSelect('email')->addFieldToFilter('entity_id', array('in' => explode(',', $customersIds)));
         $cnt = 0;
         foreach ($collection as $customer) {
             $vars = array('customer' => $customer, 'store' => Mage::app()->getStore($customer->getStoreId()), 'order' => new Varien_Object());
             $res = $this->send($customer->getEmail(), $customer->getName(), $template, $vars);
             if (true === $res) {
                 $cnt++;
             } else {
                 Mage::getSingleton('adminhtml/session')->addError($res);
             }
         }
         //foreach
         Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('amemail')->__('%s email(s) have been sent.', $cnt));
         // show customer page if we have only one order
         if (1 == count($customersIds)) {
             return $this->_redirect('customer/edit', array('id' => $customersIds[0]));
         }
         return $this->_redirect('customer/index');
     } elseif ($ordersIds) {
         $collection = Mage::getResourceModel('sales/order_collection')->addFieldToFilter('entity_id', array('in' => explode(',', $ordersIds)));
         if (version_compare(Mage::getVersion(), '1.6.2') < 0) {
             $collection = Mage::getResourceModel('sales/order_collection')->addAttributeToSelect('*')->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left');
         }
         $cnt = 0;
         foreach ($collection as $order) {
             $customer = new Varien_Object();
             if ($order->getCustomerFirstname() || $order->getCustomerLastname()) {
                 $customer->setName($order->getCustomerFirstname() . ' ' . $order->getCustomerLastname());
             } else {
                 $customer->setName($order->getShippingFirstname() . ' ' . $order->getShippingLastname());
             }
             $customer->setId($order->getCustomerId());
             $vars = array('order' => $order, 'customer' => $customer, 'store' => Mage::app()->getStore($order->getStoreId()));
             $res = $this->send($order->getCustomerEmail(), $customer->getName(), $template, $vars);
             if (true === $res) {
                 $cnt++;
             } else {
                 Mage::getSingleton('adminhtml/session')->addError($res);
             }
         }
         //foreach
         Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('amemail')->__('%s email(s) have been sent.', $cnt));
         // show order page if we have only one order
         if (1 == count($ordersIds)) {
             return $this->_redirect('sales_order/view', array('order_id' => $ordersIds[0]));
         }
         return $this->_redirect('sales_order/index');
     }
     // no ids
     return $this->_redirect('dashboard/index');
 }
Example #16
0
 /**
  * Generate either id path, request path or target path for product review
  *
  * @param string $type
  * @param Varien_Object $product
  * @return string
  * @throws Mage_Core_Exception
  */
 public function generateSinglePath($type = 'target', $review, $product)
 {
     // generate id_path
     if ('id' === $type) {
         return 'review/' . $review->getId();
     }
     // generate request_path
     if ('request' === $type) {
         if ($product->getUrlKey() == '') {
             $pUrlKey = $this->getProductModel()->formatUrlKey($product->getName());
         } else {
             $pUrlKey = $this->getProductModel()->formatUrlKey($product->getUrlKey());
         }
         $urlKey = $this->getProductModel()->formatUrlKey($review->getTitle());
         if (!$urlKey) {
             $urlKey = 'review';
         }
         $productUrlSuffix = $this->getProductUrlSuffix($review->getStoreId());
         return $this->getUnusedPath($review->getStoreId(), 'reviews/' . $pUrlKey . '/' . $urlKey . $productUrlSuffix, $this->generateSinglePath('id', $review, $product));
     }
     return 'review/product/view/id/' . $review->getId();
 }
 /**
  * charge money for recurring item
  */
 protected function _checkoutRecurring()
 {
     /** @var Mage_Sales_Model_Order $order */
     $order = Mage::getModel('sales/order');
     $item = new Varien_Object($this->_recurringProfile->getOrderItemInfo());
     $this->_price = $item->getBasePrice() * $item->getQty();
     $additionalInfo = $this->_recurringProfile->getAdditionalInfo();
     // check isset TrialBilling
     // Trial Billing Frequency <= 0 or isn't numeric => failure
     if ($this->_recurringProfile->getTrialBillingAmount() && $this->_recurringProfile->getTrialPeriodFrequency() && $this->_recurringProfile->getTrialPeriodMaxCycles() && $this->_recurringProfile->getTrialPeriodUnit() && (string) (int) $this->_recurringProfile->getTrialPeriodFrequency() === ltrim($this->_recurringProfile->getTrialPeriodFrequency(), '0') && (int) $this->_recurringProfile->getTrialPeriodFrequency() > 0) {
         $trialPeriodMaxCycles = (int) $this->_recurringProfile->getTrialPeriodMaxCycles();
         if (!isset($additionalInfo['trialPeriodMaxCycles'])) {
             $additionalInfo['trialPeriodMaxCycles'] = $trialPeriodMaxCycles;
             $this->_recurringProfile->setAdditionalInfo($additionalInfo);
             $this->_price = $this->_recurringProfile->getTrialBillingAmount();
             $this->_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
         } elseif (isset($additionalInfo['trialPeriodMaxCycles']) && $additionalInfo['trialPeriodMaxCycles'] > 0) {
             $this->_price = $this->_recurringProfile->getTrialBillingAmount();
             $this->_periodType = Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL;
         }
     }
     // calculate total amount
     $this->_shippingAmount = $item->getBaseShippingAmount();
     $this->_taxAmount = $item->getBaseTaxAmount();
     $this->_amount = $this->_price + $this->_shippingAmount + $this->_taxAmount;
     // init order
     /** @var Mage_Sales_Model_Order_Item $orderItem */
     $orderItem = Mage::getModel('sales/order_item')->setName($item->getName())->setSku($item->getSku())->setDescription($item->getDescription())->setQtyOrdered($item->getQty())->setBasePrice($item->getBasePrice())->setBaseTaxAmount($item->getBaseTaxAmount())->setBaseRowTotalInclTax($item->getBaseRowTotalInclTax());
     $order->addItem($orderItem);
     $shippingInfo = $this->_recurringProfile->getShippingAddressInfo();
     $shippingAddress = Mage::getModel('sales/order_address')->setData($shippingInfo)->setId(null);
     // get base currency code
     $orderInfo = new Varien_Object($this->_recurringProfile->getOrderInfo());
     $currencyCode = $orderInfo->getBaseCurrencyCode();
     $order->setShippingAddress($shippingAddress);
     $order->setBaseCurrencyCode($currencyCode);
     /** @var Mage_Sales_Model_Order_Payment $payment */
     $payment = Mage::getModel('sales/order_payment');
     $payment->setOrder($order);
     $payment->setIsRecurring(true);
     $payment->setIsInitialFee(true);
     $customerId = $this->_recurringProfile->getCustomerId();
     $payment->setCustomerId($customerId);
     $tokenId = $additionalInfo['token']['saved_token'];
     $payment->setTokenId($tokenId);
     /** @var Eway_Rapid31_Model_Method_Saved $ewaySave */
     $ewaySave = Mage::getModel('ewayrapid/method_saved');
     $paymentAction = Mage::getStoreConfig('payment/ewayrapid_general/payment_action');
     if ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
         $ewaySave->authorize($payment, $this->_amount);
     } elseif ($paymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
         $ewaySave->capture($payment, $this->_amount);
     }
     if (!$payment->getTransactionId()) {
         throw new Exception('Transaction is not available');
     } else {
         $this->_txdId = $payment->getTransactionId();
     }
     /** @todo: change status of order = "eWAY Authorised"
      *         now status order = "processing"
      */
 }
 public function releaseAction()
 {
     #Varien_Pear::getInstance()->runHtmlConsole(array('command'=>'list-channels'));
     if (empty($_POST)) {
         $serFiles = @glob(Mage::getBaseDir('var') . DS . 'pear' . DS . '*.ser');
         if (!$serFiles) {
             return;
         }
         $pkg = new Varien_Object();
         echo '<html><head><style type="text/css">* { font:normal 12px Arial }</style></head>
         <body><form method="post"><table border="1" cellpadding="3" cellspacing="0"><thead>
                 <tr><th>Update/Package</th><th>Version</th><th>State</th></tr>
             </thead><tbody>';
         foreach ($serFiles as $i => $file) {
             $serialized = file_get_contents($file);
             $pkg->setData(unserialize($serialized));
             $n = $pkg->getName();
             echo '<tr><td><input type="checkbox" name="pkgs[' . $i . '][name]" id="pkg_' . $i . '" value="' . $n . '"/>
                     <label for="pkg_' . $i . '">' . $n . '</label>
                     <input type="hidden" name="pkgs[' . $i . '][file]" value="' . $file . '"/>
                 </td>
                 <td><input name="pkgs[' . $i . '][release_version]" value="' . $pkg->getData('release_version') . '"/></td>
                 <td><input name="pkgs[' . $i . '][release_stability]" value="' . $pkg->getData('release_stability') . '"/></td>
             </tr>';
             #echo "<pre>"; print_r($pkg->getData()); echo "</pre>"; exit;
         }
         echo '</tbody></table><button type="submit">Save and Generate Packages</button></form></body></html>';
     } else {
         @set_time_limit(0);
         ob_implicit_flush();
         foreach ($_POST['pkgs'] as $r) {
             if (empty($r['name'])) {
                 continue;
             }
             echo "<hr/><h4>" . $r['name'] . "</h4>";
             $ext = Mage::getModel('adminhtml/extension');
             $ext->setData(unserialize(file_get_contents($r['file'])));
             $ext->setData('release_version', $r['release_version']);
             $ext->setData('release_stability', $r['release_stability']);
             #echo "<pre>"; print_r($ext->getData()); echo "</pre>";
             $result = $ext->savePackage();
             if (!$result) {
                 echo "ERROR while creating the package";
                 continue;
             } else {
                 echo "Package created; ";
             }
             $result = $ext->createPackage();
             $pear = Varien_Pear::getInstance();
             if ($result) {
                 $data = $pear->getOutput();
                 print_r($data[0]['output']);
             } else {
                 echo "ERROR:";
                 print_r($result->getMessage());
             }
         }
         echo '<hr/><a href="' . $_SERVER['REQUEST_URI'] . '">Refresh</a>';
     }
     exit;
 }
Example #19
0
 /**
  * Form XML for shipment request
  *
  * @param Varien_Object $request
  * @return string
  */
 protected function _formShipmentRequest(Varien_Object $request)
 {
     $packageParams = $request->getPackageParams();
     $height = $packageParams->getHeight();
     $width = $packageParams->getWidth();
     $length = $packageParams->getLength();
     $weightUnits = $packageParams->getWeightUnits() == Zend_Measure_Weight::POUND ? 'LBS' : 'KGS';
     $dimensionsUnits = $packageParams->getDimensionUnits() == Zend_Measure_Length::INCH ? 'IN' : 'CM';
     $itemsDesc = array();
     $itemsShipment = $request->getPackageItems();
     foreach ($itemsShipment as $itemShipment) {
         $item = new Varien_Object();
         $item->setData($itemShipment);
         $itemsDesc[] = $item->getName();
     }
     $xmlRequest = new SimpleXMLElement('<?xml version = "1.0" ?><ShipmentConfirmRequest xml:lang="en-US"/>');
     $requestPart = $xmlRequest->addChild('Request');
     $requestPart->addChild('RequestAction', 'ShipConfirm');
     $requestPart->addChild('RequestOption', 'nonvalidate');
     $shipmentPart = $xmlRequest->addChild('Shipment');
     if ($request->getIsReturn()) {
         $returnPart = $shipmentPart->addChild('ReturnService');
         // UPS Print Return Label
         $returnPart->addChild('Code', '9');
     }
     $shipmentPart->addChild('Description', substr(implode(' ', $itemsDesc), 0, 35));
     //empirical
     $shipperPart = $shipmentPart->addChild('Shipper');
     if ($request->getIsReturn()) {
         $shipperPart->addChild('Name', $request->getRecipientContactCompanyName());
         $shipperPart->addChild('AttentionName', $request->getRecipientContactPersonName());
         $shipperPart->addChild('ShipperNumber', $this->getConfigData('shipper_number'));
         $shipperPart->addChild('PhoneNumber', $request->getRecipientContactPhoneNumber());
         $addressPart = $shipperPart->addChild('Address');
         $addressPart->addChild('AddressLine1', $request->getRecipientAddressStreet());
         $addressPart->addChild('AddressLine2', $request->getRecipientAddressStreet2());
         $addressPart->addChild('City', $request->getRecipientAddressCity());
         $addressPart->addChild('CountryCode', $request->getRecipientAddressCountryCode());
         $addressPart->addChild('PostalCode', $request->getRecipientAddressPostalCode());
         if ($request->getRecipientAddressStateOrProvinceCode()) {
             $addressPart->addChild('StateProvinceCode', $request->getRecipientAddressStateOrProvinceCode());
         }
     } else {
         $shipperPart->addChild('Name', $request->getShipperContactCompanyName());
         $shipperPart->addChild('AttentionName', $request->getShipperContactPersonName());
         $shipperPart->addChild('ShipperNumber', $this->getConfigData('shipper_number'));
         $shipperPart->addChild('PhoneNumber', $request->getShipperContactPhoneNumber());
         $addressPart = $shipperPart->addChild('Address');
         $addressPart->addChild('AddressLine1', $request->getShipperAddressStreet());
         $addressPart->addChild('AddressLine2', $request->getShipperAddressStreet2());
         $addressPart->addChild('City', $request->getShipperAddressCity());
         $addressPart->addChild('CountryCode', $request->getShipperAddressCountryCode());
         $addressPart->addChild('PostalCode', $request->getShipperAddressPostalCode());
         if ($request->getShipperAddressStateOrProvinceCode()) {
             $addressPart->addChild('StateProvinceCode', $request->getShipperAddressStateOrProvinceCode());
         }
     }
     $shipToPart = $shipmentPart->addChild('ShipTo');
     $shipToPart->addChild('AttentionName', $request->getRecipientContactPersonName());
     $shipToPart->addChild('CompanyName', $request->getRecipientContactCompanyName() ? $request->getRecipientContactCompanyName() : 'N/A');
     $shipToPart->addChild('PhoneNumber', $request->getRecipientContactPhoneNumber());
     $addressPart = $shipToPart->addChild('Address');
     $addressPart->addChild('AddressLine1', $request->getRecipientAddressStreet1());
     $addressPart->addChild('AddressLine2', $request->getRecipientAddressStreet2());
     $addressPart->addChild('City', $request->getRecipientAddressCity());
     $addressPart->addChild('CountryCode', $request->getRecipientAddressCountryCode());
     $addressPart->addChild('PostalCode', $request->getRecipientAddressPostalCode());
     if ($request->getRecipientAddressStateOrProvinceCode()) {
         $addressPart->addChild('StateProvinceCode', $request->getRecipientAddressRegionCode());
     }
     if ($this->getConfigData('dest_type') == 'RES') {
         $addressPart->addChild('ResidentialAddress');
     }
     if ($request->getIsReturn()) {
         $shipFromPart = $shipmentPart->addChild('ShipFrom');
         $shipFromPart->addChild('AttentionName', $request->getShipperContactPersonName());
         $shipFromPart->addChild('CompanyName', $request->getShipperContactCompanyName() ? $request->getShipperContactCompanyName() : $request->getShipperContactPersonName());
         $shipFromAddress = $shipFromPart->addChild('Address');
         $shipFromAddress->addChild('AddressLine1', $request->getShipperAddressStreet1());
         $shipFromAddress->addChild('AddressLine2', $request->getShipperAddressStreet2());
         $shipFromAddress->addChild('City', $request->getShipperAddressCity());
         $shipFromAddress->addChild('CountryCode', $request->getShipperAddressCountryCode());
         $shipFromAddress->addChild('PostalCode', $request->getShipperAddressPostalCode());
         if ($request->getShipperAddressStateOrProvinceCode()) {
             $shipFromAddress->addChild('StateProvinceCode', $request->getShipperAddressStateOrProvinceCode());
         }
         $addressPart = $shipToPart->addChild('Address');
         $addressPart->addChild('AddressLine1', $request->getShipperAddressStreet1());
         $addressPart->addChild('AddressLine2', $request->getShipperAddressStreet2());
         $addressPart->addChild('City', $request->getShipperAddressCity());
         $addressPart->addChild('CountryCode', $request->getShipperAddressCountryCode());
         $addressPart->addChild('PostalCode', $request->getShipperAddressPostalCode());
         if ($request->getShipperAddressStateOrProvinceCode()) {
             $addressPart->addChild('StateProvinceCode', $request->getShipperAddressStateOrProvinceCode());
         }
         if ($this->getConfigData('dest_type') == 'RES') {
             $addressPart->addChild('ResidentialAddress');
         }
     }
     $servicePart = $shipmentPart->addChild('Service');
     $servicePart->addChild('Code', $request->getShippingMethod());
     $packagePart = $shipmentPart->addChild('Package');
     $packagePart->addChild('Description', substr(implode(' ', $itemsDesc), 0, 35));
     //empirical
     $packagePart->addChild('PackagingType')->addChild('Code', $request->getPackagingType());
     $packageWeight = $packagePart->addChild('PackageWeight');
     $packageWeight->addChild('Weight', $request->getPackageWeight());
     $packageWeight->addChild('UnitOfMeasurement')->addChild('Code', $weightUnits);
     // set dimensions
     if ($length || $width || $height) {
         $packageDimensions = $packagePart->addChild('Dimensions');
         $packageDimensions->addChild('UnitOfMeasurement')->addChild('Code', $dimensionsUnits);
         $packageDimensions->addChild('Length', $length);
         $packageDimensions->addChild('Width', $width);
         $packageDimensions->addChild('Height', $height);
     }
     // ups support reference number only for domestic service
     if ($this->_isUSCountry($request->getRecipientAddressCountryCode()) && $this->_isUSCountry($request->getShipperAddressCountryCode())) {
         if ($request->getReferenceData()) {
             $referenceData = $request->getReferenceData() . $request->getPackageId();
         } else {
             $referenceData = 'Order #' . $request->getOrderShipment()->getOrder()->getIncrementId() . ' P' . $request->getPackageId();
         }
         $referencePart = $packagePart->addChild('ReferenceNumber');
         $referencePart->addChild('Code', '02');
         $referencePart->addChild('Value', $referenceData);
     }
     $deliveryConfirmation = $packageParams->getDeliveryConfirmation();
     if ($deliveryConfirmation) {
         /** @var $serviceOptionsNode SimpleXMLElement */
         $serviceOptionsNode = null;
         switch ($this->_getDeliveryConfirmationLevel($request->getRecipientAddressCountryCode())) {
             case self::DELIVERY_CONFIRMATION_PACKAGE:
                 $serviceOptionsNode = $packagePart->addChild('PackageServiceOptions');
                 break;
             case self::DELIVERY_CONFIRMATION_SHIPMENT:
                 $serviceOptionsNode = $shipmentPart->addChild('ShipmentServiceOptions');
                 break;
         }
         if (!is_null($serviceOptionsNode)) {
             $serviceOptionsNode->addChild('DeliveryConfirmation')->addChild('DCISType', $packageParams->getDeliveryConfirmation());
         }
     }
     $shipmentPart->addChild('PaymentInformation')->addChild('Prepaid')->addChild('BillShipper')->addChild('AccountNumber', $this->getConfigData('shipper_number'));
     if ($request->getPackagingType() != $this->getCode('container', 'ULE') && $request->getShipperAddressCountryCode() == Mage_Usa_Model_Shipping_Carrier_Abstract::USA_COUNTRY_ID && ($request->getRecipientAddressCountryCode() == 'CA' || $request->getRecipientAddressCountryCode() == 'PR')) {
         $invoiceLineTotalPart = $shipmentPart->addChild('InvoiceLineTotal');
         $invoiceLineTotalPart->addChild('CurrencyCode', $request->getBaseCurrencyCode());
         $invoiceLineTotalPart->addChild('MonetaryValue', ceil($packageParams->getCustomsValue()));
     }
     $labelPart = $xmlRequest->addChild('LabelSpecification');
     $labelPart->addChild('LabelPrintMethod')->addChild('Code', 'GIF');
     $labelPart->addChild('LabelImageFormat')->addChild('Code', 'GIF');
     $this->setXMLAccessRequest();
     $xmlRequest = $this->_xmlAccessRequest . $xmlRequest->asXml();
     return $xmlRequest;
 }
Example #20
0
 /**
  * Prepare and do request to shipment
  *
  * @param Mage_Sales_Model_Order_Shipment $orderShipment
  * @return Varien_Object
  */
 public function requestToShipment(Mage_Sales_Model_Order_Shipment $orderShipment)
 {
     $admin = Mage::getSingleton('admin/session')->getUser();
     $order = $orderShipment->getOrder();
     $address = $order->getShippingAddress();
     $selectedShipMethod = $this->_mapShipMethod($order->getShippingMethod(true), $order->getShippingCarrier(), $address);
     $shipmentStoreId = $orderShipment->getStoreId();
     $shipmentCarrier = Mage::getModel('wsaendicia/carrier_endicia');
     $shippingMethod = $this->_getShipmentCarrier($selectedShipMethod, $shipmentCarrier->getCarrierCode());
     $baseCurrencyCode = Mage::app()->getStore($shipmentStoreId)->getBaseCurrencyCode();
     if (!$shipmentCarrier) {
         Mage::throwException('Invalid carrier: ' . $shippingMethod->getCarrierCode());
     }
     $shipperRegionCode = Mage::getStoreConfig(self::XML_PATH_STORE_REGION_ID, $shipmentStoreId);
     if (is_numeric($shipperRegionCode)) {
         $shipperRegionCode = Mage::getModel('directory/region')->load($shipperRegionCode)->getCode();
     }
     $recipientRegionCode = Mage::getModel('directory/region')->load($address->getRegionId())->getCode();
     $originStreet1 = Mage::getStoreConfig(self::XML_PATH_STORE_ADDRESS1, $shipmentStoreId);
     $originStreet2 = Mage::getStoreConfig(self::XML_PATH_STORE_ADDRESS2, $shipmentStoreId);
     $storeInfo = new Varien_Object(Mage::getStoreConfig('general/store_information', $shipmentStoreId));
     if (!$admin->getFirstname() || !$admin->getLastname() || !$storeInfo->getName() || !$storeInfo->getPhone() || !$originStreet1 || !Mage::getStoreConfig(self::XML_PATH_STORE_CITY, $shipmentStoreId) || !$shipperRegionCode || !Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $shipmentStoreId) || !Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $shipmentStoreId)) {
         Mage::throwException(Mage::helper('sales')->__('Insufficient information to create shipping label(s). Please verify your Store Information and Shipping Settings.'));
     }
     /** @var $request Mage_Shipping_Model_Shipment_Request */
     $request = Mage::getModel('shipping/shipment_request');
     $request->setOrderShipment($orderShipment);
     $request->setShipperContactPersonName($admin->getName());
     $request->setShipperContactPersonFirstName($admin->getFirstname());
     $request->setShipperContactPersonLastName($admin->getLastname());
     $request->setShipperContactCompanyName($storeInfo->getName());
     $request->setShipperContactPhoneNumber($storeInfo->getPhone());
     $request->setShipperEmail($admin->getEmail());
     $request->setShipperAddressStreet(trim($originStreet1 . ' ' . $originStreet2));
     $request->setShipperAddressStreet1($originStreet1);
     $request->setShipperAddressStreet2($originStreet2);
     $request->setShipperAddressCity(Mage::getStoreConfig(self::XML_PATH_STORE_CITY, $shipmentStoreId));
     $request->setShipperAddressStateOrProvinceCode($shipperRegionCode);
     $request->setShipperAddressPostalCode(Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $shipmentStoreId));
     $request->setShipperAddressCountryCode(Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $shipmentStoreId));
     $request->setRecipientContactPersonName(trim($address->getFirstname() . ' ' . $address->getLastname()));
     $request->setRecipientContactPersonFirstName($address->getFirstname());
     $request->setRecipientContactPersonLastName($address->getLastname());
     $request->setRecipientContactCompanyName($address->getCompany());
     $request->setRecipientContactPhoneNumber($address->getTelephone());
     $request->setRecipientEmail($address->getEmail());
     $request->setRecipientAddressStreet(trim($address->getStreet1() . ' ' . $address->getStreet2()));
     $request->setRecipientAddressStreet1($address->getStreet1());
     $request->setRecipientAddressStreet2($address->getStreet2());
     $request->setRecipientAddressCity($address->getCity());
     $request->setRecipientAddressStateOrProvinceCode($address->getRegionCode());
     $request->setRecipientAddressRegionCode($recipientRegionCode);
     $request->setRecipientAddressPostalCode($address->getPostcode());
     $request->setRecipientAddressCountryCode($address->getCountryId());
     $request->setShippingMethod($shippingMethod->getMethod());
     $request->setPackageWeight($order->getWeight());
     $request->setPackages($orderShipment->getPackages());
     $request->setBaseCurrencyCode($baseCurrencyCode);
     $request->setStoreId($shipmentStoreId);
     return $shipmentCarrier->requestToShipment($request);
 }
Example #21
0
 /**
  * Draw packages block
  *
  * @param  Zend_Pdf_Page $page
  * @return Mage_Sales_Model_Order_Pdf_Shipment_Packaging
  */
 protected function _drawPackageBlock(Zend_Pdf_Page $page)
 {
     if ($this->getPackageShippingBlock()) {
         $packaging = $this->getPackageShippingBlock();
     } else {
         $packaging = Mage::getBlockSingleton('adminhtml/sales_order_shipment_packaging');
     }
     $packages = $packaging->getPackages();
     $packageNum = 1;
     foreach ($packages as $packageId => $package) {
         $page->setFillColor(new Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92));
         $page->drawRectangle(25, $this->y + 15, 190, $this->y - 35);
         $page->drawRectangle(190, $this->y + 15, 350, $this->y - 35);
         $page->drawRectangle(350, $this->y + 15, 570, $this->y - 35);
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
         $page->drawRectangle(520, $this->y + 15, 570, $this->y - 5);
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
         $packageText = Mage::helper('sales')->__('Package') . ' ' . $packageNum;
         $page->drawText($packageText, 525, $this->y, 'UTF-8');
         $packageNum++;
         $package = new Varien_Object($package);
         $params = new Varien_Object($package->getParams());
         $dimensionUnits = Mage::helper('usa')->getMeasureDimensionName($params->getDimensionUnits());
         $typeText = Mage::helper('sales')->__('Type') . ' : ' . $packaging->getContainerTypeByCode($params->getContainer());
         $page->drawText($typeText, 35, $this->y, 'UTF-8');
         if ($params->getLength() != null) {
             $lengthText = $params->getLength() . ' ' . $dimensionUnits;
         } else {
             $lengthText = '--';
         }
         $lengthText = Mage::helper('sales')->__('Length') . ' : ' . $lengthText;
         $page->drawText($lengthText, 200, $this->y, 'UTF-8');
         if ($params->getDeliveryConfirmation() != null) {
             $confirmationText = Mage::helper('sales')->__('Signature Confirmation') . ' : ' . $packaging->getDeliveryConfirmationTypeByCode($params->getDeliveryConfirmation());
             $page->drawText($confirmationText, 355, $this->y, 'UTF-8');
         }
         $this->y = $this->y - 10;
         if ($packaging->displayCustomsValue() != null) {
             $customsValueText = Mage::helper('sales')->__('Customs Value') . ' : ' . $packaging->displayPrice($params->getCustomsValue());
             $page->drawText($customsValueText, 35, $this->y, 'UTF-8');
         }
         if ($params->getWidth() != null) {
             $widthText = $params->getWidth() . ' ' . $dimensionUnits;
         } else {
             $widthText = '--';
         }
         $widthText = Mage::helper('sales')->__('Width') . ' : ' . $widthText;
         $page->drawText($widthText, 200, $this->y, 'UTF-8');
         if ($params->getContentType() != null) {
             if ($params->getContentType() == 'OTHER') {
                 $contentsValue = $params->getContentTypeOther();
             } else {
                 $contentsValue = $packaging->getContentTypeByCode($params->getContentType());
             }
             $contentsText = Mage::helper('sales')->__('Contents') . ' : ' . $contentsValue;
             $page->drawText($contentsText, 355, $this->y, 'UTF-8');
         }
         $this->y = $this->y - 10;
         $weightText = Mage::helper('sales')->__('Total Weight') . ' : ' . $params->getWeight() . ' ' . Mage::helper('usa')->getMeasureWeightName($params->getWeightUnits());
         $page->drawText($weightText, 35, $this->y, 'UTF-8');
         if ($params->getHeight() != null) {
             $heightText = $params->getHeight() . ' ' . $dimensionUnits;
         } else {
             $heightText = '--';
         }
         $heightText = Mage::helper('sales')->__('Height') . ' : ' . $heightText;
         $page->drawText($heightText, 200, $this->y, 'UTF-8');
         $this->y = $this->y - 10;
         if ($params->getSize()) {
             $sizeText = Mage::helper('sales')->__('Size') . ' : ' . ucfirst(strtolower($params->getSize()));
             $page->drawText($sizeText, 35, $this->y, 'UTF-8');
         }
         if ($params->getGirth() != null) {
             $dimensionGirthUnits = Mage::helper('usa')->getMeasureDimensionName($params->getGirthDimensionUnits());
             $girthText = Mage::helper('sales')->__('Girth') . ' : ' . $params->getGirth() . ' ' . $dimensionGirthUnits;
             $page->drawText($girthText, 200, $this->y, 'UTF-8');
         }
         $this->y = $this->y - 5;
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
         $page->drawRectangle(25, $this->y, 570, $this->y - 30 - count($package->getItems()) * 12);
         $this->y = $this->y - 10;
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
         $page->drawText(Mage::helper('sales')->__('Items in the Package'), 30, $this->y, 'UTF-8');
         $txtIndent = 5;
         $itemCollsNumber = $packaging->displayCustomsValue() ? 5 : 4;
         $itemCollsX[0] = 30;
         //  coordinate for Product name
         $itemCollsX[1] = 250;
         // coordinate for Product name
         $itemCollsXEnd = 565;
         $itemCollsXStep = round(($itemCollsXEnd - $itemCollsX[1]) / ($itemCollsNumber - 1));
         // calculate coordinates for all other cells (Weight, Customs Value, Qty Ordered, Qty)
         for ($i = 2; $i <= $itemCollsNumber; $i++) {
             $itemCollsX[$i] = $itemCollsX[$i - 1] + $itemCollsXStep;
         }
         $i = 0;
         $page->setFillColor(new Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92));
         $page->drawRectangle($itemCollsX[$i], $this->y - 5, $itemCollsX[++$i], $this->y - 15);
         $page->drawRectangle($itemCollsX[$i], $this->y - 5, $itemCollsX[++$i], $this->y - 15);
         $page->drawRectangle($itemCollsX[$i], $this->y - 5, $itemCollsX[++$i], $this->y - 15);
         $page->drawRectangle($itemCollsX[$i], $this->y - 5, $itemCollsX[++$i], $this->y - 15);
         $page->drawRectangle($itemCollsX[$i], $this->y - 5, $itemCollsXEnd, $this->y - 15);
         $this->y = $this->y - 12;
         $i = 0;
         $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
         $page->drawText(Mage::helper('sales')->__('Product'), $itemCollsX[$i] + $txtIndent, $this->y, 'UTF-8');
         $page->drawText(Mage::helper('sales')->__('Weight'), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
         if ($packaging->displayCustomsValue()) {
             $page->drawText(Mage::helper('sales')->__('Customs Value'), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
         }
         $page->drawText(Mage::helper('sales')->__('Qty Ordered'), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
         $page->drawText(Mage::helper('sales')->__('Qty'), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
         $i = 0;
         foreach ($package->getItems() as $itemId => $item) {
             $item = new Varien_Object($item);
             $i = 0;
             $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
             $page->drawRectangle($itemCollsX[$i], $this->y - 3, $itemCollsX[++$i], $this->y - 15);
             $page->drawRectangle($itemCollsX[$i], $this->y - 3, $itemCollsX[++$i], $this->y - 15);
             $page->drawRectangle($itemCollsX[$i], $this->y - 3, $itemCollsX[++$i], $this->y - 15);
             $page->drawRectangle($itemCollsX[$i], $this->y - 3, $itemCollsX[++$i], $this->y - 15);
             $page->drawRectangle($itemCollsX[$i], $this->y - 3, $itemCollsXEnd, $this->y - 15);
             $this->y = $this->y - 12;
             $i = 0;
             $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
             $page->drawText($item->getName(), $itemCollsX[$i] + $txtIndent, $this->y, 'UTF-8');
             $page->drawText($item->getWeight(), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
             if ($packaging->displayCustomsValue()) {
                 $page->drawText($packaging->displayPrice($item->getCustomsValue()), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
             }
             $page->drawText($packaging->getQtyOrderedItem($item->getOrderItemId()), $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
             $page->drawText($item->getQty() * 1, $itemCollsX[++$i] + $txtIndent, $this->y, 'UTF-8');
         }
         $this->y = $this->y - 30;
     }
     return $this;
 }
Example #22
0
 /**
  * Form XML for international shipment request
  * As integration guide it is important to follow appropriate sequence for tags e.g.: <FromLastName /> must be
  * after <FromFirstName />
  *
  * @param Varien_Object $request
  * @return string
  */
 protected function _formIntlShipmentRequest(Varien_Object $request)
 {
     $packageParams = $request->getPackageParams();
     $height = $packageParams->getHeight();
     $width = $packageParams->getWidth();
     $length = $packageParams->getLength();
     $girth = $packageParams->getGirth();
     $packageWeight = $request->getPackageWeight();
     if ($packageParams->getWeightUnits() != Zend_Measure_Weight::POUND) {
         $packageWeight = Mage::helper('usa')->convertMeasureWeight($request->getPackageWeight(), $packageParams->getWeightUnits(), Zend_Measure_Weight::POUND);
     }
     if ($packageParams->getDimensionUnits() != Zend_Measure_Length::INCH) {
         $length = round(Mage::helper('usa')->convertMeasureDimension($packageParams->getLength(), $packageParams->getDimensionUnits(), Zend_Measure_Length::INCH));
         $width = round(Mage::helper('usa')->convertMeasureDimension($packageParams->getWidth(), $packageParams->getDimensionUnits(), Zend_Measure_Length::INCH));
         $height = round(Mage::helper('usa')->convertMeasureDimension($packageParams->getHeight(), $packageParams->getDimensionUnits(), Zend_Measure_Length::INCH));
     }
     if ($packageParams->getGirthDimensionUnits() != Zend_Measure_Length::INCH) {
         $girth = round(Mage::helper('usa')->convertMeasureDimension($packageParams->getGirth(), $packageParams->getGirthDimensionUnits(), Zend_Measure_Length::INCH));
     }
     $container = $request->getPackagingType();
     switch ($container) {
         case 'VARIABLE':
             $container = 'VARIABLE';
             break;
         case 'FLAT RATE ENVELOPE':
             $container = 'FLATRATEENV';
             break;
         case 'FLAT RATE BOX':
             $container = 'FLATRATEBOX';
             break;
         case 'RECTANGULAR':
             $container = 'RECTANGULAR';
             break;
         case 'NONRECTANGULAR':
             $container = 'NONRECTANGULAR';
             break;
         default:
             $container = 'VARIABLE';
     }
     $shippingMethod = $request->getShippingMethod();
     list($fromZip5, $fromZip4) = $this->_parseZip($request->getShipperAddressPostalCode());
     // the wrap node needs for remove xml declaration above
     $xmlWrap = new SimpleXMLElement('<?xml version = "1.0" encoding = "UTF-8"?><wrap/>');
     $method = '';
     $service = $this->getCode('service_to_code', $shippingMethod);
     if ($service == 'Priority') {
         $method = 'Priority';
         $rootNode = 'PriorityMailIntlRequest';
         $xml = $xmlWrap->addChild($rootNode);
     } else {
         if ($service == 'First Class') {
             $method = 'FirstClass';
             $rootNode = 'FirstClassMailIntlRequest';
             $xml = $xmlWrap->addChild($rootNode);
         } else {
             $method = 'Express';
             $rootNode = 'ExpressMailIntlRequest';
             $xml = $xmlWrap->addChild($rootNode);
         }
     }
     $xml->addAttribute('USERID', $this->getConfigData('userid'));
     $xml->addAttribute('PASSWORD', $this->getConfigData('password'));
     $xml->addChild('Option');
     $xml->addChild('Revision', self::DEFAULT_REVISION);
     $xml->addChild('ImageParameters');
     $xml->addChild('FromFirstName', $request->getShipperContactPersonFirstName());
     $xml->addChild('FromLastName', $request->getShipperContactPersonLastName());
     $xml->addChild('FromFirm', $request->getShipperContactCompanyName());
     $xml->addChild('FromAddress1', $request->getShipperAddressStreet2());
     $xml->addChild('FromAddress2', $request->getShipperAddressStreet1());
     $xml->addChild('FromCity', $request->getShipperAddressCity());
     $xml->addChild('FromState', $request->getShipperAddressStateOrProvinceCode());
     $xml->addChild('FromZip5', $fromZip5);
     $xml->addChild('FromZip4', $fromZip4);
     $xml->addChild('FromPhone', $request->getShipperContactPhoneNumber());
     if ($method != 'FirstClass') {
         if ($request->getReferenceData()) {
             $referenceData = $request->getReferenceData() . ' P' . $request->getPackageId();
         } else {
             $referenceData = $request->getOrderShipment()->getOrder()->getIncrementId() . ' P' . $request->getPackageId();
         }
         $xml->addChild('FromCustomsReference', 'Order #' . $referenceData);
     }
     $xml->addChild('ToFirstName', $request->getRecipientContactPersonFirstName());
     $xml->addChild('ToLastName', $request->getRecipientContactPersonLastName());
     $xml->addChild('ToFirm', $request->getRecipientContactCompanyName());
     $xml->addChild('ToAddress1', $request->getRecipientAddressStreet1());
     $xml->addChild('ToAddress2', $request->getRecipientAddressStreet2());
     $xml->addChild('ToCity', $request->getRecipientAddressCity());
     $xml->addChild('ToProvince', $request->getRecipientAddressStateOrProvinceCode());
     $xml->addChild('ToCountry', $this->_getCountryName($request->getRecipientAddressCountryCode()));
     $xml->addChild('ToPostalCode', $request->getRecipientAddressPostalCode());
     $xml->addChild('ToPOBoxFlag', 'N');
     $xml->addChild('ToPhone', $request->getRecipientContactPhoneNumber());
     $xml->addChild('ToFax');
     $xml->addChild('ToEmail');
     if ($method != 'FirstClass') {
         $xml->addChild('NonDeliveryOption', 'Return');
     }
     if ($method == 'FirstClass') {
         if (stripos($shippingMethod, 'Letter') !== false) {
             $xml->addChild('FirstClassMailType', 'LETTER');
         } else {
             if (stripos($shippingMethod, 'Flat') !== false) {
                 $xml->addChild('FirstClassMailType', 'FLAT');
             } else {
                 $xml->addChild('FirstClassMailType', 'PARCEL');
             }
         }
     }
     if ($method != 'FirstClass') {
         $xml->addChild('Container', $container);
     }
     $shippingContents = $xml->addChild('ShippingContents');
     $packageItems = $request->getPackageItems();
     // get countries of manufacture
     $countriesOfManufacture = array();
     $productIds = array();
     foreach ($packageItems as $itemShipment) {
         $item = new Varien_Object();
         $item->setData($itemShipment);
         $productIds[] = $item->getProductId();
     }
     $productCollection = Mage::getResourceModel('catalog/product_collection')->addStoreFilter($request->getStoreId())->addFieldToFilter('entity_id', array('in' => $productIds))->addAttributeToSelect('country_of_manufacture');
     foreach ($productCollection as $product) {
         $countriesOfManufacture[$product->getId()] = $product->getCountryOfManufacture();
     }
     $packagePoundsWeight = $packageOuncesWeight = 0;
     // for ItemDetail
     foreach ($packageItems as $itemShipment) {
         $item = new Varien_Object();
         $item->setData($itemShipment);
         $itemWeight = $item->getWeight() * $item->getQty();
         if ($packageParams->getWeightUnits() != Zend_Measure_Weight::POUND) {
             $itemWeight = Mage::helper('usa')->convertMeasureWeight($itemWeight, $packageParams->getWeightUnits(), Zend_Measure_Weight::POUND);
         }
         if (!empty($countriesOfManufacture[$item->getProductId()])) {
             $countryOfManufacture = $this->_getCountryName($countriesOfManufacture[$item->getProductId()]);
         } else {
             $countryOfManufacture = '';
         }
         $itemDetail = $shippingContents->addChild('ItemDetail');
         $itemDetail->addChild('Description', $item->getName());
         $ceiledQty = ceil($item->getQty());
         if ($ceiledQty < 1) {
             $ceiledQty = 1;
         }
         $individualItemWeight = $itemWeight / $ceiledQty;
         $itemDetail->addChild('Quantity', $ceiledQty);
         $itemDetail->addChild('Value', $item->getCustomsValue() * $item->getQty());
         list($individualPoundsWeight, $individualOuncesWeight) = $this->_convertPoundOunces($individualItemWeight);
         $itemDetail->addChild('NetPounds', $individualPoundsWeight);
         $itemDetail->addChild('NetOunces', $individualOuncesWeight);
         $itemDetail->addChild('HSTariffNumber', 0);
         $itemDetail->addChild('CountryOfOrigin', $countryOfManufacture);
         list($itemPoundsWeight, $itemOuncesWeight) = $this->_convertPoundOunces($itemWeight);
         $packagePoundsWeight += $itemPoundsWeight;
         $packageOuncesWeight += $itemOuncesWeight;
     }
     $additionalPackagePoundsWeight = floor($packageOuncesWeight / self::OUNCES_POUND);
     $packagePoundsWeight += $additionalPackagePoundsWeight;
     $packageOuncesWeight -= $additionalPackagePoundsWeight * self::OUNCES_POUND;
     if ($packagePoundsWeight + $packageOuncesWeight / self::OUNCES_POUND < $packageWeight) {
         list($packagePoundsWeight, $packageOuncesWeight) = $this->_convertPoundOunces($packageWeight);
     }
     $xml->addChild('GrossPounds', $packagePoundsWeight);
     $xml->addChild('GrossOunces', $packageOuncesWeight);
     if ($packageParams->getContentType() == 'OTHER' && $packageParams->getContentTypeOther() != null) {
         $xml->addChild('ContentType', $packageParams->getContentType());
         $xml->addChild('ContentTypeOther ', $packageParams->getContentTypeOther());
     } else {
         $xml->addChild('ContentType', $packageParams->getContentType());
     }
     $xml->addChild('Agreement', 'y');
     $xml->addChild('ImageType', 'PDF');
     $xml->addChild('ImageLayout', 'ALLINONEFILE');
     if ($method == 'FirstClass') {
         $xml->addChild('Container', $container);
     }
     // set size
     if ($packageParams->getSize()) {
         $xml->addChild('Size', $packageParams->getSize());
     }
     // set dimensions
     $xml->addChild('Length', $length);
     $xml->addChild('Width', $width);
     $xml->addChild('Height', $height);
     if ($girth) {
         $xml->addChild('Girth', $girth);
     }
     $xml = $xmlWrap->{$rootNode}->asXML();
     return $xml;
 }
Example #23
0
 /**
  * Get one line item key-value array
  *
  * @param Mage_Core_Model_Abstract $salesEntity
  * @param Varien_Object $item
  * @return array
  */
 protected function _prepareLineItemFields(Mage_Core_Model_Abstract $salesEntity, Varien_Object $item)
 {
     if ($salesEntity instanceof Mage_Sales_Model_Order) {
         $qty = $item->getQtyOrdered();
         $amount = $item->getBasePrice();
         // TODO: nominal item for order
     } else {
         $qty = $item->getTotalQty();
         $amount = $item->isNominal() ? 0 : $item->getBaseCalculationPrice();
     }
     // workaround in case if item subtotal precision is not compatible with PayPal (.2)
     $subAggregatedLabel = '';
     if ((double) $amount - round((double) $amount, 2)) {
         $amount = $amount * $qty;
         $subAggregatedLabel = ' x' . $qty;
         $qty = 1;
     }
     return array('id' => $item->getSku(), 'name' => $item->getName() . $subAggregatedLabel, 'qty' => $qty, 'amount' => (double) $amount);
 }
Example #24
0
 public function getForwardData(Varien_Object $dialog)
 {
     $data = array();
     $forward = $dialog->getForwardData();
     if ($forward) {
         $keys = explode(",", $forward);
         foreach ($keys as $key) {
             /** @var $instance Mage_Core_Model_Abstract */
             $instance = Mage::registry("current_{$key}");
             if ($instance && $instance->getId()) {
                 $data[$key] = $instance->getId();
             }
         }
     }
     $data[Magpleasure_Common_Block_Widget_Dialog::FKEY_JS_OBJECT_NAME] = $dialog->getName();
     try {
         $data = serialize($data);
     } catch (Exception $e) {
         $data = '';
     }
     return $this->_commonHelper()->getCore()->urlEncode($data);
 }
Example #25
0
 /**
  * Validate a single plugin
  *
  * @param Varien_Object $params
  * @return void
  */
 protected function _validatePlugin(Varien_Object $params)
 {
     if ($params->getCurrentVersion() && version_compare($params->getNewVersion(), $params->getCurrentVersion(), '>')) {
         throw Fishpig_Wordpress_Exception::warning($params->getName(), $this->__('You have version %s installed. Update to %s.', $params->getCurrentVersion(), sprintf('<a href="%s" target="_blank">%s</a>', $params->getUrl(), $params->getNewVersion())));
     }
     if ($params->getId() && !$params->getCurrentVersion()) {
         if (Mage::helper('wordpress')->isPluginEnabled($params->getId())) {
             throw Fishpig_Wordpress_Exception::warning($params->getName(), $this->__('Extension required for plugin to work. ') . $this->__('Install %s', sprintf('<a href="%s" target="_blank">extension</a>.', $params->getUrl())));
         }
     }
     return $this;
 }
Example #26
0
 /**
  * Render grid row
  *
  * @param Varien_Object $row
  * @return string
  */
 public function render(Varien_Object $row)
 {
     $str = $this->escapeHtml($row->getName());
     return $str;
 }
Example #27
0
 /**
  * File name URL getter
  *
  * @param  Varien_Object $file
  * @return string
  */
 public function getFileName(Varien_Object $file)
 {
     return $file->getName();
 }
Example #28
0
 /**
  * Create magento coupon product from object
  *
  * @param Varien_Object $coupon
  * @return Mage_Catalog_Model_Product
  */
 public function createProductFromShopgateCoupon(Varien_Object $coupon)
 {
     /* @var $product Mage_Catalog_Model_Product */
     $product = Mage::getModel('catalog/product');
     $id = $product->getIdBySku($coupon->getItemNumber());
     $product->load($id);
     $product = $this->prepareShopgateCouponProduct($product);
     $product->setPriceCalculation(false);
     $product->setName($coupon->getName());
     $product->setSku($coupon->getItemNumber());
     $product->setPrice($coupon->getUnitAmountWithTax());
     $product->setStoreId(Mage::app()->getStore()->getStoreId());
     if (!$product->getId()) {
         $oldStoreId = Mage::app()->getStore()->getStoreId();
         Mage::app()->setCurrentStore(0);
         $product->save();
         Mage::app()->setCurrentStore($oldStoreId);
     }
     return $product;
 }
Example #29
0
 /**
  * Form array with appropriate structure for shipment request
  *
  * @param Varien_Object $request
  * @return array
  */
 protected function _formShipmentRequest(Varien_Object $request)
 {
     if ($request->getReferenceData()) {
         $referenceData = $request->getReferenceData() . $request->getPackageId();
     } else {
         $referenceData = 'Order #' . $request->getOrderShipment()->getOrder()->getIncrementId() . ' P' . $request->getPackageId();
     }
     $packageParams = $request->getPackageParams();
     $customsValue = $packageParams->getCustomsValue();
     $height = $packageParams->getHeight();
     $width = $packageParams->getWidth();
     $length = $packageParams->getLength();
     $weightUnits = $packageParams->getWeightUnits() == Zend_Measure_Weight::POUND ? 'LB' : 'KG';
     $dimensionsUnits = $packageParams->getDimensionUnits() == Zend_Measure_Length::INCH ? 'IN' : 'CM';
     $unitPrice = 0;
     $itemsQty = 0;
     $itemsDesc = array();
     $countriesOfManufacture = array();
     $productIds = array();
     $packageItems = $request->getPackageItems();
     foreach ($packageItems as $itemShipment) {
         $item = new Varien_Object();
         $item->setData($itemShipment);
         $unitPrice += $item->getPrice();
         $itemsQty += $item->getQty();
         $itemsDesc[] = $item->getName();
         $productIds[] = $item->getProductId();
     }
     // get countries of manufacture
     $productCollection = Mage::getResourceModel('catalog/product_collection')->addStoreFilter($request->getStoreId())->addFieldToFilter('entity_id', array('in' => $productIds))->addAttributeToSelect('country_of_manufacture');
     foreach ($productCollection as $product) {
         $countriesOfManufacture[] = $product->getCountryOfManufacture();
     }
     $paymentType = $request->getIsReturn() ? 'RECIPIENT' : 'SENDER';
     $requestClient = array('RequestedShipment' => array('ShipTimestamp' => time(), 'DropoffType' => $this->getConfigData('dropoff'), 'PackagingType' => $request->getPackagingType(), 'ServiceType' => $request->getShippingMethod(), 'Shipper' => array('Contact' => array('PersonName' => $request->getShipperContactPersonName(), 'CompanyName' => $request->getShipperContactCompanyName(), 'PhoneNumber' => $request->getShipperContactPhoneNumber()), 'Address' => array('StreetLines' => array($request->getShipperAddressStreet1(), $request->getShipperAddressStreet2()), 'City' => $request->getShipperAddressCity(), 'StateOrProvinceCode' => $request->getShipperAddressStateOrProvinceCode(), 'PostalCode' => $request->getShipperAddressPostalCode(), 'CountryCode' => $request->getShipperAddressCountryCode())), 'Recipient' => array('Contact' => array('PersonName' => $request->getRecipientContactPersonName(), 'CompanyName' => $request->getRecipientContactCompanyName(), 'PhoneNumber' => $request->getRecipientContactPhoneNumber()), 'Address' => array('StreetLines' => array($request->getRecipientAddressStreet1(), $request->getRecipientAddressStreet2()), 'City' => $request->getRecipientAddressCity(), 'StateOrProvinceCode' => $request->getRecipientAddressStateOrProvinceCode(), 'PostalCode' => $request->getRecipientAddressPostalCode(), 'CountryCode' => $request->getRecipientAddressCountryCode(), 'Residential' => (bool) $this->getConfigData('residence_delivery'))), 'ShippingChargesPayment' => array('PaymentType' => $paymentType, 'Payor' => array('AccountNumber' => $this->getConfigData('account'), 'CountryCode' => Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId()))), 'LabelSpecification' => array('LabelFormatType' => 'COMMON2D', 'ImageType' => 'PNG', 'LabelStockType' => 'PAPER_8.5X11_TOP_HALF_LABEL'), 'RateRequestTypes' => array('ACCOUNT'), 'PackageCount' => 1, 'RequestedPackageLineItems' => array('SequenceNumber' => '1', 'Weight' => array('Units' => $weightUnits, 'Value' => $request->getPackageWeight()), 'CustomerReferences' => array('CustomerReferenceType' => 'CUSTOMER_REFERENCE', 'Value' => $referenceData), 'SpecialServicesRequested' => array('SpecialServiceTypes' => 'SIGNATURE_OPTION', 'SignatureOptionDetail' => array('OptionType' => $packageParams->getDeliveryConfirmation())))));
     // for international shipping
     if ($request->getShipperAddressCountryCode() != $request->getRecipientAddressCountryCode()) {
         $requestClient['RequestedShipment']['CustomsClearanceDetail'] = array('CustomsValue' => array('Currency' => $request->getBaseCurrencyCode(), 'Amount' => $customsValue), 'DutiesPayment' => array('PaymentType' => $paymentType, 'Payor' => array('AccountNumber' => $this->getConfigData('account'), 'CountryCode' => Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId()))), 'Commodities' => array('Weight' => array('Units' => $weightUnits, 'Value' => $request->getPackageWeight()), 'NumberOfPieces' => 1, 'CountryOfManufacture' => implode(',', array_unique($countriesOfManufacture)), 'Description' => implode(', ', $itemsDesc), 'Quantity' => ceil($itemsQty), 'QuantityUnits' => 'pcs', 'UnitPrice' => array('Currency' => $request->getBaseCurrencyCode(), 'Amount' => $unitPrice), 'CustomsValue' => array('Currency' => $request->getBaseCurrencyCode(), 'Amount' => $customsValue)));
     }
     if ($request->getMasterTrackingId()) {
         $requestClient['RequestedShipment']['MasterTrackingId'] = $request->getMasterTrackingId();
     }
     // set dimensions
     if ($length || $width || $height) {
         $requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions'] = array();
         $dimenssions =& $requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions'];
         $dimenssions['Length'] = $length;
         $dimenssions['Width'] = $width;
         $dimenssions['Height'] = $height;
         $dimenssions['Units'] = $dimensionsUnits;
     }
     return $this->_getAuthDetails() + $requestClient;
 }
Example #30
0
 public function getFileName(Varien_Object $item)
 {
     return $this->prepareFileName($item->getName()) . '.' . strtolower($item->getType());
 }