Hello I am working in Magento 2. I need to add two column in tier price "Date from" and "Date to" so that tier price will allow withing that date range.
How to add those filed in tier price row ?
Thanks in advance.
This is a module I wrote to implement a similar scenario, I haven't tested this thoroughly for all product types, there could be issues. If you find any, you could add a PR or post a comment.
This could be helpful to someone -> Tier Price custom from-to date range fields
An "out of the box" standard Magento 2 installation does not have the functionality to set date ranges for tier prices.
This functionality would need to be programmed in a custom module and tier pricing options changed using some date logic and custom attributes :
Create new product attributes and add them to the price group of your product attribute sets :
tierprice_to_date
tierprice_from_date
In the tier price templates for products add logic to check if the tier price should be displayed - pseudo code examples below...
template/product/price/tier_prices.phtml
if(date NOT between tierprice_from_date and tierprice_to_date){
return;
}
In a custom module use a plugin to remove tier pricing if required
<type name="Magento\Catalog\Model\Product">
<plugin name="after_final_price" type="Vendor\ModuleName\Plugin\ChangeTierPrice" sortOrder="999" disabled="false" />
</type>
namespace Vendor\ModuleName\Plugin;
class ChangeTierPrice
{
public function beforeGetFinalPrice($subject, $qty = null)
{
if(date NOT between tierprice_from_date and tierprice_to_date){
$finalTierPrice = [];
$subject->setData('tier_price', $finalTierPrice);
}
}
}