当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Sales_Model_Order::getAllVisibleItems方法代码示例

本文整理汇总了PHP中Mage_Sales_Model_Order::getAllVisibleItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order::getAllVisibleItems方法的具体用法?PHP Mage_Sales_Model_Order::getAllVisibleItems怎么用?PHP Mage_Sales_Model_Order::getAllVisibleItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Sales_Model_Order的用法示例。


在下文中一共展示了Mage_Sales_Model_Order::getAllVisibleItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addOrderToQueue

 /**
  * Add the items from the given order to the Order Sync queue. Does nothing if
  * Order Sync is disabled for the store that the order was placed in.
  *
  * @param Mage_Sales_Model_Order $order
  * @param bool                   $force Skip enabled check
  *
  * @return $this
  */
 public function addOrderToQueue(Mage_Sales_Model_Order $order, $force = false)
 {
     if (!$this->isEnabled($order->getStoreId()) && !$force) {
         return $this;
     }
     $items = array();
     foreach ($order->getAllVisibleItems() as $item) {
         /** @var Mage_Sales_Model_Order_Item $item */
         // For configurable products add children items only, for all other products add parents
         if ($item->getProductType() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
             foreach ($item->getChildrenItems() as $child) {
                 if ($child->getId() != null) {
                     $items[] = $child->getId();
                 }
             }
         } else {
             if ($item->getId() != null) {
                 $items[] = $item->getId();
             }
         }
     }
     // in case of multiple addresses used for shipping
     // its possible that items object here is empty
     // if so, we do not add to the item.
     if (!empty($items)) {
         $this->addItemsToQueue($items);
     }
     return $this;
 }
开发者ID:mSupply,项目名称:runnable_test_repo,代码行数:38,代码来源:Sync.php

示例2: generateAcceptedOfferArray

 public function generateAcceptedOfferArray(Mage_Sales_Model_Order $order)
 {
     $array = array();
     foreach ($order->getAllVisibleItems() as $item) {
         $_offer = array('@type' => 'Offer', 'itemOffered' => array('@type' => 'Product', 'name' => $item->getName(), 'sku' => $item->getSku(), 'image' => $item->getImageUrl()), 'price' => (string) number_format($item->getPrice(), 2), 'priceCurrency' => $order->getBaseCurrency()->getCurrencyCode(), 'eligibleQuantity' => array('@type' => 'QuantitativeValue', 'value' => $item->getQtyOrdered()));
         $array[] = $_offer;
     }
     return $array;
 }
开发者ID:salsero35,项目名称:gmailactions,代码行数:9,代码来源:Gmailactions.php

示例3: getCheckoutOptionsHtml

 /**
  * Collect options selected at checkout and calculate type consignment
  *
  * @return string
  */
 public function getCheckoutOptionsHtml()
 {
     $html = false;
     $pgAddress = $this->_helper->getPgAddress($this->_order);
     /** @var object $data Data from checkout */
     $data = $this->_order->getMyparcelData() !== null ? json_decode($this->_order->getMyparcelData(), true) : false;
     $shippingMethod = $this->_order->getShippingMethod();
     if ($pgAddress && $this->_helper->shippingMethodIsPakjegemak($shippingMethod)) {
         if (is_array($data) && key_exists('location', $data)) {
             $dateTime = date('d-m-Y H:i', strtotime($data['date'] . ' ' . $data['start_time']));
             $html .= $this->__('PostNL location:') . ' ' . $dateTime;
             if ($data['price_comment'] != 'retail') {
                 $html .= ', ' . $this->__('TYPE_' . $data['price_comment']);
             }
             $html .= ', ' . $data['location'] . ', ' . $data['city'] . ' (' . $data['postal_code'] . ')';
         } else {
             /** Old data from orders before version 1.6.0 */
             $html .= $this->__('PostNL location:') . ' ' . $pgAddress->getCompany() . ' ' . $pgAddress->getCity();
         }
     } else {
         // Get package type
         $totalWeight = $this->_helper->getTotalWeight($this->_order->getAllVisibleItems());
         if ($totalWeight !== false) {
             $html .= $this->_helper->getPackageType($totalWeight, $this->_order->getShippingAddress()->getCountryId(), true) . ' ';
             if (is_array($data) && key_exists('date', $data)) {
                 $dateTime = date('d-m-Y H:i', strtotime($data['date'] . ' ' . $data['time'][0]['start']));
                 $html .= $this->__('deliver:') . ' ' . $dateTime;
                 if ($data['time'][0]['price_comment'] != 'standard') {
                     $html .= ', ' . $this->__('TYPE_' . $data['time'][0]['price_comment']);
                 }
                 if (key_exists('home_address_only', $data) && $data['home_address_only']) {
                     $html .= ', ' . strtolower($this->__('Home address only'));
                 }
                 if (key_exists('signed', $data) && $data['signed']) {
                     $html .= ', ' . strtolower($this->__('Signature on receipt'));
                 }
             }
         }
     }
     if (is_array($data) && key_exists('browser', $data)) {
         $html = ' <span title="' . $data['browser'] . '"">' . $html . '</span>';
     }
     return $html !== false ? '<br>' . $html : '';
 }
开发者ID:myparcelnl,项目名称:magento1,代码行数:49,代码来源:ShippingInfo.php

示例4: crateFromOrder

 public static function crateFromOrder(Mage_Sales_Model_Order $order)
 {
     $aOrder = new self();
     $aOrder->id = $order->getIncrementId();
     $aOrder->currency = $order->getOrderCurrencyCode();
     $aOrder->total_amount = Aplazame_Sdk_Serializer_Decimal::fromFloat($order->getTotalDue());
     $aOrder->articles = array_map(array('Aplazame_Aplazame_BusinessModel_Article', 'crateFromOrderItem'), $order->getAllVisibleItems());
     if (($discounts = $order->getDiscountAmount()) !== null) {
         $aOrder->discount = Aplazame_Sdk_Serializer_Decimal::fromFloat(-$discounts);
     }
     return $aOrder;
 }
开发者ID:aplazame,项目名称:magento,代码行数:12,代码来源:Order.php

示例5: getItemsParams

 /**
  * Return items information, to be send to API
  * @param Mage_Sales_Model_Order $order
  * @return array
  */
 public function getItemsParams(Mage_Sales_Model_Order $order)
 {
     $return = array();
     if ($items = $order->getAllVisibleItems()) {
         for ($x = 1, $y = 0, $c = count($items); $x <= $c; $x++, $y++) {
             $return['itemId' . $x] = $items[$y]->getId();
             $return['itemDescription' . $x] = substr($items[$y]->getName(), 0, 100);
             $return['itemAmount' . $x] = number_format($items[$y]->getPrice(), 2, '.', '');
             $return['itemQuantity' . $x] = $items[$y]->getQtyOrdered();
         }
     }
     return $return;
 }
开发者ID:brunoalbim,项目名称:PagSeguro-Magento-Transparente,代码行数:18,代码来源:Params.php

示例6: sendOrder

 /**
  * Notify Sailthru that a purchase has been made. This automatically cancels
  * any scheduled abandoned cart email.
  *
  */
 public function sendOrder(Mage_Sales_Model_Order $order)
 {
     try {
         $this->_eventType = 'placeOrder';
         $data = array('email' => $order->getCustomerEmail(), 'items' => $this->_getItems($order->getAllVisibleItems()), 'adjustments' => $this->_getAdjustments($order), 'message_id' => $this->getMessageId(), 'send_template' => 'Purchase Receipt', 'tenders' => $this->_getTenders($order));
         /**
          * Send order data to purchase API
          */
         $responsePurchase = $this->apiPost('purchase', $data);
         /**
          * Send customer data to user API
          */
         //$responseUser = Mage::getModel('sailthruemail/client_user')->sendCustomerData($customer);
     } catch (Exception $e) {
         Mage::logException($e);
         return false;
     }
 }
开发者ID:xiaoguizhidao,项目名称:sailthru-magento-extension,代码行数:23,代码来源:Purchase.php

示例7: _prepareOrderItems

 /**
  * @return array
  */
 protected function _prepareOrderItems()
 {
     /** @var Mage_Sales_Model_Order_Item[] $items */
     $items = $this->_order->getAllVisibleItems();
     $data = array();
     /** @var Mage_Catalog_Model_Product_Media_Config $productMediaConfig */
     $productMediaConfig = Mage::getModel('catalog/product_media_config');
     if ($items) {
         foreach ($items as $item) {
             /** @var Mage_Catalog_Model_Product $product */
             $product = Mage::getModel('catalog/product')->load($item->getProductId());
             $smallImageUrl = $productMediaConfig->getMediaUrl($product->getData('small_image'));
             $item_data = array_filter(array('item_id' => $item->getId(), 'product_id' => $item->getProductId(), 'name' => $item->getName(), 'sku' => $item->getSku(), 'url' => $product->getProductUrl(), 'image_url' => $smallImageUrl, 'details' => $product->getData('short_description'), 'details_full' => $product->getData('description'), 'is_virtual' => $item->getIsVirtual(), 'quantity' => $item->getQtyOrdered(), 'quantity_is_decimal' => $item->getIsQtyDecimal(), 'item_subtotal_with_tax' => $item->getPriceInclTax(), 'item_subtotal' => $item->getPrice(), 'item_tax' => $item->getTaxAmount(), 'item_hidden_tax' => $item->getHiddenTaxAmount(), 'item_tax_before_discount' => $item->getTaxBeforeDiscount(), 'item_shipping_with_tax' => null, 'item_shipping' => null, 'item_discount' => $item->getDiscountAmount(), 'item_discount_with_tax' => null, 'item_total' => $item->getRowTotal(), 'item_total_with_tax' => $item->getRowTotalInclTax()));
             $data[] = $item_data;
             unset($item);
         }
     }
     return $data;
 }
开发者ID:payin7-payments,项目名称:payin7-magento,代码行数:22,代码来源:Submit.php

示例8: addOrderToQueue

 /**
  * Add the items from the given order to the Order Sync queue. Does nothing if
  * Order Sync is disabled for the store that the order was placed in.
  *
  * @param Mage_Sales_Model_Order $order
  * @param bool                   $force Skip enabled check
  *
  * @return $this
  */
 public function addOrderToQueue(Mage_Sales_Model_Order $order, $force = false)
 {
     if (!$this->isEnabled($order->getStoreId()) && !$force) {
         return $this;
     }
     $items = array();
     foreach ($order->getAllVisibleItems() as $item) {
         /** @var Mage_Sales_Model_Order_Item $item */
         // For configurable products add children items only, for all other products add parents
         if ($item->getProductType() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
             foreach ($item->getChildrenItems() as $child) {
                 $items[] = $child->getId();
             }
         } else {
             $items[] = $item->getId();
         }
     }
     $this->addItemsToQueue($items);
     return $this;
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:29,代码来源:Sync.php

示例9: addOrderToQueue

 /**
  * Add the items from the given order to the Order Sync queue. Does nothing if
  * Order Sync is disabled for the store that the order was placed in.
  *
  * @param Mage_Sales_Model_Order $order
  * @param bool                   $force Skip enabled check
  *
  * @return $this
  */
 public function addOrderToQueue(Mage_Sales_Model_Order $order, $force = false)
 {
     if (!$this->isEnabled($order->getStoreId()) && !$force) {
         return $this;
     }
     $items = array();
     $order_date = Mage::helper("klevu_search/compat")->now();
     $session_id = session_id();
     $ip_address = Mage::helper("klevu_search")->getIp();
     $order_email = 'unknown';
     if ($order->getCustomerId()) {
         $order_email = $order->getCustomer()->getEmail();
         //logged in customer
     } else {
         $order_email = $order->getBillingAddress()->getEmail();
         //not logged in customer
     }
     foreach ($order->getAllVisibleItems() as $item) {
         /** @var Mage_Sales_Model_Order_Item $item */
         // For configurable products add children items only, for all other products add parents
         if ($item->getProductType() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
             foreach ($item->getChildrenItems() as $child) {
                 if ($child->getId() != null) {
                     $items[] = array($child->getId(), $session_id, $ip_address, $order_date, $order_email);
                 }
             }
         } else {
             if ($item->getId() != null) {
                 $items[] = array($item->getId(), $session_id, $ip_address, $order_date, $order_email);
             }
         }
     }
     // in case of multiple addresses used for shipping
     // its possible that items object here is empty
     // if so, we do not add to the item.
     if (!empty($items)) {
         $this->addItemsToQueue($items);
     }
     return $this;
 }
开发者ID:klevu,项目名称:klevu-smart-search-M1,代码行数:49,代码来源:Sync.php

示例10: _fillCartInformation

 /**
  * @param array $data
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
  */
 private function _fillCartInformation(&$data, $object)
 {
     $productIids = array();
     $productQtys = array();
     $productStyleIds = array();
     /** @var Mage_Sales_Model_Quote_Item|Mage_Sales_Model_Order_Item $item */
     foreach ($object->getAllVisibleItems() as $item) {
         $productIids[] = $item->getProduct()->getIid();
         $productQtys[] = is_null($item->getQtyOrdered()) ? (int) $item->getQty() : (int) $item->getQtyOrdered();
         $productStyleIds[] = $item->getProduct()->getNumber() . '-' . $item->getProduct()->getColorCode();
     }
     $data['productStyleId'] = implode(',', $productStyleIds);
     $data['cartProductIds'] = implode(',', $productIids);
     $data['cartProductQtys'] = implode(',', $productQtys);
     $data['cartTotalNetto'] = round($object->getBaseSubtotal(), 2);
     $data['cartTotalBrutto'] = round($object->getBaseGrandTotal(), 2);
     $data['customerId'] = (int) $object->getCustomerId();
     // For zanox tracking
     if (array_key_exists('zanpid', $_COOKIE) && $_COOKIE['zanpid'] != '') {
         $data['zanpid'] = $_COOKIE['zanpid'];
     }
 }
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:26,代码来源:Observer.php

示例11: process

 /**
  * @return self
  */
 public function process()
 {
     $orderId = $this->_payload->getCustomerOrderId();
     $this->_order = $this->_getOrder($orderId);
     $logData = ['order_id' => $orderId];
     if (!$this->_order) {
         $logMessage = 'Order ({order_id}) not found in Magento. Could not process that order.';
         $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData));
         return $this;
     }
     if (!$this->_order->canCreditMemo()) {
         $logMessage = 'Credit memo cannot be created for order {order_id}';
         $this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData));
         return $this;
     }
     $this->_order->getAllVisibleItems();
     if ($this->_order->hasInvoices()) {
         $this->_processInvoicedCreditMemos();
     } else {
         $this->_processCreditMemo();
     }
     return $this;
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:26,代码来源:Creditissued.php

