4

I'm adding a new order using WHMCS local API. Everything works fine except custom fields.

$command = 'AddOrder';
$postData = array(
    'clientid' => $client_id,
    'pid' => array($product_id),
    'billingcycle' => array('monthly'),
    'customfields' => array(base64_encode(serialize(array(1 => $site_id)))),
    'paymentmethod' => 'stripe',
);
return localAPI($command, $postData);

My custom field ID is 53 but I set the key to 1 because of tutorials. Also I tried 53 as key array(base64_encode(serialize(array(53 => $site_id)))) but nothing changed.

Do you have any suggestion?

Hossein
  • 2,592
  • 4
  • 23
  • 39
  • 1
    Try changing: array(base64_encode(serialize(array(53 => $site_id)))) to array(base64_encode(serialize(array(53 => 'My Custom Value')))) Do you see the new string in the product custom field? How you set $site_id variable? – wesamly Jul 02 '19 at 09:26
  • Iv found the same decision https://whmcs.community/topic/287645-addorder-configoptions-not-working/?tab=comments#comment-1295077 – Maksim Tikhonov Jul 05 '22 at 05:40

1 Answers1

-1

Try this:

 $command = 'AddOrder';
 $postData = array(
'clientid' => $client_id,
'pid' => array($product_id),
'billingcycle' => array('monthly'),
'customfields[0]' => array(base64_encode(serialize(array(1 =>     $site_id)))),//changes here
'paymentmethod' => 'stripe',
);
return localAPI($command, $postData);ode here