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


PHP Order::getAllVisibleItems方法代码示例

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


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

示例1: setOpenInvoiceData

 /**
  * @param $formFields
  * @return mixed
  */
 protected function setOpenInvoiceData($formFields)
 {
     $count = 0;
     $currency = $this->_order->getOrderCurrencyCode();
     foreach ($this->_order->getAllVisibleItems() as $item) {
         ++$count;
         $linename = "line" . $count;
         $formFields['openinvoicedata.' . $linename . '.currencyCode'] = $currency;
         $formFields['openinvoicedata.' . $linename . '.description'] = str_replace("\n", '', trim($item->getName()));
         $formFields['openinvoicedata.' . $linename . '.itemAmount'] = $this->_adyenHelper->formatAmount($item->getPrice(), $currency);
         $formFields['openinvoicedata.' . $linename . '.itemVatAmount'] = $item->getTaxAmount() > 0 && $item->getPriceInclTax() > 0 ? $this->_adyenHelper->formatAmount($item->getPriceInclTax(), $currency) - $this->_adyenHelper->formatAmount($item->getPrice(), $currency) : $this->_adyenHelper->formatAmount($item->getTaxAmount(), $currency);
         // $product = $item->getProduct();
         // Calculate vat percentage
         $percentageMinorUnits = $this->_adyenHelper->getMinorUnitTaxPercent($item->getTaxPercent());
         $formFields['openinvoicedata.' . $linename . '.itemVatPercentage'] = $percentageMinorUnits;
         $formFields['openinvoicedata.' . $linename . '.numberOfItems'] = (int) $item->getQtyOrdered();
         if ($this->_order->getPayment()->getAdditionalInformation(\Adyen\Payment\Observer\AdyenHppDataAssignObserver::BRAND_CODE) == "klarna") {
             $formFields['openinvoicedata.' . $linename . '.vatCategory'] = "High";
         } else {
             $formFields['openinvoicedata.' . $linename . '.vatCategory'] = "None";
         }
     }
     $formFields['openinvoicedata.refundDescription'] = "Refund / Correction for " . $formFields['merchantReference'];
     $formFields['openinvoicedata.numberOfLines'] = $count;
     return $formFields;
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:30,代码来源:Redirect.php

示例2: startTransaction

 public function startTransaction(Order $order, UrlInterface $url)
 {
     $config = new Config($this->_scopeConfig);
     $config->configureSDK();
     $total = $order->getGrandTotal();
     $items = $order->getAllVisibleItems();
     $orderId = $order->getIncrementId();
     $quoteId = $order->getQuoteId();
     $currency = $order->getOrderCurrencyCode();
     $returnUrl = $url->getUrl('paynl/checkout/finish/');
     $exchangeUrl = $url->getUrl('paynl/checkout/exchange/');
     $paymentOptionId = $this->getPaymentOptionId();
     $arrBillingAddress = $order->getBillingAddress()->toArray();
     $arrShippingAddress = $order->getShippingAddress()->toArray();
     $enduser = array('initials' => substr($arrBillingAddress['firstname'], 0, 1), 'lastName' => $arrBillingAddress['lastname'], 'phoneNumber' => $arrBillingAddress['telephone'], 'emailAddress' => $arrBillingAddress['email']);
     $address = array();
     $arrAddress = \Paynl\Helper::splitAddress($arrBillingAddress['street']);
     $address['streetName'] = $arrAddress[0];
     $address['houseNumber'] = $arrAddress[1];
     $address['zipCode'] = $arrBillingAddress['postcode'];
     $address['city'] = $arrBillingAddress['city'];
     $address['country'] = $arrBillingAddress['country_id'];
     $shippingAddress = array();
     $arrAddress2 = \Paynl\Helper::splitAddress($arrShippingAddress['street']);
     $shippingAddress['streetName'] = $arrAddress2[0];
     $shippingAddress['houseNumber'] = $arrAddress2[1];
     $shippingAddress['zipCode'] = $arrShippingAddress['postcode'];
     $shippingAddress['city'] = $arrShippingAddress['city'];
     $shippingAddress['country'] = $arrShippingAddress['country_id'];
     $data = array('amount' => $total, 'returnUrl' => $returnUrl, 'paymentMethod' => $paymentOptionId, 'description' => $orderId, 'extra1' => $orderId, 'extra2' => $quoteId, 'exchangeUrl' => $exchangeUrl, 'currency' => $currency);
     $data['address'] = $address;
     $data['shippingAddress'] = $shippingAddress;
     $data['enduser'] = $enduser;
     $arrProducts = array();
     foreach ($items as $item) {
         $arrItem = $item->toArray();
         if ($arrItem['price_incl_tax'] != null) {
             $product = array('id' => $arrItem['product_id'], 'name' => $arrItem['name'], 'price' => $arrItem['price_incl_tax'], 'qty' => $arrItem['qty_ordered'], 'tax' => $arrItem['tax_amount']);
         }
         $arrProducts[] = $product;
     }
     //shipping
     $shippingCost = $order->getShippingAddress()->getShippingInclTax();
     $shippingTax = $order->getShippingAddress()->getShippingTaxAmount();
     $shippingDescription = $order->getShippingAddress()->getShippingDescription();
     $arrProducts[] = array('id' => 'shipping', 'name' => $shippingDescription, 'price' => $shippingCost, 'qty' => 1, 'tax' => $shippingTax);
     // kortingen
     $discount = $order->getSubtotal() - $order->getSubtotalWithDiscount();
     if ($discount > 0) {
         $arrProducts[] = array('id' => 'discount', 'name' => __('Discount'), 'price' => $discount * -1, 'qty' => 1, 'tax' => 0);
     }
     $data['products'] = $arrProducts;
     if ($config->isTestMode()) {
         $data['testmode'] = 1;
     }
     $data['ipaddress'] = $order->getRemoteIp();
     $transaction = \Paynl\Transaction::start($data);
     return $transaction->getRedirectUrl();
 }
开发者ID:jstjanssens,项目名称:magento2-plugin,代码行数:59,代码来源:PaymentMethod.php

示例3: testGetAllVisibleItems

 /**
  * @param bool $isDeleted
  * @param int|null $parentItemId
  * @param array $result
  *
  * @dataProvider dataProviderGetAllVisibleItems
  */
 public function testGetAllVisibleItems($isDeleted, $parentItemId, array $result)
 {
     $this->item->expects($this->once())->method('isDeleted')->willReturn($isDeleted);
     $this->item->expects($this->any())->method('getParentItemId')->willReturn($parentItemId);
     if (!empty($result)) {
         $result = [$this->item];
     }
     $this->assertEquals($result, $this->order->getAllVisibleItems());
 }
开发者ID:opexsw,项目名称:magento2,代码行数:16,代码来源:OrderTest.php

示例4: getProductsData

 /**
  * @param \Magento\Sales\Model\Order $order
  * @return array
  */
 public function getProductsData(\Magento\Sales\Model\Order $order)
 {
     /**
      * @var $orderItem \Magento\Sales\Api\Data\OrderItemInterface
      */
     $products = [];
     $orderItems = $order->getAllVisibleItems();
     foreach ($orderItems as $orderItem) {
         $products[] = ['name' => $orderItem->getName(), 'unitPrice' => $orderItem->getPriceInclTax() * 100, 'quantity' => (double) $orderItem->getQtyOrdered()];
     }
     return $products;
 }
开发者ID:tozwierz,项目名称:magento2_payupl,代码行数:16,代码来源:DataGetter.php

示例5: buildDiscountRuleDescription

 /**
  * Generates a textual description of the applied discount rules
  *
  * @param Order $order
  * @return string discount description
  */
 protected function buildDiscountRuleDescription(Order $order)
 {
     try {
         $appliedRules = array();
         foreach ($order->getAllVisibleItems() as $item) {
             /* @var Item $item */
             $itemAppliedRules = $item->getAppliedRuleIds();
             if (empty($itemAppliedRules)) {
                 continue;
             }
             $ruleIds = explode(',', $item->getAppliedRuleIds());
             foreach ($ruleIds as $ruleId) {
                 $rule = $this->_salesRuleFactory->create()->load($ruleId);
                 $appliedRules[$ruleId] = $rule->getName();
             }
         }
         if (count($appliedRules) == 0) {
             $appliedRules[] = 'unknown rule';
         }
         $discountTxt = sprintf('Discount (%s)', implode(', ', $appliedRules));
     } catch (\Exception $e) {
         $discountTxt = 'Discount (error)';
     }
     return $discountTxt;
 }
开发者ID:Nosto,项目名称:nosto-magento2,代码行数:31,代码来源:Builder.php


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