Opencart 3.0.3.8
I'm searching for a module or method like modification of opencart code for automatically disabling of download from downloadable product after time period or maybe if a success download was complete from customer. Maybe a parameter about max. avaliable download was reached.
I found COMO module https://www.opencart.com/index.php?rout ... ember=como
like Dynamic downloads but I'm not sure if this is a solution for me.
Thanks.
I'm searching for a module or method like modification of opencart code for automatically disabling of download from downloadable product after time period or maybe if a success download was complete from customer. Maybe a parameter about max. avaliable download was reached.
I found COMO module https://www.opencart.com/index.php?rout ... ember=como
like Dynamic downloads but I'm not sure if this is a solution for me.
Thanks.
In the opencart-3 or OC 4 version, the new subscription system does validate the cycle and the frequency period of a subscription plan. However, while it may not include the product downloads in the process, it could probably be done as an extension.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I just finished coding a subscription download project from the catalog/controller/mail/order.php file's add() method for users currently using the opencart-3 repository and decided to publish it here.
In that file, replace:
with:
Not sure if it was already done before but it can also be used for other projects in case users are looking for something similar. Then, users can then contribute with their own extensions targeting the catalog/view/theme/<your_theme>/template/mail/order_add.twig file and in the account/download page with this example.
Duplicate request: viewtopic.php?t=230240#p851243 .
In that file, replace:
Code: Select all
// Check for any downloadable products
$download_status = false;
$order_products = $this->model_checkout_order->getProducts($order_info['order_id']);
foreach ($order_products as $order_product) {
// Check if there are any linked downloads
$product_download_query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "product_to_download` WHERE `product_id` = '" . (int)$order_product['product_id'] . "'");
if ($product_download_query->row['total']) {
$download_status = true;
}
}
Code: Select all
// Check for any downloadable products
$download_status = false;
$order_products = $this->model_checkout_order->getProducts($order_info['order_id']);
// Subscription
$this->load->model('checkout/subscription');
// Products
$this->load->model('catalog/product');
// Downloads
$this->load->model('account/download');
foreach ($order_products as $order_product) {
// Check if there are any linked downloads
$product_download_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "product_to_download` WHERE `product_id` = '" . (int)$order_product['product_id'] . "'");
if ($product_download_query->num_rows) {
$subscription_info = $this->model_checkout_subscription->getSubscriptionByOrderProductId($order_product['order_product_id']);
if ($subscription_info) {
$product_subscription_info = $this->model_catalog_product->getSubscription($order_product['product_id'], $subscription_info['subscription_plan_id']);
if ($product_subscription_info) {
// We need to validate frequencies in compliance of the admin subscription plans
// as with the use of the APIs
if ($subscription_info['frequency'] == 'semi_month') {
$period = strtotime("2 weeks");
} else {
$period = strtotime($subscription_info['cycle'] . ' ' . $subscription_info['frequency']);
}
// Subscription date
$subscription_period = strtotime($subscription_info['date_added']);
// Calculates the remaining days between the subscription
// promotional period and the date added period
$period = ($period - $subscription_period);
// Calculate remaining period of each features
$cycle = round($period / (60 * 60 * 24));
if ($subscription_info['status'] && $subscription_info['status'] && !$subscription_info['trial_status'] && $cycle >= 0) {
$account_download_info = $this->model_account_download->getDownload($product_download_query->row['download_id']);
if ($account_download_info) {
// Download date
$download_period = strtotime($product_download_query->row['date_added']);
// Calculates the remaining period between the subscription
// and the download date added period
$period = ($period - $download_period);
// Calculate remaining period of each downloads
$download_cycle = round($period / (60 * 60 * 24));
if ($download_cycle >= $cycle) {
$download_status = true;
}
}
}
}
} else {
$download_status = true;
}
}
}
Duplicate request: viewtopic.php?t=230240#p851243 .
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Thanks, I will try it, but not sure if I'm capable enough 
If I change the above code. On last confirm order stage a error message appears.
Would you be so kindly and explain me more your approach please ?
How can I use your extension attributes in twig and php order files ?
Thanks.
Solution maybe.
https://www.opencart.com/index.php?rout ... 877e06c3e0

If I change the above code. On last confirm order stage a error message appears.
Would you be so kindly and explain me more your approach please ?
How can I use your extension attributes in twig and php order files ?
Thanks.
Solution maybe.
https://www.opencart.com/index.php?rout ... 877e06c3e0
Attachments
Failure.JPG (28.6 KiB) Viewed 3168 times
Last edited by jozef.szabo@email.cz on Thu Dec 29, 2022 7:07 am, edited 3 times in total.
You can always create a new service request in the Commercial Support section of the forum or contact me directly via the forum PM to get this done as a custom job.jozef.szabo@email.cz wrote: ↑Wed Dec 28, 2022 10:15 pmThanks, I will try it, but not sure if I'm capable enough![]()
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: No registered users and 4 guests