, (*1)
Add the module to your composer.json
composer require experius/module-donationproduct "~1.0.0"
, (*2)
Run the Magento Setup Upgrade
bin/magento setup:upgrade
, (*3)
Install Sample Data (optional), (*4)
A number of international charities will be created for testing purposes, (*5)
(Oxfam, Greenpeace, Save the Children, Amnesty International, World Wildlife Fund), (*6)
bin/magento experius_donationproduct:sampledata:deploy
, (*7)
Remove Sample Data (optional), (*8)
bin/magento experius_donationproduct:sampledata:remove
, (*9)
The donation products can be viewed on several standard locations in your Magento 2 webshop - Homepage - Sidebar - Cart - Checkout, (*10)
Off course it is possible to implement this block on any location by a Magento frontend developer. Or in a cms of category layout update via the Magento Admin. Xml example is provided in the 'Full Size Block' chapter., (*11)
When clicked on a charity of the customers choice a popup will open with the charities details and a add to cart button., (*12)
You can also create a regular category with all the donation products with a regular product detail page., (*13)
A "Donation Product" has a lot in common with a "Virtual Product". It has no stock, weight and doesn't need a shipping method or address to be set in the checkout., (*14)
, (*15)
, (*16)
To view the donation products in a category (just like the screenshot below). Create a category in the Magento Admin and add the donation products to that category., (*17)
, (*18)
This block wil be visible on every page wich has a layout with a sidebar implemented. It can be disabled in the settings. See settings chapter., (*19)
, (*20)
The full size block is visible on the homepage. It can be disabled in the settings. See settings chapter., (*21)
, (*22)
<referenceContainer name="content"> <block class="Experius\DonationProduct\Block\Donation\ListProduct" name="donation.block" after="-" template="Experius_DonationProduct::donation.phtml"/> </referenceContainer>
The checkout donation block is visible in the checkout totals block. It can be disabled in the settings. See settings chapter., (*23)
, (*24)
The cart page donation block is visible on the cart page. It can be disabled in the settings. See settings chapter., (*25)
, (*26)
Add a new product with type 'Donation Product', (*27)
, (*28)
You can configure the minimum donation amount., (*29)
, (*30)
Reports > Sales > Donations, (*31)
A report table is made to store every single "Donation Product" sale. You can make an export, sum up the amount per charity and transfer the money., (*32)
, (*33)
, (*34)
Stores > Settings > Configuration > Catalog > Donation Product, (*35)
There is a setting to enable or disable the complete module. There are settings to enable and disable the visibility of blocks on several locations in your webshop., (*36)
, (*37)
Follow the step below to uninstall the module., (*38)
bin/magento module:uninstall Experius_DonationProduct
Can i combine the 'Donation product options' with 'Custom options / Customizable Options'?, (*39)
Although its not supported, it can be done! You have change the following template by overwriting it with your own custom template version. vendor/magento/module-catalog/view/frontend/templates/product/view/form.phtml. You probaly have to hide or remove a duplicate addtocart button, (*40)
The donation product uses the 'product_info_form_content' container. This is only rendered when no 'Custom options' are found., (*41)
<?php if (!$block->hasOptions()):?> <?= $block->getChildHtml('product_info_form_content') ?> <?php else:?> <?php if ($_product->isSaleable() && $block->getOptionsContainer() == 'container1'):?> <?= $block->getChildChildHtml('options_container') ?> <?php endif;?> <?php endif; ?>
If you want to render both 'Custom options' and 'Donation options'. Change the if statement., (*42)
<?php if (!$block->hasOptions() || $_product->getTypeId()=='donation'):?> <?= $block->getChildHtml('product_info_form_content') ?> <?php else:?> <?php if ($_product->isSaleable() && $block->getOptionsContainer() == 'container1'):?> <?= $block->getChildChildHtml('options_container') ?> <?php endif;?> <?php endif; ?>