With a big catalog of 224+ extensions for your online store
How to Setup Special Price in Magento 2
Special Price is called a promotional campaign you will give to shoppers within an exact time. The special price is shown both on the catalog page and product detail page while the ordinary price is grayed out, both of them are linked by word “was” like $30.00 was $36.00.
Learn more: How to set up good prices when buying more products with Magento 2 quantity increments extension
From Magento 2 settings, you can get the special price configuration in the Advanced Settings of the individual product. Then you only need to enter the number for the discounted price and the active time to apply. As you configure, the special price is applied immediately.
Special Price can be used as an effective FOMO call to action, as it brings an exciting offer for hesitant customers. This tutorial will show you steps to set up the special price on both the catalog page and product page:
- On the catalog page
- On the product page
Related topics
- How to Setup Tier Price
- How to Configure Minimum Advertised Price (MAP)
- How to Configure Price Filter - Price Navigation
- How to create Configurable Product
- How to Add a New CMS Page
How to Setup Special Price in Magento 2
Step 1: Navigate to Catalog > Products
Step 2: Click on the product that you want to apply advanced pricing.
Step 3: Click on Advanced Pricing
under the Price
field.
Step 4: After clicking on Advanced Pricing
, a side panel will appear so that you can set up the product prices.
Step 5: Fill in the requirement fields.
- Special Price: Insert the discounted price you would like to offer.
- Special Price From/ To: Select the effective duration to apply this offer. There are 2 ways to select the time: typing with the format
MM/DD/YY
or clicking on thecalendar
to choose. - Cost: Enter the regular price of that product.
After that, press Done
to complete the changes.
How to Configure Special Prices in Magento 2 programmatically?
Here is the Sample Code:
<?php
namespace YourVendor\YourModule\Model;
use Exception;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Api\SpecialPriceInterface;
use Magento\Catalog\Api\Data\SpecialPriceInterfaceFactory;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
class UpdateSpecialPrice
{
/**
* @var SpecialPriceInterface
*/
private $specialPrice;
/**
* @var SpecialPriceInterfaceFactory
*/
private $specialPriceFactory;
/**
* @var TimezoneInterface
*/
protected $timezone;
/**
* UpdateSpecialPrice constructor.
* @param SpecialPriceInterface $specialPrice
* @param SpecialPriceInterfaceFactory $specialPriceFactory
* @param TimezoneInterface $timezone
*/
public function __construct(
SpecialPriceInterface $specialPrice,
SpecialPriceInterfaceFactory $specialPriceFactory,
TimezoneInterface $timezone
)
{
$this->specialPrice = $specialPrice;
$this->specialPriceFactory = $specialPriceFactory;
$this->timezone = $timezone;
}
/**
* @param Product $product
* @return bool
* @throws Exception
*/
public function getSpecialPriceData(Product $product)
{
$sku = $product->getSku();
$storeId = $product->getStoreId();
$yourSpecialPrice = 10.99; //(float) Special price value
try {
$dateFrom = '2021-07-01'; // future date to current date
$dateTo = '2021-07-25'; // future date to price from
$specialPriceFrom = $this->timezone->date($dateFrom)->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT); //(string) Special price from date value in Y-m-d H:i:s format in UTC
$specialPriceTo = $this->timezone->date($dateTo)->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT); //(string) Special price to date value in Y-m-d H:i:s format in UTC.
$prices = $this->specialPriceFactory->create();
$prices->setSku($sku)
->setStoreId($storeId)
->setPrice($yourSpecialPrice)
->setPriceFrom($specialPriceFrom)
->setPriceTo($specialPriceTo);
$specialProduct = $this->specialPrice->update($prices);
} catch (Exception $exception) {
throw new Exception($exception->getMessage());
}
return $specialProduct;
}
}
Let’s try and you will see the result!
Final words
Special Price in Magento 2 enables you to create exclusive discounts for your products in a certain time period. It helps enormously by using FOMO as a way to urge people to act immediately. Setting up a Special Price in Magento 2 only requires a few steps as above, so you can do it easily. After setting it up, you can expect more product views and greater sales. All questions are welcomed, so please write yours in the comment section.
Looking for Magento Development Company?
8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.
Get free consultantRecent Tutorials
How to insert Order Attributes to Transactional Emails
How to insert Order Attributes to Transactional Emails
How to add Order Attributes to PDF Order Template
Explore Our Products:
People also searched for
- magento 2 special price
- special price magento 2
- magento special price
- magento 2 set special price
- magento2 special price
- special price in magento 2
- magento 2 sale price
- special price
- get special price magento 2
- how to set special price for configurable products in magento 2
- magento 2 get special price
- magento 2 special price not showing
- magento 2 special price configurable product
- special price in magento
- magento 2 development in cheap rate
- spesial price
- magento 2 configurable product special price
- special price magento
- magento 2 product discount
- magento 2 price types
- magento 2 remove special price
- magento 2 get product special price
- 2.3.x, 2.4.x
Stay in the know
Get special offers on the latest news from Mageplaza.
Earn $10 in reward now!