AI resources

Create preference for multiple items

To create a preference with more than one item, you need to add these items to a list and provide the required attributes for each of them.

In addition to the SDKs, it is also possible to create a preference for multiple items directly through the Preferences API. To do this, send a POST request to the endpoint /checkout/preferencesAPI, including all desired items in the items array.

Use one of the available SDKs to perform this operation:

<?php
# Create a preference object
$preference = new MercadoPago\Preference();
# Create items in preference
$item1 = new MercadoPago\Item();
$item1->title = "Test Item 1";
$item1->quantity = 2;
$item1->unit_price = 11.96;

$item2= new MercadoPago\Item
$item2->title = "Test Item 2";
$item2->quantity = 1;
$item2->unit_price = 11.96;

$preference->items = array($item1,$item2);
# Save and post the preference
$preference->save();
?>

The total value of the preference will be the sum of the price value of each item listed.