Jump to content

API addorder with configoptions


Recommended Posts

I am having difficulties creating orders with ConfigOptions.

Does anyone know what actually needs to be passed in? I'm assuming the IDs of the options, but that doesn't seem to do anything, and the documentation is not very informative on this particular parameter..

 

It's creating the Product itself, but it's not adding the additional configurable options, so the products/invoices are wrong.

Edited by martynnorman
Link to comment
Share on other sites

  • 2 months later...

If anyone is wondering how to do it in .net - here's basically how I did it....

 

This formats the .net name-value-pair arrays into the php formatting for base64 encoding.

 

 

NameValueCollection httpParam = new NameValueCollection();

Dictionary<string, string> configOption = new Dictionary<string, string>();

configOption.Add(strAddonId, strAddonOptionId);

 

byte[] bytes = Encoding.UTF8.GetBytes(phpStringArray(configOption));

string base64String = Convert.ToBase64String(bytes);

httpParam.Add("configoptions", base64String);

 

 

public static string phpStringArray(Dictionary<string, string> arr)

{

StringBuilder sb = new StringBuilder("a:")

.Append(arr.Count).Append(":{");

 

foreach (string key in arr.Keys)

{

sb.AppendFormat("s:{0}:\"{1}\";s:{2}:\"{3}\";",

key.Length, key, arr[key].Length, arr[key]);

}

 

return sb.Append('}').ToString();

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated