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

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.