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

#   Odd value for "limit" needed

##

- **[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")**
- [![lousyfool's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar28604.jpg)](/forum/user/28604-lousyfool "View lousyfool's Profile") Topic Author
- [ Offline](/forum/user/28604-lousyfool)

Less More

- Posts: 2143
- Thank you received: 746
-
- [](http://www.inphase.one)
-

11 years 2 months ago -  11 years 2 months ago [\#215148](#215148) by [lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")  *[Odd value for "limit" needed](/forum/27-checkout/879445-odd-value-for-limit-needed#215148 "-- url of the page with the problem -- : local -- HikaShop version -- : 2.5.0 -- Joomla version -- : 3.4.4 -- PHP version -- : 5.5.3  Hi again,  I notice that 2.6.0 came out within the last very few hours... wow, congrats - will be an interesting one, I'm sure! Anyway, the changelog doesn't say anything about limits, so here I am:  I guess I need an odd 10 months limit on some products: it's Emerald subscriptions valid for 1 year, but renewal/repurchasing must be possible from 2 months before expiry.  The attachment shows what I've set up now, and that does the job - but for the whole year. Then I found the function &#95;checkQuantity in classes/cart.php and the lines  There's only this one period of limit in this case, so I'd be fine with modding e.g. case 3 to make it not 1 month but 10, then change my setting for period to &quot;Monthly&quot;. But I'm lost with the &quot;math&quot;, and even only 1 month is an awful long time for trial &amp; error, haha... So, it'd be great if you could give me a reliable hint on what exactly to change. Is it as simple as replacing the 1 with a 10 in case 3, then selecting &quot;Monthly&quot; in the backend?  Thanks a ton!")* was created by *[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")*

-- url of the page with the problem -- : local
-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.4
-- PHP version -- : 5.5.3

Hi again,

I notice that 2.6.0 came out within the last very few hours... wow, congrats - will be an interesting one, I'm sure! Anyway, the changelog doesn't say anything about limits, so here I am:

I guess I need an odd 10 months limit on some products: it's Emerald subscriptions valid for 1 year, but renewal/repurchasing must be possible from 2 months before expiry.

The attachment shows what I've set up now, and that does the job - but for the whole year. Then I found the function _checkQuantity in classes/cart.php and the lines Code:

$baseDates = array( 0 =&gt; 0, 1 =&gt; mktime(0,0,0,1,1,$d['year']), 2 =&gt; mktime(0,0,0,$d['mon']-(($d['mon']-1)%4),1,$d['year']), 3 =&gt; mktime(0,0,0,$d['mon'],1,$d['year']), 4 =&gt; mktime(0,0,0,$d['mon'],$d['mday']-$d['wday'],$d['year']), 5 =&gt; mktime(0,0,0,$d['mon'],$d['mday'],$d['year']), 6 =&gt; -1 );

There's only this one period of limit in this case, so I'd be fine with modding e.g. case 3 to make it not 1 month but 10, then change my setting for period to "Monthly". But I'm lost with the "math", and even only 1 month is an awful long time for trial &amp; error, haha...
So, it'd be great if you could give me a reliable hint on what exactly to change. Is it as simple as replacing the 1 with a 10 in case 3, then selecting "Monthly" in the backend?

Thanks a ton!

---

Need help with customisations of layouts, style or other site development? [ PM me!](/component/uddeim/?task=new)
(Don't forget to turn on [ "E-mail notification of new messages"](/component/uddeim/?task=settings))

- [ ![limit.jpg](/forum/attachment/26638) ](/forum/attachment/26638 "limit.jpg") [ ](/forum/attachment/26638?download=1 "limit.jpg")

Last edit: 11 years 2 months ago by [lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3OTQ0NS1vZGQtdmFsdWUtZm9yLWxpbWl0LW5lZWRlZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

11 years 2 months ago [\#215165](#215165) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Odd value for "limit" needed](/forum/27-checkout/879445-odd-value-for-limit-needed#215165 "-- url of the page with the problem -- : local -- HikaShop version -- : 2.5.0 -- Joomla version -- : 3.4.4 -- PHP version -- : 5.5.3  Hi again,  I notice that 2.6.0 came out within the last very few hours... wow, congrats - will be an interesting one, I'm sure! Anyway, the changelog doesn't say anything about limits, so here I am:  I guess I need an odd 10 months limit on some products: it's Emerald subscriptions valid for 1 year, but renewal/repurchasing must be possible from 2 months before expiry.  The attachment shows what I've set up now, and that does the job - but for the whole year. Then I found the function &#95;checkQuantity in classes/cart.php and the lines  There's only this one period of limit in this case, so I'd be fine with modding e.g. case 3 to make it not 1 month but 10, then change my setting for period to &quot;Monthly&quot;. But I'm lost with the &quot;math&quot;, and even only 1 month is an awful long time for trial &amp; error, haha... So, it'd be great if you could give me a reliable hint on what exactly to change. Is it as simple as replacing the 1 with a 10 in case 3, then selecting &quot;Monthly&quot; in the backend?  Thanks a ton!")*

Hi,

I would recommend against modifying directly the _checkQuantity function. It's not well adapted to what you want and you'll loose your changes on each update.
Rather than doing that, you could instead create a small hikashop plugin, implementing the trigger onAfterProductQuantityCheck(&amp;$product, &amp;$wantedQuantity,&amp;$quantity, &amp;$cartContent, &amp;$cart_product_id_for_product, &amp;$displayErrors)
That way, you can really have your custom check exactly the way you want it and you won't loose your changes when you update.

The following user(s) said Thank You: [lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3OTQ0NS1vZGQtdmFsdWUtZm9yLWxpbWl0LW5lZWRlZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")**
- [![lousyfool's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar28604.jpg)](/forum/user/28604-lousyfool "View lousyfool's Profile") Topic Author
- [ Offline](/forum/user/28604-lousyfool)

Less More

- Posts: 2143
- Thank you received: 746
-
- [](http://www.inphase.one)
-

11 years 2 months ago [\#215188](#215188) by [lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")  Replied by *[lousyfool](/forum/user/28604-lousyfool "View lousyfool's Profile")* on topic *[Odd value for "limit" needed](/forum/27-checkout/879445-odd-value-for-limit-needed#215188 "-- url of the page with the problem -- : local -- HikaShop version -- : 2.5.0 -- Joomla version -- : 3.4.4 -- PHP version -- : 5.5.3  Hi again,  I notice that 2.6.0 came out within the last very few hours... wow, congrats - will be an interesting one, I'm sure! Anyway, the changelog doesn't say anything about limits, so here I am:  I guess I need an odd 10 months limit on some products: it's Emerald subscriptions valid for 1 year, but renewal/repurchasing must be possible from 2 months before expiry.  The attachment shows what I've set up now, and that does the job - but for the whole year. Then I found the function &#95;checkQuantity in classes/cart.php and the lines  There's only this one period of limit in this case, so I'd be fine with modding e.g. case 3 to make it not 1 month but 10, then change my setting for period to &quot;Monthly&quot;. But I'm lost with the &quot;math&quot;, and even only 1 month is an awful long time for trial &amp; error, haha... So, it'd be great if you could give me a reliable hint on what exactly to change. Is it as simple as replacing the 1 with a 10 in case 3, then selecting &quot;Monthly&quot; in the backend?  Thanks a ton!")*

Thanks Nicolas,

Of course, "hacking" the core file isn't ideal, but I'd have my way of keeping track of those very few cases.

A plugin as recommended by you may be small in size, but likely too big in complexity for my little knowledge of PHP. Plus, in the [ dev docs](http://www.hikashop.com/support/support/documentation/62-hikashop-developer-documentation.html) the trigger onAfterProductQuantityCheck is not mentioned/documented.

Well, one can't have it all, it seems... ![;)](/media/kunena/emoticons/24.png ";)")

---

Need help with customisations of layouts, style or other site development? [ PM me!](/component/uddeim/?task=new)
(Don't forget to turn on [ "E-mail notification of new messages"](/component/uddeim/?task=settings))

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3OTQ0NS1vZGQtdmFsdWUtZm9yLWxpbWl0LW5lZWRlZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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.043 seconds

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