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


PHP Order::formatPrice方法代码示例

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


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

示例1: getEntries

 /**
  * Get RSS feed items
  *
  * @return array
  */
 protected function getEntries()
 {
     /** @var $resourceModel \Magento\Sales\Model\Resource\Order\Rss\OrderStatus */
     $resourceModel = $this->orderResourceFactory->create();
     $results = $resourceModel->getAllCommentCollection($this->order->getId());
     $entries = [];
     if ($results) {
         foreach ($results as $result) {
             $urlAppend = 'view';
             $type = $result['entity_type_code'];
             if ($type && $type != 'order') {
                 $urlAppend = $type;
             }
             $type = __(ucwords($type));
             $title = __('Details for %1 #%2', $type, $result['increment_id']);
             $description = '<p>' . __('Notified Date: %1', $this->localeDate->formatDate($result['created_at'])) . '<br/>' . __('Comment: %1<br/>', $result['comment']) . '</p>';
             $url = $this->urlBuilder->getUrl('sales/order/' . $urlAppend, ['order_id' => $this->order->getId()]);
             $entries[] = ['title' => $title, 'link' => $url, 'description' => $description];
         }
     }
     $title = __('Order #%1 created at %2', $this->order->getIncrementId(), $this->localeDate->formatDate($this->order->getCreatedAt()));
     $url = $this->urlBuilder->getUrl('sales/order/view', ['order_id' => $this->order->getId()]);
     $description = '<p>' . __('Current Status: %1<br/>', $this->order->getStatusLabel()) . __('Total: %1<br/>', $this->order->formatPrice($this->order->getGrandTotal())) . '</p>';
     $entries[] = ['title' => $title, 'link' => $url, 'description' => $description];
     return ['entries' => $entries];
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:31,代码来源:OrderStatus.php

示例2: _formatOptionValue

 /**
  * Format option value process
  *
  * @param  array|string $value
  * @param  \Magento\Sales\Model\Order $order
  * @return string
  */
 protected function _formatOptionValue($value, $order)
 {
     $resultValue = '';
     if (is_array($value)) {
         if (isset($value['qty'])) {
             $resultValue .= sprintf('%d', $value['qty']) . ' x ';
         }
         $resultValue .= $value['title'];
         if (isset($value['price'])) {
             $resultValue .= " " . $order->formatPrice($value['price']);
         }
         return $resultValue;
     } else {
         return $value;
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:23,代码来源:AbstractPdf.php

示例3: getOrderItemValue

 /**
  * Retrieve order item value by key
  *
  * @param \Magento\Sales\Model\Order $order
  * @param string $key
  * @return string
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function getOrderItemValue(\Magento\Sales\Model\Order $order, $key)
 {
     $escape = true;
     switch ($key) {
         case 'order_increment_id':
             $value = $order->getIncrementId();
             break;
         case 'created_at':
             $value = $this->formatDate($order->getCreatedAt(), \IntlDateFormatter::SHORT, true);
             break;
         case 'shipping_address':
             $value = $order->getShippingAddress() ? $this->escapeHtml($order->getShippingAddress()->getName()) : __('N/A');
             break;
         case 'order_total':
             $value = $order->formatPrice($order->getGrandTotal());
             $escape = false;
             break;
         case 'status_label':
             $value = $order->getStatusLabel();
             break;
         case 'view_url':
             $value = $this->getUrl('sales/order/view', ['order_id' => $order->getId()]);
             break;
         default:
             $value = $order->getData($key) ? $order->getData($key) : __('N/A');
             break;
     }
     return $escape ? $this->escapeHtml($value) : $value;
 }
开发者ID:nja78,项目名称:magento2,代码行数:37,代码来源:View.php


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