Helcim Virtual Store

XML Code Samples

Helcim Virtual Store Support

Below are simple code samples showing how to achieve results with the Helcim Virtual Store XML API. In order to use the Live Access feature a general understanding of XML, as well as a server-side scripting language (such as: PHP or ASP) is required. Based on popularity, most of the examples below are in PHP 5.

List of Code Samples (PHP/HTML)


Displaying Basic Product Information

The code below displays basic product information, including product name and price.

<?php

	// SET XML VARIABLES
	$merchant = '99999999';
	$token = 'abc123abc123abc123abc123';
	$xmlURL = "http://xml.virtualstore.helcim.com/";
	$cartURL = "https://virtualstore.helcim.com/cart/";

	// LOAD A SPECIFIC PRODUCT INTO THE XML
	$productId = '123';
	$xml = simplexml_load_file($xmlURL.'?type=product&merchant='
	.$merchant.'&token='.$token.'&product='.$productId);
	$product = $xml->product;

?>
<html>
<head></head>
<body>

	<!--PRODUCT-NAME-->
	<h1><?= $productName ?></h1>

	<!--PRODUCT-SKU-->
	SKU: <?= $product->sku ?>
	<br/><br/>

	<!--PRODUCT-DESCRIPTION-->
	<p>
	<?= $product->description ?>
	</p>

	<!--PRODUCT-SHIPPING-UNITS-->
	<?= $product->shippingUnits ?> Shipping Units<br/>

	<!--PRODUCT-DIMENSIONS-->
	W <?= $product->width ?>cm
	<br/>
	H <?= $product->height ?>cm
	<br/>
	L <?= $product->length ?>cm
	<br/>


	<!--PRODUCT-WEIGHT-->
	Weight: <?= $product->weight ?>kg
	<br/><br/>

	<!--PRODUCT-PRICE-->
	<h2>$<?= $product->price ?></h2>

	<!--SHOPPING-CART-BUY-BUTTON-->
	<a target="helcimcart" href="<?= $cartURL ?>?productId=<?= $product->id ?>">
	<img src="https://virtualstore.helcim.com/pictures/cartbuttons/HelcimBuyButton09.jpg">
	</a>
	<br/><br/>

	<!--PRODUCT-PICTURE-MAIN-->
	<img border="1"
	src="<?= $product->pictures->path ?>hcm1<?= $product->pictures->main ?>">
	<br/><br/>

	<!--PRODUCT-TAGS-->
	Tags: <?= $product->tags ?>
	<br/><br/>

</body>
</html>

Displaying In Stock or Out of Stock

The code below displays is the product is in stock or out of stock.

<?php

	// SET XML VARIABLES
	$merchant = '99999999';
	$token = 'abc123abc123abc123abc123';
	$xmlURL = "http://xml.virtualstore.helcim.com/";
	$cartURL = "https://virtualstore.helcim.com/cart/";

	// LOAD A SPECIFIC PRODUCT INTO THE XML
	$productId = '123';
	$xml = simplexml_load_file($xmlURL.'?type=product&merchant='
	.$merchant.'&token='.$token.'&product='.$productId);
	$product = $xml->product;

?>
<html>
<head></head>
<body>

	<!--PRODUCT-STOCK-->
	<?php
		// DISPLAY IF PRODUCT IS IN STOCK OR NOT
		if($product->inStock == 1) {
	?>

		In Stock
		<br/>

	<?php 
		}else{
	?>

		Out of Stock
		<br/>

	<?php
		}
	?>

</body>
</html>

Listing all Products in a Category

The code below draws a simple list of all the products in a specified category.

<?php

	// SET XML VARIABLES
	$merchant = '99999999';
	$token = 'abc123abc123abc123abc123';
	$xmlURL = "http://xml.virtualstore.helcim.com/";

	// LOAD ALL PRODUCTS OF A SPECIFIC CATEGORY
	$categoryId = '87';
	$products = simplexml_load_file($xmlURL.'?type=product&merchant='
	.$merchant.'&token='.$token.'&category='.$categoryId);

?>
<html>
<head></head>
<body>

	<!--CATEGORY-NAME-->
	<h1><?= $products->product->category->name ?></h1>

	<?php
		// DISPLAY ALL PRODUCTS IN THIS CATEGORY
		foreach($products->product as $product)
		{
	?>

		<!--PRODUCT-PICTURE-THUMBNAIL-->
		<img border="1"
		src="<?= $product->pictures->path.'tn'.$product->pictures->main ?>">
		<br/>

		<!--PRODUCT-NAME-->
		<h2><?= $productName ?></h2>
		<br/>


		<!--CATEGORY-PRODUCT-PRICE-->
		<b>$<?= $product->price ?></b>
		<br/><br/>

	<?php
		}
	?>

</body>
</html>

© Copyright 2006-2010 Helcim Inc. All Rights Reserved.

The Helcim name and logo are trademarks of Helcim Inc. The Interac name and logo are trademarks of Interac Inc. The Visa and MasterCard logos are trademarks of Visa International and MasterCard International Incorporated. Other tradenames may be trademarks of their respective owners. Helcim is a registered MSP/ISO of the Canadian branch of U.S. Bank National Association and GE Money. New applicants are subject to conditions and approval of the application by Helcim and its partnering banks.