commit 20786161b7087b6a39f8c0a781ba52b21851415a Author: shopkeeperdev Date: Tue Oct 7 18:31:07 2025 -0400 Initial commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/Block/Adminhtml/Order/View/VendorNotes.php b/Block/Adminhtml/Order/View/VendorNotes.php new file mode 100644 index 0000000..043557e --- /dev/null +++ b/Block/Adminhtml/Order/View/VendorNotes.php @@ -0,0 +1,57 @@ +_order = $order; + $this->_scopeConfig = $scopeConfig; + parent::__construct($context, $data); + } + + public function getOrder() + { + return $this->_order->load($this->getRequest()->getParam('order_id')); + } + + public function getVendorNotes() + { + $order = $this->getOrder(); + $notes = []; + $vendorConfigPaths = [ + 'Thermo Fisher' => 'vendor_notes/general/thermo_fisher_note', + 'Orion' => 'vendor_notes/general/orion_note', + 'Nalgene' => 'vendor_notes/general/nalgene_note', + 'Thermo Fisher Parts' => 'vendor_notes/general/thermo_fisher_parts_note' + ]; + + foreach ($order->getAllItems() as $item) { + $product = $item->getProduct(); + $vendorId = $product->getData('vendor'); + if ($vendorId) { + $vendorLabel = $product->getAttributeText('vendor'); + if (isset($vendorConfigPaths[$vendorLabel])) { + $note = $this->_scopeConfig->getValue($vendorConfigPaths[$vendorLabel], ScopeInterface::SCOPE_STORE); + if ($note && !in_array($note, $notes)) { + $notes[] = $note; + } + } + } + } + + return $notes; + } +} diff --git a/Setup/InstallData.php b/Setup/InstallData.php new file mode 100644 index 0000000..0da752f --- /dev/null +++ b/Setup/InstallData.php @@ -0,0 +1,74 @@ +eavSetupFactory = $eavSetupFactory; + $this->attributeSetCollectionFactory = $attributeSetCollectionFactory; + $this->attributeSetFactory = $attributeSetFactory; + } + + public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) + { + $setup->startSetup(); + $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); + + // Create the attribute + $eavSetup->addAttribute( + Product::ENTITY, + 'vendor', + [ + 'type' => 'int', + 'label' => 'Vendor', + 'input' => 'select', + 'source' => \Magento\Eav\Model\Entity\Attribute\Source\Table::class, + 'required' => false, + 'sort_order' => 50, + 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, + 'group' => 'General', + 'used_in_product_listing' => true, + 'visible_on_front' => false, + 'option' => [ + 'values' => [ + 'Thermo Fisher', + 'Orion', + 'Nalgene', + 'Thermo Fisher Parts' + ] + ] + ] + ); + + // Assign the attribute to all existing attribute sets + $attributeId = $eavSetup->getAttributeId(Product::ENTITY, 'vendor'); + $entityTypeId = $eavSetup->getEntityTypeId(Product::ENTITY); + + $attributeSetCollection = $this->attributeSetCollectionFactory->create(); + $attributeSetCollection->addFieldToFilter('entity_type_id', $entityTypeId); + + foreach ($attributeSetCollection as $attributeSet) { + $groupId = $eavSetup->getAttributeGroupId($entityTypeId, $attributeSet->getId(), 'General'); + $eavSetup->addAttributeToGroup($entityTypeId, $attributeSet->getId(), $groupId, $attributeId, null); + } + + $setup->endSetup(); + } +} diff --git a/etc/acl.xml b/etc/acl.xml new file mode 100644 index 0000000..f8fddb8 --- /dev/null +++ b/etc/acl.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml new file mode 100644 index 0000000..32f57ab --- /dev/null +++ b/etc/adminhtml/system.xml @@ -0,0 +1,48 @@ + + + + + + +
+ + shopkeeper + Shopkeeper_VendorNotes::config_vendor_notes + + + + How to use Vendor Notes: +
    +
  • These notes will automatically appear on order pages when products with the corresponding vendor are in the order.
  • +
  • You can use HTML formatting: <br> for line breaks, <a href="mailto:email@example.com">link text</a> for email links.
  • +
  • Leave a field blank if you don't need notes for that vendor.
  • +
+ Need to add a new vendor? +
    +
  1. Go to Stores > Attributes > Product and edit the Vendor attribute (attribute code: vendor)
  2. +
  3. Add your new vendor option in the Manage Options section
  4. +
  5. Contact your developer to add the configuration field for the new vendor note
  6. +
+ + ]]>
+ + + Enter notes here. Supports HTML for links and emails (e.g., <a href="mailto:support@thermofisher.com">support@thermofisher.com</a>). + + + + Enter notes here. Supports HTML for links and emails. + + + + Enter notes here. Supports HTML for links and emails. + + + + Enter notes here. Supports HTML for links and emails. + +
+
+
+
\ No newline at end of file diff --git a/etc/config.xml b/etc/config.xml new file mode 100644 index 0000000..16815c3 --- /dev/null +++ b/etc/config.xml @@ -0,0 +1,13 @@ + + + + + + Example multi-line note for Thermo Fisher.<br>Contact: <a href="mailto:support@thermofisher.com">support@thermofisher.com</a><br>More info: <a href="https://thermofisher.com/support">Support Page</a> + Example note for Orion.<br>Email: <a href="mailto:info@orion.com">info@orion.com</a> + Example note for Nalgene.<br>Link: <a href="https://nalgene.com/help">Help Center</a> + Example note for Thermo Fisher Parts.<br>Support: <a href="mailto:parts@thermofisher.com">parts@thermofisher.com</a> + + + + diff --git a/etc/module.xml b/etc/module.xml new file mode 100644 index 0000000..3e61d6e --- /dev/null +++ b/etc/module.xml @@ -0,0 +1,4 @@ + + + + diff --git a/registration.php b/registration.php new file mode 100644 index 0000000..b39d68b --- /dev/null +++ b/registration.php @@ -0,0 +1,6 @@ + + + + + + + + diff --git a/view/adminhtml/templates/order/view/vendor_notes.phtml b/view/adminhtml/templates/order/view/vendor_notes.phtml new file mode 100644 index 0000000..3c3c217 --- /dev/null +++ b/view/adminhtml/templates/order/view/vendor_notes.phtml @@ -0,0 +1,28 @@ +getVendorNotes(); +?> + +
+
+ +
+
+
+ $note): ?> +
+
+ +
+
+ +
+
+ +
+ + +
+
+
+ diff --git a/view/adminhtml/templates/order/view/vendor_notes.phtml.bak b/view/adminhtml/templates/order/view/vendor_notes.phtml.bak new file mode 100644 index 0000000..525e3e1 --- /dev/null +++ b/view/adminhtml/templates/order/view/vendor_notes.phtml.bak @@ -0,0 +1,16 @@ +getVendorNotes(); +?> + +
+ +
+
    + + + +
+
+
+