PHP code example of vshopes / holded

1. Go to this page and download the library: Download vshopes/holded library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vshopes / holded example snippets

 
 
ded\Caller;
use Holded\Document;

$token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' //your token

$caller = new Caller ($token);

$document = new Document ($caller);

//docType should be one of: {invoice, salesreceipt, creditnote, salesorder, proform, waybill,estimate, purchase, purchaseorder or purchaserefund}
$docType =  'salesreceipt';

$listdocuments = $document->list(null,$docType);

print_r($listdocuments);


 
lded\Caller;
use Holded\Document;


$caller = new Caller ('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');


$document = new Document ($caller);
$salesreceiptid='XXXXXXXXXXXXXXX';

$listdocuments = $document->list(null, ['salesreceipt',$salesreceiptid ]);

print_r($listdocuments);


 
lded\Caller;
use Holded\Document;


$caller = new Caller ('XXXXXXXXXXXXXXXXXX');


$document = new Document ($caller);


$docData = [
        'applyContactDefaults' => false,
        'contactCode' =>     '',                                                // (NIF / CIF / VAT)
        'contactName' => 'Pepe Pérez',
        'contactEmail' => '[email protected]',
        'contactAddress' => 'La Pera 12',
        'contactCity' => 'Madrid',
        'contactCp' => '28029',
        'contactProvince'=> 'Madrid',
        'contactCountry'=> 'España',
        'contactCountryCode'=> 'ES',
      //'desc'=> ,
        'date'  => time(),                                                      //int32
        'notes'=> '#0001#34555',
        'salesChannelId'=> 'XXXXXXXXXXXXXXXXXXXX',
        'paymentMethodId'=> 'XXXXXXXXXXXXXXXXXXXX',
      //'designId'=> ,
      //'language'=>,
      //'warehouseId'=>  ,                                                      //Choose the warehouse for your salesorder, purchaseorder or waybill.
        'items'   => [ [                                                        //array of objects
                            'name' => 'Faja compresión',
                            'units' => 1,
                            'sku' => '124135135513',
                            'subtotal' => '34.33',
                            'tax' => '21',
                        ],                                                        
                        [                                                       
                            'name' => 'Plancha ATR',
                            'units' => 2,
                            'sku' => '1241351234513',
                            'subtotal' => '12.11',
//                            'tax' => '',
                        ]                
                    ],                       

      //'customFields'=>,                    // array of objects

      //'invoiceNum'=>,
      //'numSerieId'=>,
        'currency'=>'EUR',
      //'currencyChange'=>,
      //'tags'=>,  //array of strings

      //'dueDate'=>, //int32

      //'shippingAddress'=>,
      //'shippingPostalCode'=>,
      //'shippingCity'=>,
      //'shippingProvince'=>,
      //'shippingCountry'=>,
      //'salesChannel' => '',                   //float
];

//docType should be one of: {invoice, salesreceipt, creditnote, salesorder, proform, waybill,estimate, purchase, purchaseorder or purchaserefund}
$docType =  'salesreceipt';

$response = $document->create(['body' => $docData], $docType );

print_r($response);

 
lded\Caller;
use Holded\SalesChannels;


$caller = new Caller ('XXXXXXXXXXXXXXXXXXXXXX');


$saleschannels = new SalesChannels ($caller);

$listsc = $saleschannels->list();

print_r($listsc);

 
lded\Caller;
use Holded\Payment;


$caller = new Caller ('XXXXXXXXXXXXXXXXXXXXXXXXX');


$payment = new Payment ($caller);

$listpayments = $payment->list();

print_r($listpayments);

 
lded\Caller;
use Holded\Treasury;


$caller = new Caller ('XXXXXXXXXXXXXXXXXXXXXXXXX');


$treasury = new Treasury ($caller);

$list_treasuries = $treasury->list();

print_r($list_treasuries);

 
lded\Caller;
use Holded\Funnel;


$caller = new Caller ('XXXXXXXXXXXXXXXXXXXXXX');


$funnel = new Funnel ($caller);

$funnellist = $funnel->list();

print_r($funnellist);