question

Rohit Bhardwaj avatar image
Rohit Bhardwaj asked zgreathouse Deactivated commented

How to update merchant store hours ?

Hi there,
I'm trying to update a merchant's store hours(business hours). I used
https://api.clover.com:443/v3/merchants/M5N7XSJ4YW..
to get the merchant's business hours. When I'm using the API documentation and trying to update the business hours, I get the same response every time which says "no content" with response code 0. I used the model schema which was given on the right side and filled in the data accordingly but the response was similar as above. I just want to know how can I update the business hours.
Thanks.
Merchant
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

zgreathouse avatar image
zgreathouse Deactivated answered
The endpoint you should use to update your Merchant's Opening Hours is
POST /v3/merchants/{mId}/opening_hours/{hId}

To get the hId for this endpoint, you can use GET /v3/merchants/{mId}/opening_hours and the hId is the value in the "id" field of the response.

Below is an Example Body for the update merchant opening hours endpoint:
{
     "name": "Opening hours",
     "sunday": {
          "elements": [
               {
                    "start": 1000,
                    "end": 1400
               }
          ]
     },
     "monday": {
          "elements": [
               {
                    "start": 900,
                    "end": 1700
               }
          ]
     },
     "tuesday": {
          "elements": [
               {
                    "start": 900,
                    "end": 1700
               }
          ]
     },
	"wednesday": {
          "elements": [
               {
                    "start": 900,
                    "end": 1700
               }
          ]
	},
     "thursday": {
          "elements": [
               {
                    "start": 900,
                    "end": 1700
               }
          ]
	},
     "friday": {
          "elements": [
               {
                    "start": 900,
                    "end": 1700
               }
          ]
     },
     "saturday": {
          "elements": [
               {
                    "start": 900,
                    "end": 2000
               }
          ]
     }
}
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Rohit Bhardwaj avatar image
Rohit Bhardwaj answered zgreathouse Deactivated commented
Hi @zgreathouse, thanks for your answer. It is working as expected on API docs. I have another concern with me regarding the POST using PHP. I'm stuck in the JSON here which I printed on web and it is as below,
Array(
[name] => Opening hours
[sunday] => Array
(
[elements] => Array
(
[start] => 1000
[end] => 2300
)
)
[monday] => Array
(
[elements] => Array
(
[start] => 0500
[end] => 2359
)
)
[tuesday] => Array
(
[elements] => Array
(
[start] => 1100
[end] => 2300
)
)
[wednesday] => Array
(
[elements] => Array
(
[start] => 0600
[end] => 2359
)
)
[thursday] => Array
(
[elements] => Array
(
[start] => 1200
[end] => 2300
)
)
[friday] => Array
(
[elements] => Array
(
[start] => 0800
[end] => 2301
)
)
[saturday] => Array
(
[elements] => Array
(
[start] => 1400
[end] => 2359
)
) )

with error response as, "{"message":"Invalid value in JSON"}".
Can you please help me out here in creating a JSON similar to the one you showed in your answer using PHP. It will be very helpful. Thank you.

1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

zgreathouse avatar image zgreathouse commented ·

I'm not a PHP user, but here is a link to a stack overflow question regarding conversion to JSON: https://stackoverflow.com/questions/34942737/convert-array-to-json-string-php

0 Likes 0 ·

Welcome to the
Clover Developer Community