Jump to content

How to add multiple item orders through the API?


Hutts

Recommended Posts

Having a problem getting multiple orders on one invoice. Need to query entries from a database and add them to an order through the api. Tried this code

 

$i = 0;
while ($r=odbc_fetch_array($results))
{
 $postfields['pid[$i]'] = $r['pid'];
 $postfields['billingcycle[$i]'] = 'onetime';
 $i++;
 }

 

However this code only enters 1 item when there should be multiple. Manually entering $postfields['pid[0]'] = ....$postfields['pid[1]'] = .....does add the multiple orders. I need to do this dynamically tho seeing i have no idea exactly how many items. Tried a couple of different ways to set the $postfields[XXX] variables name but can't seem to get it to work. Any thoughts?

Link to comment
Share on other sites

Not sure if this is some funky bug or i'm doing something wrong ?

 

Tried this

 

for ($i = 0; $i <= 2; $i++)
	  {
	    $postfields['pid[$i]'] = 14 + $i;
		echo "postfields[$i]=";
		echo $postfields['pid[$i]'];
		echo ";";
		}
	  #$a = 3;
	  #$b = 4;
	  #$c = 5;
	  #$postfields['pid[$a]'] = 14;
	  #echo "postfields[$a]=";
	  #echo $postfields['pid[$a]'];
	  #echo ";";
	  #$postfields['pid[$b]'] = 15;
	  #echo "postfields[$b]=";
	  #echo $postfields['pid[$b]'];
	  #echo ";";
	  #$postfields['pid[$c]'] = 16;
	  #echo "postfields[$c]=";
	  #echo $postfields['pid[$c]'];
	  #echo ";";
                 ........
                 echo($data);

 

Returns 1 item ordered

 

postfields[0]=14;postfields[1]=15;postfields[2]=16;result=success;orderid=230;invoiceid=178;productids=240;addonids=;domainids=;

 

Uncomment the above lines and the following gets returned (4 items)

 

postfields[0]=14;postfields[1]=15;postfields[2]=16;postfields[3]=14;postfields[4]=15;postfields[5]=16;result=success;orderid=231;invoiceid=179;productids=241,242,243,244;addonids=;domainids=;

 

Seems for some reason the api isn't getting the data assigned in the loop?

Edited by Hutts
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