HotcakesCommerce / hotcakes-commerce-core

The core of the e-commerce part of the overall solution. This is an ecommerce shopping cart solution built on top of the DNN (DotNetNuke) CMS. Anyone can do commerce online now!
https://mmmcommerce.com
MIT License
68 stars 55 forks source link

SI: Allow store owners to "close" the store #387

Open WillStrohl opened 2 years ago

WillStrohl commented 2 years ago

Is your feature request related to a problem?

Hotcakes Support Request: 8445

There may be occasions when a store owner might want to permanently or temporarily allow the store to still exist, but have it functionally be closed.

Examples could include:

There are plenty more examples, for sure.

Describe the solution you'd like

Add a setting to the Superuser Settings area that is a checkbox. This checkbox will toggle whether the store is open or closed.

When the store is closed a value will be added to the hcc_StoreSettings table.

There is already code in the MVC controllers to look for and add the store closed setting to the ViewBag for views to see and work with.

var blnIsStoreClosed = ViewBag["StoreClosed"]; // should be boolean  

The database and server-side API are all fully aware of this setting. It's a first-class property in the StoreSettings class.

var blnIsStoreClosed = HccApp.CurrentStore.Settings.StoreClosed; // should be boolean  

When the store is closed:

As with any other update, anything facing a customer will be localized, so different languages and text values can be displayed, depending on the desires of the respective store owner.

Describe alternatives you've considered

Updating the database manually, and then customizing all of the viewset cshtml files that visitors can see.

Additional context

There is already underlying infrastructure to allow this to happen without updates to Hotcakes Commerce itself, but it requires direct access to the database and updates to many of the viewset UI files.

If someone wants to do this today, it's already possible but requires some development work.

First, run the query below.

/*

    CLOSE/OPEN Hotcakes Commerce store online.  

    Instructions:  

    1. Update the variable below as desired. 
    2. Execute the script against the site. 
    3. Restart the site or clear the site cache. 
*/

--   Open: False 
-- Closed: True 

DECLARE @IsClosed NVARCHAR(100) = N'True'; -- UPDATE THIS IF YOU NEED TO

-- Do NOTHING past this line
SELECT * FROM [dbo].[hcc_StoreSettings] WHERE [SettingName] = N'StoreClosed';
IF NOT EXISTS(SELECT 1 FROM [dbo].[hcc_StoreSettings] WHERE [SettingName] = N'StoreClosed' AND [StoreId] = 1) 
BEGIN 
    INSERT INTO [dbo].[hcc_StoreSettings] (
        [StoreId], 
        [SettingName], 
        [SettingValue]
    ) 
    VALUES (
        1, 
        N'StoreClosed', 
        @IsClosed
    );
END 
ELSE
BEGIN 
    UPDATE [dbo].[hcc_StoreSettings] SET [SettingValue] = @IsClosed WHERE [SettingName] =  N'StoreClosed' AND [StoreId] = 1; 
END 
SELECT * FROM [dbo].[hcc_StoreSettings] WHERE [SettingName] = N'StoreClosed';

Next, update each of the front-facing views to show/hide features and UI as desired using the setting as described previously.

Whenever you open or close the store, the website will need to be restarted to clear the cache and see the change take effect.