Cookies setting

Cookies help us enhance your experience on our site by storing information about your preferences and interactions. You can customize your cookie settings by choosing which cookies to allow. Please note that disabling certain cookies might impact the functionality and features of our services, such as personalized content and suggestions. Cookie Policy

Cookie Policy
Essential cookies

These cookies are strictly necessary for the site to work and may not be disabled.

Information
Always enabled
Advertising cookies

Advertising cookies deliver ads relevant to your interests, limit ad frequency, and measure ad effectiveness.

Information
Analytics cookies

Analytics cookies collect information and report website usage statistics without personally identifying individual visitors to Google.

Information
mageplaza.com

How to Setup Special Price in Magento 2

Vinh Jacker | 04-19-2016

How to Setup Special Price

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

How to Setup Special Price on Catalog Page

  • On the product page

How to Setup Special Price on Product Page

Related topics

How to Setup Special Price in Magento 2

Step 1: Navigate to Catalog > Products

Navigate to product list

Step 2: Click on the product that you want to apply advanced pricing.

Choose a product

Step 3: Click on Advanced Pricing under the Price field.

Advanced Pricing

Step 4: After clicking on Advanced Pricing, a side panel will appear so that you can set up the product prices.

Advanced Pricing config

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 the calendar 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.

x
    Jacker

    With over a decade of experience crafting innovative tech solutions for ecommerce businesses built on Magento, Jacker is the mastermind behind our secure and well-functioned extensions. With his expertise in building user-friendly interfaces and robust back-end systems, Mageplaza was able to deliver exceptional Magento solutions and services for over 122K+ customers around the world.



    Related Post

    Website Support
    & Maintenance Services

    Make sure your store is not only in good shape but also thriving with a professional team yet at an affordable price.

    Get Started
    mageplaza services