diff --git a/Block/Adminhtml/Order/View/VendorNotes.php b/Block/Adminhtml/Order/View/VendorNotes.php index dd2ff9c..0dcd53c 100644 --- a/Block/Adminhtml/Order/View/VendorNotes.php +++ b/Block/Adminhtml/Order/View/VendorNotes.php @@ -6,23 +6,27 @@ use Magento\Sales\Model\Order; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Store\Model\ScopeInterface; use Magento\Framework\Serialize\Serializer\Json; +use Magento\Framework\Filter\Template as FilterTemplate; class VendorNotes extends Template { protected $_order; protected $_scopeConfig; protected $json; + protected $filterTemplate; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Sales\Model\Order $order, ScopeConfigInterface $scopeConfig, Json $json, + FilterTemplate $filterTemplate, array $data = [] ) { $this->_order = $order; $this->_scopeConfig = $scopeConfig; $this->json = $json; + $this->filterTemplate = $filterTemplate; parent::__construct($context, $data); } diff --git a/etc/Model/Config/Backend/HtmlArraySerialized.php b/etc/Model/Config/Backend/HtmlArraySerialized.php new file mode 100644 index 0000000..11ae3ed --- /dev/null +++ b/etc/Model/Config/Backend/HtmlArraySerialized.php @@ -0,0 +1,32 @@ +getValue(); + + if (is_array($value)) { + // Don't escape HTML in the note field + foreach ($value as &$row) { + if (isset($row['note'])) { + // Decode any previously encoded HTML entities + $row['note'] = html_entity_decode($row['note'], ENT_QUOTES, 'UTF-8'); + } + } + unset($row); + } + + $this->setValue($value); + return parent::beforeSave(); + } +} \ No newline at end of file diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index b9fafae..8b54f7e 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -32,7 +32,7 @@ Shopkeeper\VendorNotes\Block\Adminhtml\Form\Field\VendorMapping - Magento\Config\Model\Config\Backend\Serialized\ArraySerialized + Shopkeeper\VendorNotes\Model\Config\Backend\HtmlArraySerialized Add vendor names and their corresponding notes. The vendor name must match exactly as it appears in the product attribute. diff --git a/view/adminhtml/templates/order/view/vendor_notes.phtml b/view/adminhtml/templates/order/view/vendor_notes.phtml index 3c3c217..8a34c43 100644 --- a/view/adminhtml/templates/order/view/vendor_notes.phtml +++ b/view/adminhtml/templates/order/view/vendor_notes.phtml @@ -15,7 +15,7 @@ $notes = $block->getVendorNotes();
- + filterOutputHtml($note); ?>
@@ -25,4 +25,4 @@ $notes = $block->getVendorNotes(); - + \ No newline at end of file