PHP code example of pdeans / miva-provision

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

    

pdeans / miva-provision example snippets


use pdeans\Miva\Provision\Manager as Provision;

$store_code = 'PS';
$url = 'http://www.example.com/mm5/json.mvc?Function=Module&Module_Code=remoteprovisioning&Module_Function=XML';
$token = '12345';

$prv = new Provision($store_code, $url, $token);

$xml = $prv->create('Category_Add', [
    '@tags' => [
        'Code' => 'Tools',
        'Name' => $prv->cdata('Class Tools and Skill Kits'),
    ],
]);

// Output: <![CDATA[Class Tools and Skill Kits]]>
echo $prv->cdata('Class Tools and Skill Kits');

// Output: 49.00
echo $prv->decimal(49.0000000);

// Output: 49.001
echo $prv->decimal(49.0005, 3);

$xml = $prv->create('CategoryProduct_Assign', [
    '@attributes' => [
        'category_code' => 'Food',
        'product_code'  => 'ale-gallon',
    ],
]);

$xml = $prv->create('CategoryProduct_Assign', [
    '@a' => [
        'category_code' => 'Food',
        'product_code'  => 'ale-gallon',
    ],
]);

$xml = $prv->create('ProductAttribute_Add', [
    '@a' => [
        'product_code' => 'chest',
    ],
    '@tags' => [
        'Code'   => 'lock',
        'Type'   => 'select',
        'Prompt' => $prv->cdata('Lock'),
    ],
]);

$xml = $prv->create('ProductAttribute_Add', [
    '@a' => [
        'product_code' => 'chest',
    ],
    '@t' => [
        'Code'   => 'lock',
        'Type'   => 'select',
        'Prompt' => $prv->cdata('Lock'),
    ],
]);

$xml = $prv->create('Module', [
    '@attributes' => [
        'code' => 'customfields',
        'feature' => 'fields_prod',
    ],
    '@tags' => [
        'ProductField_Value' => [
            '@attributes' => [
                'product' => 'chest',
                'field' => 'armor_type',
            ],
            '@value' => 'wood',
        ],
    ],
]);

$xml = $prv->create('Module', [
    '@a' => [
        'code' => 'customfields',
        'feature' => 'fields_prod',
    ],
    '@t' => [
        'ProductField_Value' => [
            '@a' => [
                'product' => 'chest',
                'field' => 'armor_type',
            ],
            '@v' => 'wood',
        ],
    ],
]);

$xml = $prv->create('Order_Add', [
    '@t' => [
        'Charges' => [
            'Charge' => [
                [
                    'Type' => 'SHIPPING',
                    'Description' => 'Shipping: UPS Ground',
                    'Amount' => 5.95
                ],
                [
                    'Type' => 'TAX',
                    'Description' => 'Sales Tax',
                    'Amount' => 2.15
                ],
            ],
        ],
    ],
]);

$xml = $prv->create('Order_Add', [
    '@t' => [
        'TriggerFulfillmentModules' => null,
    ],
]);

$response = $prv->send($xml);

$response = $prv->send($xml, true);

// Appends <Domain></Domain> element to xml
$xml = $prv->addDomain($xml);

// Appends <Store code="store code"></Store> element to xml
$xml = $prv->addStore($xml);

// Appends <Provision></Provision> element to xml
$xml = $prv->addProvision($xml);

// Get store code
$store_code = $prv->getStore();

// Set store code
$prv->setStore('store code');

// Get provision request url
$url = $prv->getUrl();

// Set provision request url
$prv->setUrl('request url');

// Get provision access token
$token = $prv->getToken();

// Set provision access token
$prv->setToken('access token');
xml
<Category_Add>
    <Code>Tools</Code>
    <Name><![CDATA[Class Tools and Skill Kits]]></Name>
</Category_Add>
xml
<Order_Add>
    <Charges>
        <Charge>
            <Type>SHIPPING</Type>
            <Description>Shipping: UPS Ground</Description>
            <Amount>5.95</Amount>
        </Charge>
        <Charge>
            <Type>TAX</Type>
            <Description>Sales Tax</Description>
            <Amount>2.15</Amount>
        </Charge>
    </Charges>
</Order_Add>
xml
<Order_Add>
    <TriggerFulfillmentModules />
</Order_Add>