The ShopBite plugin offers a powerful business hours management system, specifically designed for gastronomy and retail businesses. This chapter explains the detailed configuration and management of business hours.
The business hours system enables:
CREATE TABLE `shopbite_business_hour` (
`id` BINARY(16) NOT NULL,
`day_of_week` INT(11) NOT NULL, -- 0=Sunday, 1=Monday, ..., 6=Saturday
`opening_time` VARCHAR(5) NOT NULL, -- Format: HH:MM
`closing_time` VARCHAR(5) NOT NULL, -- Format: HH:MM
`sales_channel_id` BINARY(16) NOT NULL,
`created_at` DATETIME(3) NOT NULL,
`updated_at` DATETIME(3) NULL,
PRIMARY KEY (`id`),
CONSTRAINT `fk.shopbite_business_hour.sales_channel_id`
FOREIGN KEY (`sales_channel_id`)
REFERENCES `sales_channel` (`id`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
| Field | Type | Description | Example |
|---|---|---|---|
| Sales Channel | Dropdown | Select sales channel | "My Restaurant" |
| Day of Week | Dropdown | Day of the week (0-6) | 1 (Monday) |
| Opening Time | Time picker | Opening time | 11:00 |
| Closing Time | Time picker | Closing time | 22:00 |
| Closed | Checkbox | Mark day as closed | ✓ |
GET /store-api/shopbite/business-hour
| Parameter | Type | Description | Example |
|---|---|---|---|
sales-channel-id | UUID | Filter by Sales Channel | 019a36f224b0704fb6835914050392f4 |
include-closed | Boolean | Include closed days | true |
curl -X GET "https://your-shopware-domain.com/store-api/shopbite/business-hour" \
-H "Authorization: Bearer YourAPIToken" \
-H "sw-access-key: YourAccessKey" \
-H "Accept: application/json"
{
"apiAlias": "shopbite_business_hour",
"data": [
{
"id": "019a36f224b0704fb6835914050392f4",
"dayOfWeek": 1,
"openingTime": "11:00",
"closingTime": "22:00",
"salesChannelId": "019a36f224b0704fb6835914050392f4",
"createdAt": "2024-01-11T14:30:00+01:00",
"updatedAt": "2024-01-11T14:30:00+01:00",
"salesChannel": {
"id": "019a36f224b0704fb6835914050392f4",
"name": "My Restaurant",
"typeId": "019a36f224b0704fb6835914050392f4"
}
},
{
"id": "019a36f224b0704fb6835914050392f5",
"dayOfWeek": 2,
"openingTime": "11:00",
"closingTime": "22:00",
"salesChannelId": "019a36f224b0704fb6835914050392f4",
"createdAt": "2024-01-11T14:30:00+01:00",
"updatedAt": "2024-01-11T14:30:00+01:00",
"salesChannel": {
"id": "019a36f224b0704fb6835914050392f4",
"name": "My Restaurant",
"typeId": "019a36f224b0704fb6835914050392f4"
}
}
],
"total": 7
}
| Status Code | Meaning | Solution |
|---|---|---|
| 200 | Success | Data successfully retrieved |
| 401 | Unauthorized | Check API credentials |
| 403 | Forbidden | Check permissions |
| 404 | Not Found | Endpoint or Sales Channel not found |
| 500 | Internal Server Error | Check server logs |
Special opening hours are stored in the same table, but with a special flag:
-- Special opening hours are stored as separate entries
-- with a special date instead of day of the week
ALTER TABLE `shopbite_business_hour`
ADD COLUMN `special_date` DATE NULL AFTER `day_of_week`;
| Field | Type | Description | Example |
|---|---|---|---|
| Sales Channel | Dropdown | Select sales channel | "My Restaurant" |
| Date | Date picker | Date of special opening | 2024-12-24 |
| Opening Time | Time picker | Special opening time | 10:00 |
| Closing Time | Time picker | Special closing time | 14:00 |
| Description | Text | Optional description | "Christmas Eve - shortened opening hours" |
curl -X GET "https://your-shopware-domain.com/store-api/shopbite/business-hour?special=true" \
-H "Authorization: Bearer YourAPIToken" \
-H "sw-access-key: YourAccessKey"
-- Indexes for better performance
CREATE INDEX `idx_sales_channel` ON `shopbite_business_hour` (`sales_channel_id`);
CREATE INDEX `idx_day_of_week` ON `shopbite_business_hour` (`day_of_week`);
-- For special opening hours
CREATE INDEX `idx_special_date` ON `shopbite_business_hour` (`special_date`);
# In config/packages/cache.yaml
framework:
cache:
pools:
shopbite.business_hours:
adapter: cache.adapter.redis
default_lifetime: 3600 # 1 hour cache
// Fetch business hours
async function fetchBusinessHours(salesChannelId) {
const response = await fetch(
`/store-api/shopbite/business-hour?sales-channel-id=${salesChannelId}`,
{
headers: {
'Authorization': `Bearer ${apiToken}`,
'sw-access-key': accessKey
}
}
);
if (!response.ok) {
throw new Error('Failed to fetch business hours');
}
return await response.json();
}
// Display business hours
function displayBusinessHours(hours) {
const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
hours.data.forEach(hour => {
const dayName = days[hour.dayOfWeek];
console.log(`${dayName}: ${hour.openingTime} - ${hour.closingTime}`);
});
}
// Example call
fetchBusinessHours('019a36f224b0704fb6835914050392f4')
.then(displayBusinessHours)
.catch(console.error);
<template>
<div class="business-hours">
<h3>Opening Hours</h3>
<div v-for="hour in businessHours" :key="hour.id" class="hour-item">
<span class="day">{{ getDayName(hour.dayOfWeek) }}</span>
<span class="time">{{ hour.openingTime }} - {{ hour.closingTime }}</span>
</div>
</div>
</template>
<script>
export default {
data() {
return {
businessHours: [],
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
};
},
async mounted() {
await this.fetchBusinessHours();
},
methods: {
getDayName(dayOfWeek) {
return this.days[dayOfWeek];
},
async fetchBusinessHours() {
try {
const response = await this.$axios.get('/store-api/shopbite/business-hour');
this.businessHours = response.data.data;
} catch (error) {
console.error('Failed to fetch business hours:', error);
}
}
}
};
</script>
<style scoped>
.business-hours {
margin: 20px 0;
padding: 15px;
background: #f5f5f5;
border-radius: 8px;
}
.hour-item {
display: flex;
justify-content: space-between;
padding: 8px 0;
border-bottom: 1px solid #ddd;
}
.day {
font-weight: bold;
}
.time {
color: #666;
}
</style>
Causes:
Solutions:
# Clear cache
bin/console cache:clear
# Check database
mysql -u shopware -p shopware -e "SELECT * FROM shopbite_business_hour;"
# Check Sales Channel ID
bin/console sales-channel:list
Causes:
Solutions:
# Check database
mysql -u shopware -p shopware -e "SELECT COUNT(*) FROM shopbite_business_hour;"
# Check API permissions
bin/console integration:list
# API test
curl -X GET "https://your-domain.com/store-api/shopbite/business-hour" -H "Authorization: Bearer YourToken"
Causes:
Solutions:
# Check time format
mysql -u shopware -p shopware -e "SELECT opening_time, closing_time FROM shopbite_business_hour LIMIT 5;"
# Check time zone
bin/console config:get Shopware.Core.SystemConfig.timezone