We can sell resources from ptc-resources-server by using WooCommerce + Stripe payment gateway + downloadable product types for free. I realized we don't need to bother paying for WooCommerce Subscriptions and people can simply be prompted to manually purchase the product again in the meantime, if we even want to enforce that... One step at a time... ðŸ«
We can programmatically update the downloadable file associated with each product during the plugin release deployment (via cURL request to a custom REST API endpoint, for example) like so:
// Written by ChatGPT. Not reviewed for accuracy, but illustrates the basic idea.
function update_downloadable_file_path($product_id, $new_file_path) {
// Retrieve the existing downloadable files (it can be an array of multiple files)
$downloadable_files = get_post_meta($product_id, '_downloadable_files', true);
// Check if there are existing downloadable files
if (!empty($downloadable_files)) {
// Assuming there's only one downloadable file and you want to update it
foreach ($downloadable_files as $download_id => $file) {
// Update the file path with the new file path
$downloadable_files[$download_id]['file'] = $new_file_path;
}
} else {
// If no existing files, you can add a new downloadable file entry
$download_id = md5(uniqid());
$downloadable_files = array(
$download_id => array(
'name' => 'Your File Name', // Adjust the name as needed
'file' => $new_file_path,
)
);
}
// Update the downloadable files meta for the product
update_post_meta($product_id, '_downloadable_files', $downloadable_files);
}
We can sell resources from
ptc-resources-server
by using WooCommerce + Stripe payment gateway + downloadable product types for free. I realized we don't need to bother paying for WooCommerce Subscriptions and people can simply be prompted to manually purchase the product again in the meantime, if we even want to enforce that... One step at a time... ðŸ«See the user guide: https://woocommerce.com/document/digital-downloadable-product-handling/
We can programmatically update the downloadable file associated with each product during the plugin release deployment (via cURL request to a custom REST API endpoint, for example) like so: