shopp_add_product_download()

add product download file to a product/variation

shopp_add_product_download ( $product, $file, $variant )

@param int $product id of the product the download asset will be added to
@param string $file full or correct relative path to the download file asset.
@param int $variant id of the variant the download asset will be attached to.  For products with variants, this is a required parameter.
@return mixed false of failure, the new download asset id on success

Description

Add product download file to a product/variation.

Relative paths should be from the WP_CONTENT_DIR.

Examples

non-variant product

// Get product name "My Download Product"
$Product = shopp_product( 'My Download Product', 'name' );

// the product download file
$file = '/path/to/myproduct.zip';

// Add the product download
$download = shopp_add_product_download ( $Product->id, $file );

product with variants

// Get product name "My Album"
$Album = shopp_product( 'My Download Product', 'name' );

// Get variant for Track => "Track 01"
$Track = shopp_product_variant( 
    array( 
        'product' => $Album->id
        'option' => array(
            'Track' => 'Track 01'
        )
    ),
    'variant'
);

// the product download file
$mp3 = '/path/to/track-01.mp3';

// Add the product download
$download_id = shopp_add_product_download ( $Album->id, $mp3, $Track->id );

See Also

You must be logged in to post a comment.

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

Skip to toolbar