commit f07db21ac428ad60619c0881ba4af0bd9d84db30 Author: shopkeeperdev Date: Thu Nov 20 12:01:53 2025 -0500 Initial commit: Free Shipping Message module diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d840458 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# IDE +.idea/ +.vscode/ +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db diff --git a/Block/Product/View/Message.php b/Block/Product/View/Message.php new file mode 100644 index 0000000..e08eff1 --- /dev/null +++ b/Block/Product/View/Message.php @@ -0,0 +1,86 @@ +blockFactory = $blockFactory; + $this->filterProvider = $filterProvider; + parent::__construct($context, $data); + } + + /** + * Get CMS block HTML content + * + * @return string + */ + public function getCmsBlockHtml() + { + $blockId = $this->getData('cms_block_id'); + + if (!$blockId) { + return ''; + } + + $block = $this->blockFactory->create(); + $block->load($blockId, 'identifier'); + + if (!$block->getId() || !$block->isActive()) { + return ''; + } + + $html = $this->filterProvider->getBlockFilter() + ->setStoreId($this->_storeManager->getStore()->getId()) + ->filter($block->getContent()); + + return $html; + } + + /** + * Check if CMS block exists and is active + * + * @return bool + */ + public function hasCmsBlock() + { + $blockId = $this->getData('cms_block_id'); + + if (!$blockId) { + return false; + } + + $block = $this->blockFactory->create(); + $block->load($blockId, 'identifier'); + + return $block->getId() && $block->isActive(); + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..d5fdb6c --- /dev/null +++ b/README.md @@ -0,0 +1,101 @@ +# Shopkeeper Free Shipping Message + +A Magento 2 module that displays a customizable CMS block message below the "Add to Cart" button on product pages. + +## Features + +- Displays a CMS block on product pages +- Positioned below the "Add to Cart" button +- Fully customizable content through Magento admin +- Only displays when the CMS block is active + +## Installation + +### Via Composer (Recommended) + +```bash +composer require shopkeeper/module-free-shipping-message +php bin/magento module:enable Shopkeeper_FreeShippingMessage +php bin/magento setup:upgrade +php bin/magento cache:flush +``` + +### Manual Installation + +1. Create directory: `app/code/Shopkeeper/FreeShippingMessage` +2. Copy all files to the directory +3. Run the following commands: + +```bash +php bin/magento module:enable Shopkeeper_FreeShippingMessage +php bin/magento setup:upgrade +php bin/magento cache:flush +``` + +## Configuration + +1. Log into Magento Admin +2. Navigate to **Content > Blocks** +3. Create a new CMS block with the following settings: + - **Block Title**: Free Shipping Message (or your preferred title) + - **Identifier**: `free_shipping_message` + - **Status**: Enabled + - **Store View**: Select appropriate store views + - **Content**: Add your free shipping message content + +## Module Structure + +``` +FreeShippingMessage/ +├── Block/ +│ └── Product/ +│ └── View/ +│ └── Message.php +├── etc/ +│ └── module.xml +├── view/ +│ └── frontend/ +│ ├── layout/ +│ │ └── catalog_product_view.xml +│ └── templates/ +│ └── product/ +│ └── view/ +│ └── message.phtml +├── registration.php +└── README.md +``` + +## Customization + +### Change CMS Block Identifier + +To use a different CMS block, modify the `cms_block_id` argument in `view/frontend/layout/catalog_product_view.xml`: + +```xml +your_block_identifier +``` + +### Styling + +The message is wrapped in a `
` element. Add custom CSS to your theme to style it: + +```css +.free-shipping-message { + margin-top: 15px; + padding: 10px; + background-color: #f0f0f0; +} +``` + +## Requirements + +- Magento 2.3.x or higher +- PHP 7.3 or higher + +## License + +Proprietary + +## Support + +For support, contact Shopkeeper development team. diff --git a/etc/module.xml b/etc/module.xml new file mode 100644 index 0000000..a77ef36 --- /dev/null +++ b/etc/module.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/registration.php b/registration.php new file mode 100644 index 0000000..a5fdbaf --- /dev/null +++ b/registration.php @@ -0,0 +1,10 @@ + + + + + + + + free_shipping_message + + + + + diff --git a/view/frontend/templates/product/view/message.phtml b/view/frontend/templates/product/view/message.phtml new file mode 100644 index 0000000..f66160d --- /dev/null +++ b/view/frontend/templates/product/view/message.phtml @@ -0,0 +1,10 @@ + +hasCmsBlock()): ?> +
+ getCmsBlockHtml() ?> +
+