PHP code example of memdev / opentrans

1. Go to this page and download the library: Download memdev/opentrans 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/ */

    

memdev / opentrans example snippets

 php


use \SE\Component\OpenTrans;

$document = $builder->getDocument();

$document->getHeader()->getOrderInfo()->setOrderId('00000000001');

$orderLine1 = new OpenTrans\Node\Order\ItemNode();
$orderLine1->setLineId('P00000001');

$document->addItem($orderLine1);

$xml = $builder->serialize();

 php


use \SE\Component\OpenTrans;

// Let the DocumentFactoryResolver pick the factory you need

$loader = new OpenTrans\NodeLoader();
$factoryClass = OpenTrans\DocumentFactory\DocumentFactoryResolver::resolveFactory(
    $loader,
    OpenTrans\DocumentType::DOCUMENT_ORDER
);

$factory = new $factoryClass($loader);
$builder = new OpenTrans\DocumentBuilder($factory);
$builder->build(); // bootstraps the default document structure

$document = $builder->getDocument();
// ... build your document