3
  1. I have a product with a custom option DateTime filed in product options Screenshot from 2020年10月07日 16-59-54
  2. 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',
 )
 ),
 ),
 ),
 ),
);
  1. 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"}]}}}"

  1. 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

asked Oct 8, 2020 at 3:30

1 Answer 1

0

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 :)

answered Oct 9, 2020 at 10:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.