Jump to content

Recommended Posts

I want to add another item to the order_lines array but however I do it I end up with an error:

$data = [
	'purchase_country'=>$company_country,
	'purchase_currency'=>$currency_nm,
	'order_amount'=>$api_amount,
	'locale'=>"en-GB",
	'order_tax_amount'=>0,
	'order_lines'=>[
		[
			'name'=>$product_name,
			'quantity'=>1,
			'unit_price'=>$api_amount,
			'tax_rate'=>0,
			'total_amount'=>$api_amount,
			'total_tax_amount'=>0
		]
	],
    "intent"=>"buy"
];

I thought this would work:

	'order_lines'=>[
		[
			'name'=>$product_name,
			'quantity'=>1,
			'unit_price'=>$api_amount,
			'tax_rate'=>0,
			'total_amount'=>$api_amount,
			'total_tax_amount'=>0
		],
        [
			'name'=>$product_name2,
			'quantity'=>1,
			'unit_price'=>$api_amount2,
			'tax_rate'=>0,
			'total_amount'=>$api_amount2,
			'total_tax_amount'=>0
		]
	],
    "intent"=>"buy"
];

Any ideas please?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/315959-how-should-this-array-be-formatted/
Share on other sites

You are storing calculated items in your array elements.  That is not necessary when you have the details of the calc already present.

How about these lines:

    'order_lines'=>
    [
    [
        'name'=>$product_name,
        'quantity'=>1,
        'unit_price'=>$api_amount,
        'tax_rate'=>0,
        'total_amount'=>$api_amount,
        'total_tax_amount'=>0
    ]
    ],

You have an element with no key

And - why an array and not a db?

Edited by ginerjm
This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.