0

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.

2 Answers 2

2

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

1

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);
        }  
    }       
  
}
4
  • Yes I know that we dont have this functionality by default we need to create module. If you have any idea please share your thoughts. Commented Feb 10, 2021 at 11:04
  • This solution for Magento 1 might be useful stackoverflow.com/questions/14472070/…
    – paj
    Commented Feb 10, 2021 at 11:08
  • I checked that already but its for m1. I want it for m2 Commented Feb 10, 2021 at 11:12
  • yes it's M1 but the principal is the same and should be enough info there to get you started on a solution for M2 have updated my answer with pseudo code...
    – paj
    Commented Feb 10, 2021 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.