Skip to content

Instantly share code, notes, and snippets.

@M4hd1BD
Last active April 15, 2024 09:22
Show Gist options
  • Save M4hd1BD/91f80381f676a4d37e5955a07e149724 to your computer and use it in GitHub Desktop.
Save M4hd1BD/91f80381f676a4d37e5955a07e149724 to your computer and use it in GitHub Desktop.

Steps

  1. First prepare the data in the below format, note that the first one, Monday, is multi-slot and rest of them are single slot. So follow that for multi-slot.
{
    "monday" : {
        "enable" : "enable",
        "start" : {
                    "0" : "0:45",
                    "1" : "1:45"
                },
        "close" : {
                    "0" : "06:45",
                    "1" : "7:45"
                }
    },
    "tuesday" : {
        "enable" : "enable",
        "start" : "01:00",
        "close" : "01:30"
    },
    "wednesday" : {
        "enable": "enable",
        "start" : "01:00",
        "close" : "01:30"
    },
    "thursday" : {
        "enable": "enable",
        "start" : "01:00",
        "close" : "01:30"
    },
    "friday" : {
        "enable": "enable",
        "start" : "01:00",
        "close" : "01:30"
    },
    "saturday" : {
        "enable": "enable",
        "start" : "01:00",
        "close" : "01:30"
    },
    "sunday" : {
        "enable" : "enable",
        "start" : "01:00",
        "close" : "01:30"
    }
}
  1. Then serialize this data, you can use this tool: https://duzun.me/playground/serialize
  2. After serilization is done, you'll have to replace the double quotes using sinlge quotes, you can use this tool: http://www.unit-conversion.info/texttools/replace-text/ Replace quotes
  3. Insert the data you got from the previous step to your CSV.
  4. Then you'll have to insert this code into your themes functions.php, or if you're using any Code Snippet plugin, you can use that too:
add_action('init', function(){
	$tools = ATBDP()->tools;
	$tools->importable_fields['bdbh'] = "Business Hours";
});
  1. Finally just upload the CSV and map the fields accordingly and you should be good to go.
@flossyfaysal
Copy link

Superb

@rashed1995
Copy link

Top notch

@richardaubin
Copy link

A couple of questions...

  1. How do you setup a day and mark it as closed
  2. How do you mark a day as open 24/7
  3. How do you mark all days as open 24/7

@M4hd1BD
Copy link
Author

M4hd1BD commented Sep 14, 2022

Hi @richardaubin,

  1. Just don't include the 'enable': 'enable' property and it'll be treated as closed.
  2. Keep the start and close property empty (empty string) and add another property like this: 'remain_close': 'open'.
  3. Refer to #2, do this for all the days.

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