[Skip to main content](#vessel-content)

#   Modify Plug In for akeeba Subscriptions

##

- **[Teto](/forum/user/8045-teto "View Teto's Profile")**
- [![Teto's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar8045_2012-09-12.png)](/forum/user/8045-teto "View Teto's Profile") Topic Author
- [ Offline](/forum/user/8045-teto)

Less More

- Posts: 184
- Thank you received: 4
-
- [](http://www.madeinvino.com)
-

14 years 3 months ago [\#59378](#59378) by [Teto](/forum/user/8045-teto "View Teto's Profile")  *[Modify Plug In for akeeba Subscriptions](/forum/2-general-talk-about-hikashop/59378-modify-plug-in-for-akeeba-subscriptions#59378 "We sell normal products and also subscriptions. The subscriptions give the opportunity to buy the products (without a valid subscription it is no possible to buy the products). With have different subscriptions with different duration. To enable on my web site this feature I am using AkeebaSubscreption and the relative HikaShop Plug In.  I tested your plug-in with akeeba subscriptions and it works fine :cheer: , but we have a different method to start the subscription period depending on when the customer buy the subscrition.  For example Customer A: buys the subscription of one month as the 25th of April, the subscription period has to start the 20th of MAY and continue for 30 days. Customer B: buys the subscription of one month as the 5th of May, the subscription period has to start the 20th of MAY and continue for 30 days. Customer C: buys the subscription of one month as the 6th of May, the subscription period has to start the 20th of JUNE and continue for 30 days.  In practice, if a customer buys from the 20th of April to the 5th of May, the subscription has to start the 20th of May. if a customer buys from the 6th of May to the 19th of May, the subscription has to start the 20th of June.  To obtain this behaviour is necessary modify the plug in? Could you give me some help to do that?  Thanks in advance.")* was created by *[Teto](/forum/user/8045-teto "View Teto's Profile")*

We sell normal products and also subscriptions.
The subscriptions give the opportunity to buy the products (without a valid subscription it is no possible to buy the products).
With have different subscriptions with different duration.
To enable on my web site this feature I am using AkeebaSubscreption and the relative HikaShop Plug In.

I tested your plug-in with akeeba subscriptions and it works fine ![:cheer:](/media/kunena/emoticons/2.png ":cheer:") , but we have a different method to start the subscription period depending on when the customer buy the subscrition.

For example
Customer A: buys the subscription of one month as the 25th of April, the subscription period has to start the 20th of MAY and continue for 30 days.
Customer B: buys the subscription of one month as the 5th of May, the subscription period has to start the 20th of MAY and continue for 30 days.
Customer C: buys the subscription of one month as the 6th of May, the subscription period has to start the 20th of JUNE and continue for 30 days.

In practice, if a customer buys from the 20th of April to the 5th of May, the subscription has to start the 20th of May.
if a customer buys from the 6th of May to the 19th of May, the subscription has to start the 20th of June.

To obtain this behaviour is necessary modify the plug in?
Could you give me some help to do that?

Thanks in advance.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzU5Mzc4LW1vZGlmeS1wbHVnLWluLWZvci1ha2VlYmEtc3Vic2NyaXB0aW9ucz90bXBsPW1hcmtkb3du) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86322
- Thank you received: 14281
-
-

14 years 3 months ago [\#59433](#59433) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Modify Plug In for akeeba Subscriptions](/forum/2-general-talk-about-hikashop/59378-modify-plug-in-for-akeeba-subscriptions#59433 "We sell normal products and also subscriptions. The subscriptions give the opportunity to buy the products (without a valid subscription it is no possible to buy the products). With have different subscriptions with different duration. To enable on my web site this feature I am using AkeebaSubscreption and the relative HikaShop Plug In.  I tested your plug-in with akeeba subscriptions and it works fine :cheer: , but we have a different method to start the subscription period depending on when the customer buy the subscrition.  For example Customer A: buys the subscription of one month as the 25th of April, the subscription period has to start the 20th of MAY and continue for 30 days. Customer B: buys the subscription of one month as the 5th of May, the subscription period has to start the 20th of MAY and continue for 30 days. Customer C: buys the subscription of one month as the 6th of May, the subscription period has to start the 20th of JUNE and continue for 30 days.  In practice, if a customer buys from the 20th of April to the 5th of May, the subscription has to start the 20th of May. if a customer buys from the 6th of May to the 19th of May, the subscription has to start the 20th of June.  To obtain this behaviour is necessary modify the plug in? Could you give me some help to do that?  Thanks in advance.")*

It will indeed be necessary that you change the code of the plugin.

These lines are what calculates the date when the subscription has to start and the date when it has to stop:
$date = date('Y-m-d H:i:s', $timestamp);
$publish_up = $date;
$publish_down = date("Y-m-d H:i:s", $timestamp+(86400*$level_duration*$result-&gt;order_product_quantity));
You will need to change them in order to accomodate with what you want to do.
Maybe something like that:
$day = date('d',$timestamp);
$month = date('m',$timestamp);
if($day&gt;=6 AND $day &lt;=19)$new_month=$month+1;
elseif($day&gt;19)$new_month=$month+2;
else $new_month=$month;
$date = str_replace('-'.$month.'-','-'.$new_month.'-',date('Y-m-d H:i:s', $timestamp));
$publish_up = $date;
$publish_down = date("Y-m-d H:i:s", $timestamp+(86400*$level_duration*$result-&gt;order_product_quantity));

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzU5Mzc4LW1vZGlmeS1wbHVnLWluLWZvci1ha2VlYmEtc3Vic2NyaXB0aW9ucz90bXBsPW1hcmtkb3du) or [Create an account](/register) to join the conversation.

- **[Teto](/forum/user/8045-teto "View Teto's Profile")**
- [![Teto's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar8045_2012-09-12.png)](/forum/user/8045-teto "View Teto's Profile") Topic Author
- [ Offline](/forum/user/8045-teto)

Less More

- Posts: 184
- Thank you received: 4
-
- [](http://www.madeinvino.com)
-

14 years 3 months ago -  14 years 3 months ago [\#59518](#59518) by [Teto](/forum/user/8045-teto "View Teto's Profile")  Replied by *[Teto](/forum/user/8045-teto "View Teto's Profile")* on topic *[Re: Modify Plug In for akeeba Subscriptions](/forum/2-general-talk-about-hikashop/59378-modify-plug-in-for-akeeba-subscriptions#59518 "We sell normal products and also subscriptions. The subscriptions give the opportunity to buy the products (without a valid subscription it is no possible to buy the products). With have different subscriptions with different duration. To enable on my web site this feature I am using AkeebaSubscreption and the relative HikaShop Plug In.  I tested your plug-in with akeeba subscriptions and it works fine :cheer: , but we have a different method to start the subscription period depending on when the customer buy the subscrition.  For example Customer A: buys the subscription of one month as the 25th of April, the subscription period has to start the 20th of MAY and continue for 30 days. Customer B: buys the subscription of one month as the 5th of May, the subscription period has to start the 20th of MAY and continue for 30 days. Customer C: buys the subscription of one month as the 6th of May, the subscription period has to start the 20th of JUNE and continue for 30 days.  In practice, if a customer buys from the 20th of April to the 5th of May, the subscription has to start the 20th of May. if a customer buys from the 6th of May to the 19th of May, the subscription has to start the 20th of June.  To obtain this behaviour is necessary modify the plug in? Could you give me some help to do that?  Thanks in advance.")*

Thank you nicolas

I am trying to modify the plug in but I have some problem because unfortunately I am not an expert of PHP

I found the code you indicated

$timestamp = time();
if(!$old){
//New sub
//$date = date('Y-m-d H:i:s', $timestamp);
//$publish_up = $date;
//$publish_down = date("Y-m-d H:i:s", $timestamp+(86400*$level_duration*$result-&gt;order_product_quantity));

$publish_up = date(DATE_ATOM, mktime(0, 0, 0, date('m',$timestamp), 20, date('y',$timestamp)));
$publish_down = date("Y-m-d H:i:s", $publish_up+(86400*$level_duration*$result-&gt;order_product_quantity));

if (date('d',$timestamp)&gt;= 6) {
$publish_up = strtotime("+1 month", $publish_up);
$publish_down = strtotime("+1 month", $publish_down);
}
}
else{
//add sub after the old sub
$publish_up = $old-&gt;publish_down;
$publish_down = hikashop_getTime($old-&gt;publish_down);
$publish_down = date("Y-m-d H:i:s", $publish_down+(86400*$level_duration*$result-&gt;order_product_quantity));

}

Unfortunately it doesn't work fine.

I would like to set the $publish_up to start the 20th of the month at the time 00:00 and the $publish_down equal to $publish_up plus the duration.
If the day is equal or greater than 6, I would like to add a month to both the variables ($publish_up and $publish_down).

I have also modifyed this code

//$query = 'SELECT * FROM '.hikashop_table('akeebasubs_subscriptions',false).'
//WHERE state = '.$db-&gt;quote('C').'
//AND user_id = '.(int)$user_id.' AND enabled = 1 AND akeebasubs_level_id = '.(int)$level_id.' ORDER BY akeebasubs_subscription_id DESC';
$query = 'SELECT * FROM '.hikashop_table('akeebasubs_subscriptions',false).'
WHERE state = '.$db-&gt;quote('C').'
AND user_id = '.(int)$user_id.' AND enabled = 1 ORDER BY akeebasubs_subscription_id DESC';

Because I would like to contiue with the prevoius date also if the subscription level is different.
Is it correct?

Could you help to find the errors.

Thank you!

Last edit: 14 years 3 months ago by [Teto](/forum/user/8045-teto "View Teto's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzU5Mzc4LW1vZGlmeS1wbHVnLWluLWZvci1ha2VlYmEtc3Vic2NyaXB0aW9ucz90bXBsPW1hcmtkb3du) or [Create an account](/register) to join the conversation.

- **[Teto](/forum/user/8045-teto "View Teto's Profile")**
- [![Teto's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar8045_2012-09-12.png)](/forum/user/8045-teto "View Teto's Profile") Topic Author
- [ Offline](/forum/user/8045-teto)

Less More

- Posts: 184
- Thank you received: 4
-
- [](http://www.madeinvino.com)
-

14 years 3 months ago -  14 years 3 months ago [\#59538](#59538) by [Teto](/forum/user/8045-teto "View Teto's Profile")  Replied by *[Teto](/forum/user/8045-teto "View Teto's Profile")* on topic *[Re: Modify Plug In for akeeba Subscriptions](/forum/2-general-talk-about-hikashop/59378-modify-plug-in-for-akeeba-subscriptions#59538 "We sell normal products and also subscriptions. The subscriptions give the opportunity to buy the products (without a valid subscription it is no possible to buy the products). With have different subscriptions with different duration. To enable on my web site this feature I am using AkeebaSubscreption and the relative HikaShop Plug In.  I tested your plug-in with akeeba subscriptions and it works fine :cheer: , but we have a different method to start the subscription period depending on when the customer buy the subscrition.  For example Customer A: buys the subscription of one month as the 25th of April, the subscription period has to start the 20th of MAY and continue for 30 days. Customer B: buys the subscription of one month as the 5th of May, the subscription period has to start the 20th of MAY and continue for 30 days. Customer C: buys the subscription of one month as the 6th of May, the subscription period has to start the 20th of JUNE and continue for 30 days.  In practice, if a customer buys from the 20th of April to the 5th of May, the subscription has to start the 20th of May. if a customer buys from the 6th of May to the 19th of May, the subscription has to start the 20th of June.  To obtain this behaviour is necessary modify the plug in? Could you give me some help to do that?  Thanks in advance.")*

Probably i found the reason

I have to change there rows

$publish_up = date(DATE_ATOM, mktime(0, 0, 0, date('m',$timestamp), 20, date('y',$timestamp)));
$publish_down = date("Y-m-d H:i:s", $publish_up+(86400*$level_duration*$result-&gt;order_product_quantity));

With

$publish_up = mktime(0, 0, 0, date('m',$timestamp), 20, date('y',$timestamp));

$publish_down = strtotime("+".$level_duration*$result-&gt;order_product_quantity." day", $publish_up);
Or
$publish_down = mktime(0, 0, 0, date('m',$timestamp), 20+($level_duration*$result-&gt;order_product_quantit),date('y',$timestamp));

Is it correct? I cannot test it until tomorrow.

Last edit: 14 years 3 months ago by [Teto](/forum/user/8045-teto "View Teto's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzU5Mzc4LW1vZGlmeS1wbHVnLWluLWZvci1ha2VlYmEtc3Vic2NyaXB0aW9ucz90bXBsPW1hcmtkb3du) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86322
- Thank you received: 14281
-
-

14 years 3 months ago [\#59580](#59580) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Modify Plug In for akeeba Subscriptions](/forum/2-general-talk-about-hikashop/59378-modify-plug-in-for-akeeba-subscriptions#59580 "We sell normal products and also subscriptions. The subscriptions give the opportunity to buy the products (without a valid subscription it is no possible to buy the products). With have different subscriptions with different duration. To enable on my web site this feature I am using AkeebaSubscreption and the relative HikaShop Plug In.  I tested your plug-in with akeeba subscriptions and it works fine :cheer: , but we have a different method to start the subscription period depending on when the customer buy the subscrition.  For example Customer A: buys the subscription of one month as the 25th of April, the subscription period has to start the 20th of MAY and continue for 30 days. Customer B: buys the subscription of one month as the 5th of May, the subscription period has to start the 20th of MAY and continue for 30 days. Customer C: buys the subscription of one month as the 6th of May, the subscription period has to start the 20th of JUNE and continue for 30 days.  In practice, if a customer buys from the 20th of April to the 5th of May, the subscription has to start the 20th of May. if a customer buys from the 6th of May to the 19th of May, the subscription has to start the 20th of June.  To obtain this behaviour is necessary modify the plug in? Could you give me some help to do that?  Thanks in advance.")*

I don't know.
I can guide but if you want us to develop and test a modified version of the plugin for you, I'm afraid that we would have to charge you for that. I already gave a solution I think could work. That's already a great pointer if you know a bit of PHP.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzU5Mzc4LW1vZGlmeS1wbHVnLWluLWZvci1ha2VlYmEtc3Vic2NyaXB0aW9ucz90bXBsPW1hcmtkb3du) or [Create an account](/register) to join the conversation.

- **[Teto](/forum/user/8045-teto "View Teto's Profile")**
- [![Teto's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar8045_2012-09-12.png)](/forum/user/8045-teto "View Teto's Profile") Topic Author
- [ Offline](/forum/user/8045-teto)

Less More

- Posts: 184
- Thank you received: 4
-
- [](http://www.madeinvino.com)
-

14 years 3 months ago -  14 years 3 months ago [\#59628](#59628) by [Teto](/forum/user/8045-teto "View Teto's Profile")  Replied by *[Teto](/forum/user/8045-teto "View Teto's Profile")* on topic *[Re: Modify Plug In for akeeba Subscriptions](/forum/2-general-talk-about-hikashop/59378-modify-plug-in-for-akeeba-subscriptions#59628 "We sell normal products and also subscriptions. The subscriptions give the opportunity to buy the products (without a valid subscription it is no possible to buy the products). With have different subscriptions with different duration. To enable on my web site this feature I am using AkeebaSubscreption and the relative HikaShop Plug In.  I tested your plug-in with akeeba subscriptions and it works fine :cheer: , but we have a different method to start the subscription period depending on when the customer buy the subscrition.  For example Customer A: buys the subscription of one month as the 25th of April, the subscription period has to start the 20th of MAY and continue for 30 days. Customer B: buys the subscription of one month as the 5th of May, the subscription period has to start the 20th of MAY and continue for 30 days. Customer C: buys the subscription of one month as the 6th of May, the subscription period has to start the 20th of JUNE and continue for 30 days.  In practice, if a customer buys from the 20th of April to the 5th of May, the subscription has to start the 20th of May. if a customer buys from the 6th of May to the 19th of May, the subscription has to start the 20th of June.  To obtain this behaviour is necessary modify the plug in? Could you give me some help to do that?  Thanks in advance.")*

Dear Nicolas

you are right, I have to learn at least a bit of PHP (and CSS).
After many many tests I finally found the solution to obtain what I need

$month = date('m',$timestamp);
$year = date('Y',$timestamp);
$publish_up = $year.'-'.$month.'-20 00:00:00';

// controllo se il giorno è maggiore o uguale a 6 allora l'abbonamento parte il mese successivo
if (date('d',$timestamp)&gt;= '06') {
$date_apg = strtotime('+1 month', strtotime($publish_up));
$month = date('m',$date_apg);
$year = date('Y',$date_apg);
$publish_up = $year.'-'.$month.'-20 00:00:00';
}

// aggiongo i giorni alla data di fine abbonamento
$date_apg = strtotime('+'.$level_duration*$result-&gt;order_product_quantity.' day', strtotime($publish_up));
$day = date('d',$date_apg);
$month = date('m',$date_apg);
$year = date('Y',$date_apg);
$publish_down = $year.'-'.$month.'-'.$day.' 00:00:00';

Probably it is not the most elegant way to do that, but considering I am not an expert of PHP I am really sodisfied about it.
If someone have some suggestion, please you are more than welcome!.

I hope this Topic can help someone else in the future.

Last edit: 14 years 3 months ago by [Teto](/forum/user/8045-teto "View Teto's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzU5Mzc4LW1vZGlmeS1wbHVnLWluLWZvci1ha2VlYmEtc3Vic2NyaXB0aW9ucz90bXBsPW1hcmtkb3du) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86322
- Thank you received: 14281
-
-

14 years 3 months ago -  14 years 3 months ago [\#59683](#59683) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Modify Plug In for akeeba Subscriptions](/forum/2-general-talk-about-hikashop/59378-modify-plug-in-for-akeeba-subscriptions#59683 "We sell normal products and also subscriptions. The subscriptions give the opportunity to buy the products (without a valid subscription it is no possible to buy the products). With have different subscriptions with different duration. To enable on my web site this feature I am using AkeebaSubscreption and the relative HikaShop Plug In.  I tested your plug-in with akeeba subscriptions and it works fine :cheer: , but we have a different method to start the subscription period depending on when the customer buy the subscrition.  For example Customer A: buys the subscription of one month as the 25th of April, the subscription period has to start the 20th of MAY and continue for 30 days. Customer B: buys the subscription of one month as the 5th of May, the subscription period has to start the 20th of MAY and continue for 30 days. Customer C: buys the subscription of one month as the 6th of May, the subscription period has to start the 20th of JUNE and continue for 30 days.  In practice, if a customer buys from the 20th of April to the 5th of May, the subscription has to start the 20th of May. if a customer buys from the 6th of May to the 19th of May, the subscription has to start the 20th of June.  To obtain this behaviour is necessary modify the plug in? Could you give me some help to do that?  Thanks in advance.")*

Great !

Thank you for sharing back your modifications. It'll probably help someone else in the future.

Last edit: 14 years 3 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzItZ2VuZXJhbC10YWxrLWFib3V0LWhpa2FzaG9wLzU5Mzc4LW1vZGlmeS1wbHVnLWluLWZvci1ha2VlYmEtc3Vic2NyaXB0aW9ucz90bXBsPW1hcmtkb3du) or [Create an account](/register) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.099 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
