shopp_add_order_line_download()

attach a download asset to a order line

shopp_add_order_line_download ( $order, $line, $download )

@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

Description

attach a download asset to a order line

This function will associate a downloadable asset id with a particular purchaseed order line-item. It will also generate a download key for the item.

Example

// Create a DL Product
$data = array(
    'name' => "Product Download",
    'publish' => array( 'flag' => true ),
    'description' => "Product Download Test",
    'packaging' => true
);
$data['single'] = array(
    'type' => 'Download',
    'price' => 1.00,
);
$DownloadProduct = shopp_add_product($data);

// Get the new product's sole priceline Price object
$Price = reset($DownloadProduct->prices)

// Convert the Price to an Item object
$Item = shopp_product_variant_to_item( $Price );

// get the most recent order id
$order_id = shopp_last_order()->id;

// add the Item to the order
shopp_add_order_line($order_id, $Item );

// Add a download asset to my product
// get the download id
$download = shopp_add_product_download ( $DownloadProduct->id, '/full/path/to/Download.zip' );

// Add the download to my order
shopp_add_order_line_download( 
    $order_id, 
    shopp_order_line_count($order_id) - 1, 
    $download 
);

See Also

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.

Skip to toolbar