vue-storefront-1 icon indicating copy to clipboard operation
vue-storefront-1 copied to clipboard

Improve the cart product.product_option format

Open pkarw opened this issue 6 years ago • 3 comments

What is the motivation for adding / enhancing this feature?

We're using the product.product_option to provide the backend with the selected product options. Here you have the code which is setting the options right now.

Let's simplify it from:

{  
   "cartItem":{  
      "sku":"WS05",
      "qty":1,
      "product_option":{  
         "extension_attributes":{  
            "custom_options":[  

            ],
            "configurable_item_options":[  
               {  
                  "option_id":"93",
                  "option_value":"56"
               },
               {  
                  "option_id":"142",
                  "option_value":"167"
               }
            ],
            "bundle_options":[  

            ]
         }
      },
      "quoteId":"587011"
   }
}

TO

{  
   "cartItem":{  
      "sku":"WS05",
      "qty":1,
      "option":{  
            "custom":[  

            ],
            "configurable":[  
               {  
                  "option_id":"93",
                  "option_value":"56"
               },
               {  
                  "option_id":"142",
                  "option_value":"167"
               }
            ],
            "bundle":[  

            ]
      },
      "quoteId":"587011"
   }
}

pkarw avatar Aug 20 '19 09:08 pkarw

In order to have it still compatible with Magento2 we need to change the new format to old one just before calling the vue-storefront-api endpoint OR change the vue-storefront-api endpoint input format and map the format inside the cart/update.

Please note: changing the API is not recommended as many platform connectors (m1, m2, epi-server ...) are using the old format.

Please note: by any change provided we must support the old format as well!

pkarw avatar Aug 20 '19 09:08 pkarw

ps. there is also an product.options property which is presenting the options as they appear to the user. Not sure about the naming :/

pkarw avatar Aug 20 '19 09:08 pkarw

Related to vuestorefront/vue-storefront-1#289

pkarw avatar Aug 20 '19 09:08 pkarw