示例12: notifyAction


//.........这里部分代码省略.........
                 $state = 'new';
                 $status = 'canceled';
                 $comment = 'Redsys ha actualizado el estado del pedido con el valor "' . $status . '"';
                 $this->escribirLog($idLog . " - Actualizado el estado del pedido con el valor " . $status, $logActivo);
                 $isCustomerNotified = true;
                 $order->setState($state, $status, $comment, $isCustomerNotified);
                 $order->registerCancellation("")->save();
                 $order->save();
                 //$this->_redirect('checkout/onepage/failure');
             }
         } else {
             $this->escribirLog($idLog . " - Validaciones NO superadas", $logActivo);
             $ord = $pedido;
             $orde = $ord;
             $order = Mage::getModel('sales/order')->loadByIncrementId($orde);
             $state = 'new';
             $status = 'canceled';
             $comment = 'Redsys ha actualizado el estado del pedido con el valor "' . $status . '"';
             $isCustomerNotified = true;
             $order->setState($state, $status, $comment, $isCustomerNotified);
             $order->registerCancellation("")->save();
             $order->save();
             //$this->_redirect('checkout/onepage/failure');
         }
     } else {
         if (!empty($_GET)) {
             //URL OK Y KO
             /** Recoger datos de respuesta * */
             $version = $_GET["Ds_SignatureVersion"];
             $datos = $_GET["Ds_MerchantParameters"];
             $firma_remota = $_GET["Ds_Signature"];
             // Se crea Objeto
             $miObj = new RedsysAPI();
             /** Se decodifican los datos enviados y se carga el array de datos * */
             $decodec = $miObj->decodeMerchantParameters($datos);
             /** Clave * */
             $kc = Mage::getStoreConfig('payment/redsys/clave256', Mage::app()->getStore());
             /** Se calcula la firma * */
             $firma_local = $miObj->createMerchantSignatureNotif($kc, $datos);
             /** Extraer datos de la notificación * */
             $total = $miObj->getParameter('Ds_Amount');
             $pedido = $miObj->getParameter('Ds_Order');
             $codigo = $miObj->getParameter('Ds_MerchantCode');
             $terminal = $miObj->getParameter('Ds_Terminal');
             $moneda = $miObj->getParameter('Ds_Currency');
             $respuesta = $miObj->getParameter('Ds_Response');
             $fecha = $miObj->getParameter('Ds_Date');
             $hora = $miObj->getParameter('Ds_Hour');
             $id_trans = $miObj->getParameter('Ds_AuthorisationCode');
             $tipoTrans = $miObj->getParameter('Ds_TransactionType');
             // Recogemos los datos del comercio
             $codigoOrig = Mage::getStoreConfig('payment/redsys/num', Mage::app()->getStore());
             $terminalOrig = Mage::getStoreConfig('payment/redsys/terminal', Mage::app()->getStore());
             $monedaOrig = Mage::getStoreConfig('payment/redsys/moneda', Mage::app()->getStore());
             $tipoTransOrig = Mage::getStoreConfig('payment/redsys/trans', Mage::app()->getStore());
             // Obtenemos el código ISO del tipo de moneda
             if ($monedaOrig == "0") {
                 $monedaOrig = "978";
             } else {
                 $monedaOrig = "840";
             }
             // INI MOD #7375
             // Limpiamos 0 por delante agregados para pasarlo como parámetro
             $pedido = ltrim($pedido, '0');
             // FIN MOD #7375
             if ($firma_local === $firma_remota && checkImporte($total) && checkPedidoNum($pedido) && checkFuc($codigo) && checkMoneda($moneda) && checkRespuesta($respuesta) && $tipoTrans == $tipoTransOrig && $codigo == $codigoOrig && intval(strval($terminalOrig)) == intval(strval($terminal))) {
                 $respuesta = intval($respuesta);
                 $orde = $pedido;
                 $order = Mage::getModel('sales/order')->loadByIncrementId($orde);
                 if ($respuesta < 101) {
                     $transaction_amount = number_format($order->getBaseGrandTotal(), 2, '', '');
                     $amountOrig = (double) $transaction_amount;
                     if ($amountOrig != $total) {
                         $this->_redirect('checkout/onepage/failure');
                     } else {
                         $this->_redirect('checkout/onepage/success');
                     }
                 } else {
                     if (strval($mantenerPedidoAnteError) == 1) {
                         $_order = new Mage_Sales_Model_Order();
                         $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
                         $_order->loadByIncrementId($orderId);
                         $items = $_order->getAllVisibleItems();
                         $cart = Mage::getSingleton('checkout/cart');
                         foreach ($items as $itemId => $item) {
                             $this->escribirLog($idLog . " - Cargado carrito con " . $item->getName(), $logActivo);
                             $cart->addOrderItem($item);
                         }
                         $cart->save();
                     }
                     $this->_redirect('checkout/onepage/failure');
                 }
             } else {
                 $this->_redirect('checkout/onepage/failure');
             }
         } else {
             echo 'No hay respuesta por parte de Redsys!';
         }
     }
 }
