<?php
/**
 * Shortcode Title: Price list
 * Shortcode: price_list
 * Usage: [pricing_list][pricing_list_item]...[/pricing_list_item][/pricing_list]
 */
add_shortcode('price_list', 'ts_price_list_func');

function ts_price_list_func( $atts, $content = null ) {
	
	global $price_list_items;
    $price_list_items = array(); // clear the array
	
	do_shortcode($content); // execute the '[price_list_items]' shortcode first to get columns
	
	if (!is_array($price_list_items) || count($price_list_items) == 0) {
		return '';
	}
	$items = '';
	
	foreach ($price_list_items as $item) {
		$items .= '
			<li>
				<div class="left">'.$item['title'].'</div>
				<div class="right">'.$item['price'].'</div>
			</li>';
	}
    $price_list_items = array();
	
	if (empty($items)) {
		return '';
	}
	
	return '
		<div class="price-list">
			<ul>
				'.$items.'
			</ul>
		</div>';
}

/**
 * Shortcode Title: Price List Item - can be used only with price_list shortcode
 * Shortcode: price_list_item
 * Usage: [price_list_item title="Product" price="$12.00"]
 */
add_shortcode('price_list_item', 'ts_price_list_item_func');
function ts_price_list_item_func( $atts, $content = null ) {
    extract(shortcode_atts(array(
	    'title' => '',
	    'price' => ''
    ), $atts));
    global $price_list_items;
	
    $price_list_items[] = array(
		'title' => $title,
	    'price' => $price
	);
	return $price_list_items;
}