PHP code example of jurager / commerce

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

    

jurager / commerce example snippets


$cml = new Commerce();

$cml->loadImportXml('/path/import.xml'); // Загружаем товары
$cml->loadOffersXml('/path/offers.xml'); // Загружаем предложения

foreach ($cml->products as $product){
    echo $product->name; // Товары->Товар->Наименование
    foreach ($product->offers as $offer){
        echo $offer->name; // Предложения->Предложение->Наименование
        echo $offer->prices[0]->cost; // Предложения->Предложение->Цены->Цена->ЦенаЗаЕдиницу
    }
}