USS-Connect APICatalogue

environment = new environmentType(); $args->environment->languageCode = 'de'; $args->environment->countryCode = 'DE'; $args->environment->portalName = 'print24'; $selected = new selectedType(); $selected->optionIds = array(); $selected->shippingDestinationChoice = 0; // The interface accept ids and names as requested option value // don't save option ids in your local system $value_ref_in = 'optionName'; // select by option names, you can save this local $value_ref_out = 'value'; // $value_ref_in = 'optionId'; // select by option ids do not save option ids in your local database // $value_ref_out = 'id'; $saveItem = false; $itemIdentifier = ''; $i = 0; foreach($_GET as $key => $value) { switch ($key){ case 'language': echo ""; $args->environment->languageCode = $value; break; case 'country': echo ""; $args->environment->countryCode = $value; break; case 'saveItem': $saveItem = true; break; case 'itemIdentifier': $itemIdentifier = ( $value == '' ? '~generate~' : $value); break; case 'internalId': $selected->internalId = $value; break; default: $selected->optionIds[$i] = new parameterType(); $selected->optionIds[$i]->name = $key; $selected->optionIds[$i]->{$value_ref_out} = $value; $i++; break; } } if ( count( array($selected->optionIds > 0))){ $args->selected = &$selected; } $args->messageLevel = 'all'; // $args->calculatedPriceRange = new rangeType(); // $args->calculatedPriceRange->lower = 0; // calculate price only for the selected product // $args->calculatedPriceRange->lower = 1; // sample for calculate the first 10 prices // $args->calculatedPriceRange->upper = 10; // build the webservice client // test server, access with sample certificate. Download this from the Unitedprint api download page. $soap_service = "http://interface.unitedprint.com.onts.print24test.de/wsdl2.1/catalogue.wsdl"; // real server, you need your own certificate. Contact the Unitedprint customers service. // $soap_service = "http://interface.unitedprint.com/wsdl2.1"; try { $options = array( 'soap_version' => SOAP_1_1, 'exceptions' => true, 'trace' => 1, 'cache_wsdl' => WSDL_CACHE_NONE, 'local_cert' => 'sample.cert', 'stream_context' => stream_context_create(['ssl' => ['verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true]]), 'charset' => 'utf8', ); $client = new SoapClient($soap_service, $options); } catch(Exception $e) { echo "Error on make interface client: " . $e->getMessage(); } // call webservice try { if ($saveItem){ $saveItemArgs->environment = $args->environment; $saveItemArgs->product = $args->selected; $saveItemArgs->product->itemIdentifier = $itemIdentifier; $saveItemArgs->product->emphasizeType = 'USR'; $saveItemArgs->writeMode = 'save'; $saveItemArgs->messageLevel = $args->messageLevel; $erg = $client->setCustomProduct($saveItemArgs); } else { $erg = $client->getCustomCatalogue($args); } } catch(Exception $e) { echo "Error on request interface: " . $e->getMessage(); } echo "

party group: " . $erg->environment->partyGroupName . " / " . $erg->environment->portalName . " / " . $erg->environment->countryCode . "_" . $erg->environment->languageCode ."

\n"; if ( property_exists($erg->productList, 'selectGroupList') ) { // show details of the selected product if ($erg->productList->selected){ echo "
"; echo "
\n

".utf8_decode($erg->productList->selected->productNameSingular)."

"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
product price net".$erg->productList->selected->priceNet ." ". $erg->environment->currencyCode."
product price gross".$erg->productList->selected->priceGross ." ". $erg->environment->currencyCode."
shipping price net".$erg->productList->selected->shippingNet ." ". $erg->environment->currencyCode."
shipping price gross".$erg->productList->selected->shippingGross ." ". $erg->environment->currencyCode."
"; echo "

property names values

"; foreach ($erg->productList->selected->propertyNames as $property ) { echo ""; } echo "
".$property->name."".utf8_decode($property->value)."
"; echo "

catalogue type

".$erg->productList->selected->catalogueIdentCode."
"; echo ""; echo ""; echo "
"; // product info end } echo "
"; $box_size = 1; // fill product select box area foreach ($erg->productList->selectGroupList as $group) { // for all select boxes $size = count(array($group->optionList)); $groupValue = $group->selectTranslations; if ($groupValue == "") { $groupValue = $group->selectName; } switch (gettype($groupValue)){ case 'array': // translations texts consisting of several parts for formatting $groupValue = utf8_decode(join(" ", $groupValue)); break; case 'string': // .. or only one $groupValue = utf8_decode($groupValue); break; } echo "
\n

".$groupValue." (" . $group->selectName . ")

\n"; echo "\n
"; } echo "
"; // product selection end } else { if ($erg->catalogueList){ if (gettype($erg->catalogueList->catalogueList) != 'array'){ $erg->catalogueList->catalogueList = array($erg->catalogueList->catalogueList); } echo "Saved product Identifier is: ".$erg->catalogueList->catalogueList[0]->productId."
"; echo "order this product"; } echo "
back to catalogue select view"; echo "
catalogue is empty"; } ?>