- I have a product with a custom option DateTime filed in product options Screenshot from 2020年10月07日 16-59-54
- When I try to place an order using rest API. My order array is given below
$order = array (
'cartItem' =>
array (
'sku' => $product_sku,
'qty' => 1,
'quote_id' => $cart_id,
'product_option' =>
array (
'extension_attributes' =>
array (
'custom_options' =>
array (
0 =>
array (
'option_id' => '1',
'option_value' => '2020-10-15 13:00:00',
)
),
),
),
),
);
- My cart response is given below
"{"item_id":4,"sku":"Jessica Pant","qty":1,"name":"Jessica Pant","price":169,"product_type":"simple","quote_id":"3","product_option":{"extension_attributes":{"custom_options":[{"option_id":"1","option_value":"2020年10月16日 01:00:00"}]}}}"
- As you can see i have set custom option value(datetime) as '2020年10月15日 13:00:00' in code. But after execute add to cart API code. the date changed to "2020年10月16日 01:00:00"
Expected result (*)
"{"item_id":4,"sku":"Jessica Pant","qty":1,"name":"Jessica Pant","price":169,"product_type":"simple","quote_id":"3","product_option":{"extension_attributes":{"custom_options":[{"option_id":"1","option_value":"2020年10月15日 13:00:00"}]}}}"
Actual result (*)
"{"item_id":4,"sku":"Jessica Pant","qty":1,"name":"Jessica Pant","price":169,"product_type":"simple","quote_id":"3","product_option":{"extension_attributes":{"custom_options":[{"option_id":"1","option_value":"2020年10月16日 01:00:00"}]}}}"
My Magento ver. 2.3.4-p2
1 Answer 1
Finally, I have figured out the issue. Actually, it was not a core issue of magento2. The issue was related to a settings in catalog congiuration
stores > config > catalog > catalog > Date & Time Custom Options
My setting was 12h AM/PM
I changed it to 24h
Hope it will help someone :)
Explore related questions
See similar questions with these tags.