Jump to content

AddOrder configoptions not working.


Recommended Posts

Hello,

Why addorder configoptions not working. i have also done base64encoding in configoption like this.

curl -X POST \
  https://myhost.com/includes/api.php \
  -H 'Content-Type: application/json' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F username=username \
  -F password=password\
  -F responsetype=json \
  -F action=AddOrder \
  -F clientid=293 \
  -F paymentmethod=tco \
  -F 'pid[0]=1' \
  -F 'billingcycle[0]=semiannually' \
  -F 'configoptions=[YToxOntpOjI7aToyO30=, YToxOntpOjEwO2k6MjE7fQ==]' \
  -F promooverride=false \
  -F currency=INR

Response is:

{
    "result": "success",
    "orderid": 778,
    "productids": "949",
    "addonids": "",
    "domainids": "",
    "invoiceid": 824
}

 

When i look in whmcs i can see that there is no changes in configoptions. It doesn't throw error if my configoptions is wrong.

Evertime the first options of configoptions are selected as you can see in attachment.

When i look in whmcs add order documentation: https://developers.whmcs.com/api-reference/addorder/

configoptions is send like this: array(base64_encode(serialize(array("2" => 2))), base64_encode(serialize(array("10" => 21)))); => ouput is  [YToxOntpOjI7aToyO30=, YToxOntpOjEwO2k6MjE7fQ==]

Please help me i am stuck into this problem for long time.

 

Thank you.

 

Screen Shot 2018-05-03 at 4.07.02 PM.png

Link to comment
Share on other sites

  • 1 year later...

You have passed like this :
configoptions is send like this: array(base64_encode(serialize(array("2" => 2))), base64_encode(serialize(array("10" => 21)))); => ouput is  [YToxOntpOjI7aToyO30=, YToxOntpOjEwO2k6MjE7fQ==]

But I have passed like this and its worked for me :

// Geting IDs for config options
$operating_system = ["2" => 2];
$cpanel_cloud_license = ["10" => 21];

// Config Options Array Merge for multiple config options
$configoptions_array_merge = $operating_system + $cpanel_cloud_license;

// Config Options Array Formatted for WHMCS API
$configoptions_array[] = base64_encode(serialize($configoptions_array_merge));

// Sending to API
'configoptions' => isset($configoptions_array) ? $configoptions_array : '',
 

MUST Remember :
Your Output is : 
[YToxOntpOjI7aToyO30=, YToxOntpOjEwO2k6MjE7fQ==]

But Correct Output will be only one always, doesn't matter how many arrays you have passed.


Correct Output will be : [YToxOntpOjI7aToyO30=]

Link to comment
Share on other sites

  • 1 year later...
On 3/28/2020 at 9:21 PM, Abdullah said:

You have passed like this :
configoptions is send like this: array(base64_encode(serialize(array("2" => 2))), base64_encode(serialize(array("10" => 21)))); => ouput is  [YToxOntpOjI7aToyO30=, YToxOntpOjEwO2k6MjE7fQ==]

But I have passed like this and its worked for me :

// Geting IDs for config options
$operating_system = ["2" => 2];
$cpanel_cloud_license = ["10" => 21];

// Config Options Array Merge for multiple config options
$configoptions_array_merge = $operating_system + $cpanel_cloud_license;

// Config Options Array Formatted for WHMCS API
$configoptions_array[] = base64_encode(serialize($configoptions_array_merge));

// Sending to API
'configoptions' => isset($configoptions_array) ? $configoptions_array : '',
 

MUST Remember :
Your Output is : 
[YToxOntpOjI7aToyO30=, YToxOntpOjEwO2k6MjE7fQ==]

But Correct Output will be only one always, doesn't matter how many arrays you have passed.


Correct Output will be : [YToxOntpOjI7aToyO30=]

This doenst work for quantity selection like a slider or text box

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