Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions CustomBoldCommentPlugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
namespace Bold\OrderComment\Plugin;
use Magento\Sales\Api\Data\OrderExtensionFactory;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\Data\OrderSearchResultInterface;
use Magento\Sales\Api\OrderRepositoryInterface;

class CustomBoldCommentPlugin
{

const FIELD_NAME = 'bold_order_comment';
protected $extensionFactory;

public function __construct(OrderExtensionFactory $extensionFactory)
{
$this->extensionFactory = $extensionFactory;
}

public function afterGet(OrderRepositoryInterface $subject, OrderInterface $order)
{
$customBoldComments = $order->getData(self::FIELD_NAME);
$extensionAttributes = $order->getExtensionAttributes();
$extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
$extensionAttributes->setBoldOrderComment($customBoldComments);
$order->setExtensionAttributes($extensionAttributes);
return $order;
}

public function afterGetList(OrderRepositoryInterface $subject, OrderSearchResultInterface $searchResult)
{
$orders = $searchResult->getItems();
foreach ($orders as &$order) {
$customBoldComments = $order->getData(self::FIELD_NAME);
$extensionAttributes = $order->getExtensionAttributes();
$extensionAttributes = $extensionAttributes ? $extensionAttributes : $this->extensionFactory->create();
$extensionAttributes->setBoldOrderComment($customBoldComments);
$order->setExtensionAttributes($extensionAttributes);
}
return $searchResult;
}
}
7 changes: 6 additions & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@
<type name="Magento\Sales\Api\OrderRepositoryInterface">
<plugin name="bold_load_ordercomment" type="Bold\OrderComment\Plugin\Model\Order\LoadOrderComment"/>
</type>
</config>

<type name="Magento\Sales\Api\OrderRepositoryInterface">
<plugin name="bold_order_comment_add_order_extension_attribute"
type="Bold\OrderComment\Plugin\CustomBoldCommentPlugin" />
</type>
</config>
5 changes: 5 additions & 0 deletions i18n/es_ES.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"Do you have any comments regarding the order?","¿Tienes algún comentario para agregar al pedido?"
"Enter your comment...","Ingrese su comentario..."
"Order Comment","Comentario del pedido"
"The order comment could not be saved","El comentario del pedido no pudo ser almacenado"
"Cart %1 doesn't contain products","El carrito %1 no contiene productos"