Dear all Zen Cart users and developers.
In the last 2 months, I was trying to find out, how a Subscription System (subscription products) could work in Zen Cart.
I am a starter in PHP and I could not do a lot.
I just managed to make some modifications and I am searching for some help.
The main idea is based on downloadable products. There in attributes conrtoller, I setup the days for the subscription to be active. If the subscription is active, user is informed when he bought the product (subscription), and when it expires.
If product(subscription) is active ( did not expired ) user can see a content (any HTML, FLASH etc. content) that I placed in a define, in a file I made and named subscription_defines.php, located in "includes\languages\english\extra_definitions\subscription_defines.php".
I made it this way, so nobody have access to this file in includes, witch uses .htaccess.
I also exploited the fact that all defines placed in a php file in "includes\languages\english\extra_definitions\some_file_defines.php" are loading automatically.
So, when a subscription is active (active means that downloadable product has not expired , and this stands in the modification I made in tpl_modules_downloads.php) I echo the define described above, else I echo another define I set up in my file "subscription_defines.php" witch inform user that subscription has expired and provide him a link to renew subscription.
Now I am working to find out, how to stop a user from renewing, if he had no orders in the past.
In the start I modified the file "tpl_product_info_display.php";
in the top of the code, below
"<div class="centerColumn" id="productGeneral">"
I placed this code :
################################################################################____
<?php if (zen_count_customer_orders() < 1){
echo CUSTOMER_NO_SUBSCRIPTION;
} elseif (zen_count_customer_orders() > 1){ ?>
##########################################################################################
and in the bottom this :
####################__
<?php
}
?>
####################__
Define CUSTOMER_NO_SUBSCRIPTION is also placed in the file "subscription_defines.php" and informs user that he has not bought any subscription, so he can not renew.
But this is not working because user can not even buy !!
Maybe there should be a query to check the product(subscription) id, and if product is "subscription renew" then we run the above IF's.
As I mentioned above, I am a starter in PHP and I just started digging deep in zen cart code.
Maybe someone from the developers team could help to make this work.
Well, this is not necessary for subscriptions(products) to work, but would be a good idea to stop user automatically from trying to buy a subscription renew if he has not any order before.
Also, I have made some modifications in :
"tpl_account_history_default.php"
"tpl_account_history_info_default.php"
I do not provide the link "account" at all even I made modification to this in the start, trying to show or not "protected" content based on the last order status.
My "tpl_account_default.php" was the following :
########################################################################################################################____
<div class="centerColumn" id="accountDefault">
<h1 id="accountDefaultHeading"><?php echo HEADING_TITLE; ?></h1>
<?php if ($messageStack->size('account') > 0) echo $messageStack->output('account'); ?>
<?php if (zen_count_customer_orders() < 1)
echo CUSTOMER_NO_SUBSCRIPTION;
?>
<?php if (zen_count_customer_orders() > 0) { ?>
<class="clearBoth" /> <table width="100%" border="0" cellpadding="0" cellspacing="0" id="prevOrders">
<?php foreach($ordersArray as $orders) { ?> <tr></tr> <?php } ?> </table>
<?php
if ($orders['orders_status_name'] == 3){
echo PERIEXOMENO_SYNDROMITWN;
} elseif ($orders['orders_status_name'] == 1){
echo PAYMENT_PENDING;
} elseif ($orders['orders_status_name'] == 2){
echo PRE_ACTIVATION_STATUS;
} elseif ($orders['orders_status_name'] == 4){
echo SUBSCRIPTION_EXPIRED;
}
?>
<?php
}
?>
########################################################################################################################_
Instead , I placed a login box in the left, and I provide to the user what I want :
account_history
account_edit
account_password
shopping_cart
logoff
and also the
subscription(product) and
subscription renew(product) links directly.
Well, if someone has any idea for developing for this, please reply or contact me directly ; [email protected].
Thanks



