Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
WillStrohl opened this issue Jan 13, 2022 · 0 comments
Open

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

WillStrohl opened this issue Jan 13, 2022 · 0 comments

Comments

@WillStrohl
Copy link
Member

WillStrohl commented Jan 13, 2022

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:

  • Too many changes are required in a short timeframe. The store is closed temporarily to avoid undesired orders.
  • An API or integration is failing or otherwise needs updating. The store is closed to prevent errors and/or data issues.
  • A payment provider is broken or otherwise needs to be updated/replaced. The store is closed to prevent errors at checkout.

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.

  • SettingName: StoreClosed
  • SettingValue: True

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:

  • All catalog pages will continue to display products and categories.
  • Prices for products are all hidden.
  • Cart and Checkout will no longer function.
  • The REST API will no longer function. All requests should have an HTTP 404 response.
  • The store administration is still fully functional.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant