Beispiel #1
0
/**
 * shopp_add_order_line_download - attach a download asset to a order line
 *
 * @api
 * @since 1.2
 *
 * @param int $order the order id to add the download asset to
 * @param int $line the order line item to add the download asset to
 * @param int $download the download asset id
 * @return bool true on success, false on failure
 **/
function shopp_add_order_line_download($order = false, $line = 0, $download = false)
{
    $Lines = shopp_order_lines($order);
    $ids = array_keys($Lines);
    if (empty($Lines) || $line >= count($Lines) || !isset($ids[$line])) {
        return false;
    }
    $id = $ids[$line];
    $DL = new ProductDownload($download);
    if (empty($DL->id)) {
        shopp_debug(__FUNCTION__ . " failed: Invalid or missing download asset id.");
        return false;
    }
    $Purchased = new ShoppPurchased();
    $Purchased->populate($Lines[$id]);
    $Purchased->download = $download;
    $Purchased->keygen();
    $Purchased->save();
    return true;
}