Пример #1
0
    protected function cart_item_description($item, $key)
    {
        parent::cart_item_description($item, $key);
        if (!$this->log->is_transaction_completed()) {
            return;
        }
        $links = _wpsc_get_cart_item_downloadable_links($item, $this->log);
        ?>
		<div class="wpsc-cart-item-downloadable">
<?php 
        if (count($links) === 1) {
            ?>
			<strong><?php 
            esc_html_e('Download link: ', 'wp-e-commerce');
            ?>
</strong><br />
			<a href="<?php 
            echo esc_url($links[0]['url']);
            ?>
"><?php 
            echo esc_html($links[0]['name']);
            ?>
</a>
<?php 
        } else {
            ?>
			<strong><?php 
            esc_html_e('Digital Contents', 'wp-e-commerce');
            ?>
</strong>
			<ul>
<?php 
            foreach ($links as $link) {
                ?>
				<li><a href="<?php 
                echo esc_url($link['url']);
                ?>
"><?php 
                echo esc_html($link['name']);
                ?>
</a></li>
<?php 
            }
            ?>
			</ul>
<?php 
        }
        ?>
		</div>
<?php 
    }
Пример #2
0
function wpsc_get_downloadable_links($purchase_log)
{
    if (!$purchase_log->is_transaction_completed()) {
        return array();
    }
    $cart_contents = $purchase_log->get_cart_contents();
    $links = array();
    foreach ($cart_contents as $item) {
        $item_links = _wpsc_get_cart_item_downloadable_links($item, $purchase_log);
        if (empty($item_links)) {
            continue;
        }
        $links[$item->name] = $item_links;
    }
    return apply_filters('wpsc_get_downloadable_links', $links, $purchase_log);
}