开发者ID:Codeko,项目名称:magento-redsys,代码行数:101,代码来源:IndexController.php

示例13: orderCreateRequest

 /**
  * Initializes the payment.
  * @param Mage_Sales_Model_Order
  * @param Mage_Shipping_Model_Shipping
  * @return array
  */
 public function orderCreateRequest(Mage_Sales_Model_Order $order, $allShippingRates)
 {
     $this->_order = $order;
     $orderCurrencyCode = $this->_order->getOrderCurrencyCode();
     $orderCountryCode = $this->_order->getBillingAddress()->getCountry();
     $shippingCostList = array();
     if (empty($allShippingRates) || Mage::getSingleton('customer/session')->isLoggedIn()) {
         if ($order->getShippingInclTax() > 0) {
             $shippingCostList['shippingMethods'][] = array('name' => $order->getShippingDescription(), 'country' => $orderCountryCode, 'price' => $this->toAmount($order->getShippingInclTax()));
         }
         $grandTotal = $this->_order->getGrandTotal() - $order->getShippingInclTax();
     } else {
         $firstPrice = 0;
         foreach ($allShippingRates as $key => $rate) {
             $gross = $this->toAmount($rate->getPrice());
             if ($key == 0) {
                 $firstPrice = $rate->getPrice();
             }
             $shippingCostList['shippingMethods'][] = array('name' => $rate->getMethodTitle(), 'country' => $orderCountryCode, 'price' => $gross);
         }
         $grandTotal = $this->_order->getGrandTotal() - $firstPrice;
     }
     $shippingCost = array('countryCode' => $orderCountryCode, 'shipToOtherCountry' => 'true', 'shippingCostList' => $shippingCostList);
     $orderItems = $this->_order->getAllVisibleItems();
     $items = array();
     $productsTotal = 0;
     $is_discount = false;
     foreach ($orderItems as $key => $item) {
         $itemInfo = $item->getData();
         if ($itemInfo['discount_amount'] > 0) {
             $itemInfo['price_incl_tax'] = $itemInfo['price_incl_tax'] - $itemInfo['discount_amount'];
             $is_discount = true;
         } else {
             if ($itemInfo['discount_percent'] > 0) {
                 $itemInfo['price_incl_tax'] = $itemInfo['price_incl_tax'] * (100 - $itemInfo['discount_percent']) / 100;
             }
         }
         // Check if the item is countable one
         if ($this->toAmount($itemInfo['price_incl_tax']) > 0) {
             $items['products'][] = array('quantity' => (int) $itemInfo['qty_ordered'], 'name' => $itemInfo['name'], 'unitPrice' => $this->toAmount($itemInfo['price_incl_tax']));
             $productsTotal += $itemInfo['price_incl_tax'] * $itemInfo['qty_ordered'];
         }
     }
     //if($this->_order->getShippingAmount () > 0 && !empty ( $shippingCostList['shippingMethods'][0] ) ){
     //        $items ['products'] ['products'] [] = array (
     //            'quantity' => 1 ,'name' => Mage::helper ( 'payu_account' )->__('Shipping costs') . " - " . $shippingCostList['shippingMethods'][0]['name'] ,'unitPrice' => $this->toAmount ( $this->_order->getShippingAmount () ));
     //}
     // assigning the shopping cart
     $shoppingCart = array('grandTotal' => $this->toAmount($grandTotal), 'CurrencyCode' => $orderCurrencyCode, 'ShoppingCartItems' => $items);
     $orderInfo = array('merchantPosId' => OpenPayU_Configuration::getMerchantPosId(), 'orderUrl' => Mage::getBaseUrl() . 'sales/order/view/order_id/' . $this->_order->getId() . '/', 'description' => 'Order no ' . $this->_order->getRealOrderId(), 'validityTime' => $this->_config->getOrderValidityTime());
     if ($is_discount) {
         $items['products'] = array();
         $items['products'][] = array('quantity' => 1, 'name' => Mage::helper('payu_account')->__('Order # ') . $this->_order->getId(), 'unitPrice' => $this->toAmount($grandTotal));
     }
     $OCReq = $orderInfo;
     $OCReq['products'] = $items['products'];
     $OCReq['customerIp'] = Mage::app()->getFrontController()->getRequest()->getClientIp();
     $OCReq['notifyUrl'] = $this->_myUrl . 'orderNotifyRequest';
     $OCReq['cancelUrl'] = $this->_myUrl . 'cancelPayment';
     $OCReq['continueUrl'] = $this->_myUrl . 'continuePayment';
     $OCReq['currencyCode'] = $orderCurrencyCode;
     $OCReq['totalAmount'] = $shoppingCart['grandTotal'];
     $OCReq['extOrderId'] = $this->_order->getId() . '-' . microtime();
     if (!empty($shippingCostList)) {
         $OCReq['shippingMethods'] = $shippingCostList['shippingMethods'];
     }
     unset($OCReq['shoppingCart']);
     $customer_sheet = array();
     $billingAddressId = $this->_order->getBillingAddressId();
     if (!empty($billingAddressId)) {
         $billingAddress = $this->_order->getBillingAddress();
         $customer_mail = $billingAddress->getEmail();
         if (!empty($customer_mail)) {
             $customer_sheet = array('email' => $billingAddress->getEmail(), 'phone' => $billingAddress->getTelephone(), 'firstName' => $billingAddress->getFirstname(), 'lastName' => $billingAddress->getLastname());
             $shippingAddressId = $this->_order->getShippingAddressId();
             if (!empty($shippingAddressId)) {
                 $shippingAddress = $this->_order->getShippingAddress();
             }
             if (!$this->_order->getIsVirtual()) {
                 $customer_sheet['delivery'] = array('street' => trim(implode(' ', $shippingAddress->getStreet())), 'postalCode' => $shippingAddress->getPostcode(), 'city' => $shippingAddress->getCity(), 'countryCode' => $shippingAddress->getCountry(), 'recipientName' => trim($shippingAddress->getFirstname() . ' ' . $shippingAddress->getLastname()), 'recipientPhone' => $shippingAddress->getTelephone(), 'recipientEmail' => $shippingAddress->getEmail());
             }
             $OCReq['buyer'] = $customer_sheet;
         }
     }
     $result = OpenPayU_Order::create($OCReq);
     if ($result->getStatus() == 'SUCCESS') {
         // store session identifier in session info
         Mage::getSingleton('core/session')->setPayUSessionId($result->getResponse()->orderId);
         // assign current transaction id
         $this->_transactionId = $result->getResponse()->orderId;
         $order->getPayment()->setLastTransId($this->_transactionId);
         $locale = Mage::getStoreConfig('general/locale/code', Mage::app()->getStore()->getId());
         $lang_code = explode('_', $locale, 2);
         $ret = array('redirectUri' => $result->getResponse()->redirectUri, 'url' => OpenPayu_Configuration::getSummaryUrl(), 'sessionId' => $result->getResponse()->orderId, 'lang' => strtolower($lang_code[1]));
//.........这里部分代码省略.........
开发者ID:par-orillonsoft,项目名称:plugin_magento,代码行数:101,代码来源:Payment.php

示例14: getInvoiceExtraPrintBlocksXML

 /**
  * Generate Invoice Print XML
  * @param Mage_Sales_Model_Order $order
  * @return mixed
  */
 public function getInvoiceExtraPrintBlocksXML($order)
 {
     $dom = new DOMDocument('1.0', 'utf-8');
     $OnlineInvoice = $dom->createElement('OnlineInvoice');
     $dom->appendChild($OnlineInvoice);
     $OnlineInvoice->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $OnlineInvoice->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsd', 'http://www.w3.org/2001/XMLSchema');
     $OrderLines = $dom->createElement('OrderLines');
     $OnlineInvoice->appendChild($OrderLines);
     // Add Order Lines
     $items = $order->getAllVisibleItems();
     /** @var $item Mage_Sales_Model_Order_Item */
     foreach ($items as $item) {
         // @todo Calculate prices using Discount Rules
         // @todo Get children products from bundle
         //if (!$item->getNoDiscount()) {
         //    Mage::helper('partpayment/tools')->addToDebug('Warning: The product has a discount. There might be problems.', $order->getIncrementId());
         //}
         $itemQty = (int) $item->getQtyOrdered();
         //$taxPrice = $item->getTaxAmount();
         $taxPrice = $itemQty * $item->getPriceInclTax() - $itemQty * $item->getPrice();
         $taxPercent = $item->getTaxPercent();
         $priceWithTax = $itemQty * $item->getPriceInclTax();
         // Calculate tax percent for Bundle products
         if ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
             $taxPercent = $taxPrice > 0 ? round(100 / (($priceWithTax - $taxPrice) / $taxPrice)) : 0;
         }
         $OrderLine = $dom->createElement('OrderLine');
         $OrderLine->appendChild($dom->createElement('Product', $item->getName()));
         $OrderLine->appendChild($dom->createElement('Qty', $itemQty));
         $OrderLine->appendChild($dom->createElement('UnitPrice', sprintf("%.2f", $item->getPrice())));
         $OrderLine->appendChild($dom->createElement('VatRate', sprintf("%.2f", $taxPercent)));
         $OrderLine->appendChild($dom->createElement('VatAmount', sprintf("%.2f", $taxPrice)));
         $OrderLine->appendChild($dom->createElement('Amount', sprintf("%.2f", $priceWithTax)));
         $OrderLines->appendChild($OrderLine);
     }
     // Add Shipping Line
     if (!$order->getIsVirtual()) {
         $shipping = $order->getShippingAmount();
         //$shippingIncTax = $order->getShippingInclTax();
         $shippingTax = $order->getShippingTaxAmount();
         $shippingTaxPercent = $shipping != 0 ? (int) (100 * $shippingTax / $shipping) : 0;
         $OrderLine = $dom->createElement('OrderLine');
         $OrderLine->appendChild($dom->createElement('Product', $order->getShippingDescription()));
         $OrderLine->appendChild($dom->createElement('Qty', 1));
         $OrderLine->appendChild($dom->createElement('UnitPrice', sprintf("%.2f", $shipping)));
         $OrderLine->appendChild($dom->createElement('VatRate', sprintf("%.2f", $shippingTaxPercent)));
         $OrderLine->appendChild($dom->createElement('VatAmount', sprintf("%.2f", $shippingTax)));
         $OrderLine->appendChild($dom->createElement('Amount', sprintf("%.2f", $shipping + $shippingTax)));
         $OrderLines->appendChild($OrderLine);
     }
     // add Payment Fee
     $fee = $order->getPartpaymentPaymentFee();
     if ($fee > 0) {
         $OrderLine = $dom->createElement('OrderLine');
         $OrderLine->appendChild($dom->createElement('Product', Mage::helper('partpayment')->__('Payment fee')));
         $OrderLine->appendChild($dom->createElement('Qty', 1));
         $OrderLine->appendChild($dom->createElement('UnitPrice', sprintf("%.2f", $fee)));
         $OrderLine->appendChild($dom->createElement('VatRate', 0));
         $OrderLine->appendChild($dom->createElement('VatAmount', 0));
         $OrderLine->appendChild($dom->createElement('Amount', sprintf("%.2f", $fee)));
         $OrderLines->appendChild($OrderLine);
     }
     // add Discount
     $discount = $order->getDiscountAmount() + $order->getShippingDiscountAmount();
     if (abs($discount) > 0) {
         $discount_description = $order->getDiscountDescription() !== null ? Mage::helper('sales')->__('Discount (%s)', $order->getDiscountDescription()) : Mage::helper('sales')->__('Discount');
         $OrderLine = $dom->createElement('OrderLine');
         $OrderLine->appendChild($dom->createElement('Product', $discount_description));
         $OrderLine->appendChild($dom->createElement('Qty', 1));
         $OrderLine->appendChild($dom->createElement('UnitPrice', sprintf("%.2f", $discount)));
         $OrderLine->appendChild($dom->createElement('VatRate', 0));
         $OrderLine->appendChild($dom->createElement('VatAmount', 0));
         $OrderLine->appendChild($dom->createElement('Amount', sprintf("%.2f", $discount)));
         $OrderLines->appendChild($OrderLine);
     }
     // Add reward points
     if ((double) $order->getBaseRewardCurrencyAmount() > 0) {
         $OrderLine = $dom->createElement('OrderLine');
         $OrderLine->appendChild($dom->createElement('Product', Mage::helper('partpayment')->__('Reward points')));
         $OrderLine->appendChild($dom->createElement('Qty', 1));
         $OrderLine->appendChild($dom->createElement('UnitPrice', -1 * $order->getBaseRewardCurrencyAmount()));
         $OrderLine->appendChild($dom->createElement('VatRate', 0));
         $OrderLine->appendChild($dom->createElement('VatAmount', 0));
         $OrderLine->appendChild($dom->createElement('Amount', -1 * $order->getBaseRewardCurrencyAmount()));
         $OrderLines->appendChild($OrderLine);
     }
     return str_replace("\n", '', $dom->saveXML());
 }
开发者ID:anziv,项目名称:Magento-modules,代码行数:94,代码来源:Order.php

示例15: _persistOrder

 /**
  * Function to persist orders to be flushed to Bronto
  *
  * @param Mage_Sales_Model_Order $order
  * @param Bronto_Api_Order $brontoOrder
  * @param Bronto_Order_Model_Queue $orderRow
  * @param array $context
  */
 protected function _persistOrder($order, $brontoOrder, $orderRow, $context)
 {
     extract($context);
     // Get visible items from order
     $items = $order->getAllVisibleItems();
     // Keep product order by using a new array
     $fullItems = array();
     $brontoOrderItems = array();
     // loop through the items. if it's a bundled item,
     // replace the parent item with the child items.
     foreach ($items as $item) {
         $itemProduct = Mage::getModel('catalog/product')->load($item->getProductId());
         // Handle product based on product type
         switch ($itemProduct->getTypeId()) {
             // Bundled products need child items
             case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
                 if (count($item->getChildrenItems()) > 0) {
                     foreach ($item->getChildrenItems() as $childItem) {
                         if ($childItem->getPrice() != 0) {
                             $item->setPrice(0);
                         }
                         $fullItems[] = $childItem;
                     }
                 }
                 $fullItems[] = $item;
                 break;
                 // Configurable products just need simple config item
             // Configurable products just need simple config item
             case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE:
                 $childItems = $item->getChildrenItems();
                 if (1 === count($childItems)) {
                     $childItem = $childItems[0];
                     // Collect options applicable to the configurable product
                     $productAttributeOptions = $itemProduct->getTypeInstance(true)->getConfigurableAttributesAsArray($itemProduct);
                     // Build Selected Options Name
                     $nameWithOptions = array();
                     foreach ($productAttributeOptions as $productAttribute) {
                         $itemValue = $productHelper->getProductAttribute($childItem->getProductId(), $productAttribute['attribute_code'], $storeId);
                         $nameWithOptions[] = $productAttribute['label'] . ': ' . $itemValue;
                     }
                     // Set parent product name to include selected options
                     $parentName = $item->getName() . ' [' . implode(', ', $nameWithOptions) . ']';
                     $item->setName($parentName);
                 }
                 $fullItems[] = $item;
                 break;
                 // Grouped products need parent and child items
             // Grouped products need parent and child items
             case Mage_Catalog_Model_Product_Type::TYPE_GROUPED:
                 // This condition probably never gets hit, parent grouped items don't show in order
                 $fullItems[] = $item;
                 foreach ($item->getChildrenItems() as $child_item) {
                     $fullItems[] = $child_item;
                 }
                 break;
                 // Anything else (namely simples) just get added to array
             // Anything else (namely simples) just get added to array
             default:
                 $fullItems[] = $item;
                 break;
         }
     }
     // Cycle through newly created array of products
     foreach ($fullItems as $item) {
         // If product has a parent, get that parent product
         $parent = false;
         if ($item->getParentItem()) {
             $parent = Mage::getModel('catalog/product')->setStoreId($storeId)->load($item->getParentItem()->getProductId());
         }
         /* @var $product Mage_Catalog_Model_Product */
         $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($item->getProductId());
         // If there is a parent product, use that to get category ids
         if ($parent) {
             $categoryIds = $parent->getCategoryIds();
         } else {
             $categoryIds = $product->getCategoryIds();
         }
         // If the product type is simple and the description
         // is empty, then attempt to find a parent product
         // to backfill the description.
         $parentProduct = $productHelper->getConfigurableProduct($product);
         if (!$product->getData($descriptionAttr)) {
             $product->setData($descriptionAttr, $parentProduct->getData($descriptionAttr));
         }
         if (empty($categoryIds)) {
             $categoryIds = $parentProduct->getCategoryIds();
         }
         // Cycle through category ids to pull category details
         $categories = array();
         foreach ($categoryIds as $categoryId) {
             /* @var $category Mage_Catalog_Model_Category */
             $category = Mage::getModel('catalog/category')->load($categoryId);
//.........这里部分代码省略.........
开发者ID:bevello,项目名称:bevello,代码行数:101,代码来源:Observer.php


注:本文中的Mage_Sales_Model_Order::getAllVisibleItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。