This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Esun_FreeGift::config"
title="eSUN Automatic Free Gift Configuration"
sortOrder="95"/>
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
@@ -0,0 +1,69 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="esun" translate="label" sortOrder="300">
<label>Esun</label>
</tab>
<section id="esun_free_gift" translate="label" type="text" sortOrder="940"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>Automatic Free Gift</label>
<tab>esun</tab>
<resource>Esun_FreeGift::config</resource>
<group id="general" translate="label" type="text" sortOrder="10"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>General</label>
<field id="enabled" translate="label comment" type="select" sortOrder="10"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>esun_free_gift/general/enabled</config_path>
</field>
<field id="gift_sku" translate="label comment" type="text" sortOrder="20"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>Gift Product SKU</label>
<comment>The product must be an enabled simple product assigned to this website. Set Manage Stock to No and Visibility to Not Visible Individually.</comment>
<validate>required-entry</validate>
<config_path>esun_free_gift/general/gift_sku</config_path>
<depends>
<field id="enabled">1</field>
</depends>
</field>
<field id="start_date" translate="label comment" type="date" sortOrder="30"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>Start Date</label>
<comment>Leave empty to start immediately.</comment>
<frontend_model>Esun\FreeGift\Block\Adminhtml\System\Config\Form\Field\Date</frontend_model>
<config_path>esun_free_gift/general/start_date</config_path>
<depends>
<field id="enabled">1</field>
</depends>
</field>
<field id="end_date" translate="label comment" type="date" sortOrder="40"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>End Date</label>
<comment>Leave empty for no end date.</comment>
<frontend_model>Esun\FreeGift\Block\Adminhtml\System\Config\Form\Field\Date</frontend_model>
<config_path>esun_free_gift/general/end_date</config_path>
<depends>
<field id="enabled">1</field>
</depends>
</field>
<group id="tiers" translate="label" type="text" sortOrder="50"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>Gift Tiers</label>
<field id="items" translate="label comment" sortOrder="10"
showInDefault="1" showInWebsite="1" showInStore="0">
<label>Tier Items</label>
<frontend_model>Esun\FreeGift\Block\Adminhtml\System\Config\Form\Field\TierItems</frontend_model>
<backend_model>Esun\FreeGift\Model\Config\Backend\TierItems</backend_model>
<comment>Compared with the base subtotal after discounts, excluding tax, shipping and gift items. Tiers are evaluated from the highest amount down.</comment>
<config_path>esun_free_gift/tiers/items</config_path>
</field>
</group>
</group>
</section>
</system>
</config>
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<esun_free_gift>
<general>
<enabled>0</enabled>
<gift_sku></gift_sku>
<start_date></start_date>
<end_date></end_date>
</general>
<tiers>
<tier_1_amount>199</tier_1_amount>
<tier_1_qty>1</tier_1_qty>
<tier_2_amount>299</tier_2_amount>
<tier_2_qty>2</tier_2_qty>
<tier_3_amount>399</tier_3_amount>
<tier_3_qty>3</tier_3_qty>
</tiers>
</esun_free_gift>
</default>
</config>
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="quote_item" resource="checkout" engine="innodb" comment="Sales Flat Quote Item">
<column xsi:type="smallint"
name="is_esun_free_gift"
unsigned="true"
nullable="false"
default="0"
comment="Is eSUN Automatic Free Gift"/>
</table>
<table name="sales_order_item" resource="sales" engine="innodb" comment="Sales Flat Order Item">
<column xsi:type="smallint"
name="is_esun_free_gift"
unsigned="true"
nullable="false"
default="0"
comment="Is eSUN Automatic Free Gift"/>
</table>
</schema>
@@ -0,0 +1,12 @@
{
"quote_item": {
"column": {
"is_esun_free_gift": true
}
},
"sales_order_item": {
"column": {
"is_esun_free_gift": true
}
}
}
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Quote\Model\Quote">
<plugin name="esun_free_gift_block_external_add"
type="Esun\FreeGift\Plugin\Quote\AddProductPlugin"
sortOrder="10"/>
</type>
<type name="Magento\Quote\Model\Quote\TotalsCollector">
<plugin name="esun_free_gift_sync_during_totals"
type="Esun\FreeGift\Plugin\Quote\TotalsCollectorPlugin"
sortOrder="100"/>
</type>
</config>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_model_service_quote_submit_before">
<observer name="esun_free_gift_validate_before_submit"
instance="Esun\FreeGift\Observer\ValidateGiftBeforeSubmit"/>
</event>
</config>
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Object/etc/fieldset.xsd">
<scope id="global">
<fieldset id="sales_convert_quote_item">
<field name="is_esun_free_gift">
<aspect name="to_order_item"/>
</field>
</fieldset>
</scope>
</config>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Checkout\CustomerData\Cart">
<plugin name="esun_free_gift_customer_data"
type="Esun\FreeGift\Plugin\CustomerData\CartPlugin"
sortOrder="10000"/>
</type>
</config>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Esun_FreeGift">
<sequence>
<module name="Magento_Catalog"/>
<module name="Magento_Checkout"/>
<module name="Magento_Quote"/>
<module name="Magento_Sales"/>
<module name="Esun_Cart"/>
</sequence>
</module>
</config>