Skip to main content

Limit period

More
8 years 7 months ago #288811 by piggersisdaman
Limit period was created by piggersisdaman
-- HikaShop version -- : 3.3.0
-- Joomla version -- : 3.8.5
-- PHP version -- : 7.0

When using the "Limit" feature is it possible to add bi-weekly and every 3 weeks to the drop down?

Please Log in or Create an account to join the conversation.

More
8 years 7 months ago #288826 by nicolas
Replied by nicolas on topic Limit period
Hi,

There is no option to add more choices to it.
To do that you would have to:
- modify the code:
Code:
$periodicity = array( 'forever' => 0, 'yearly' => 1, 'quarterly' => 2, 'monthly' => 3, 'weekly' => 4, 'daily' => 5, 'cart' => 6 ); $baseDates = array( 0 => 0, 1 => mktime(0,0,0,1,1,$d['year']), 2 => mktime(0,0,0,$d['mon']-(($d['mon']-1)%4),1,$d['year']), 3 => mktime(0,0,0,$d['mon'],1,$d['year']), 4 => mktime(0,0,0,$d['mon'],$d['mday']-$d['wday'],$d['year']), 5 => mktime(0,0,0,$d['mon'],$d['mday'],$d['year']), 6 => -1 );
in the file administrator/components/com_hikashop/classes/limit.php to add the new choices in the code which process the limits.
- Edit the file administrator/components/com_hikashop/views/limit/tmpl/form.php and add the new choices in the code below to add them to the dropdown of limits:
Code:
$values = array(); $values[] = JHTML::_('select.option', 'cart', JText::_('Cart')); $values[] = JHTML::_('select.option', 'daily', JText::_('Daily')); $values[] = JHTML::_('select.option', 'weekly', JText::_('Weekly')); $values[] = JHTML::_('select.option', 'monthly', JText::_('Monthly')); $values[] = JHTML::_('select.option', 'quarterly', JText::_('Quarterly')); $values[] = JHTML::_('select.option', 'yearly', JText::_('Yearly')); $values[] = JHTML::_('select.option', 'forever', JText::_('Forever')); echo JHTML::_('select.genericlist', $values, "data[limit][limit_periodicity]" , 'class="inputbox" size="1"', 'value', 'text', @$this->element->limit_periodicity );
The following user(s) said Thank You: piggersisdaman

Please Log in or Create an account to join the conversation.

More
8 years 7 months ago - 8 years 6 months ago #288846 by piggersisdaman
Replied by piggersisdaman on topic Limit period
I added 2 more options and they appear in the drop down menu fine. On the limit.php, it doesn't appear to be working correctly. I tested it and it using the 2 new options and it still allows it to be added to cart without warning.

Is it possible my mktime is incorrect for array 7 and 8?

Thanks for help.
Code:
$d = getdate(); $periodicity = array( 'forever' => 0, 'yearly' => 1, 'quarterly' => 2, 'monthly' => 3, 'weekly' => 4, 'daily' => 5, 'cart' => 6, 'bi-weekly' => 7, 'three-weeks' => 8 ); $baseDates = array( 0 => 0, 1 => mktime(0,0,0,1,1,$d['year']), 2 => mktime(0,0,0,$d['mon']-(($d['mon']-1)%4),1,$d['year']), 3 => mktime(0,0,0,$d['mon'],1,$d['year']), 4 => mktime(0,0,0,$d['mon'],$d['mday']-$d['wday'],$d['year']), 5 => mktime(0,0,0,$d['mon'],$d['mday'],$d['year']), 6 => -1, 7 => mktime(0,0,0,$d['mon'],$d['mday']-13,$d['year']), 8 => mktime(0,0,0,$d['mon'],$d['mday']-20,$d['year']) );
Last edit: 8 years 6 months ago by piggersisdaman.

Please Log in or Create an account to join the conversation.

More
8 years 7 months ago #288847 by piggersisdaman
Replied by piggersisdaman on topic Limit period
I spotted my mistake. I dropped 7 and 8 below 6.
Code:
$d = getdate(); $periodicity = array( 'forever' => 0, 'yearly' => 1, 'quarterly' => 2, 'monthly' => 3, 'weekly' => 4, 'daily' => 5, 'cart' => 6, 'bi-weekly' => 7, 'three-weeks' => 8 ); $baseDates = array( 0 => 0, 1 => mktime(0,0,0,1,1,$d['year']), 2 => mktime(0,0,0,$d['mon']-(($d['mon']-1)%4),1,$d['year']), 3 => mktime(0,0,0,$d['mon'],1,$d['year']), 4 => mktime(0,0,0,$d['mon'],$d['mday']-$d['wday'],$d['year']), 5 => mktime(0,0,0,$d['mon'],$d['mday'],$d['year']), 6 => -1, 7 => mktime(0,0,0,$d['mon'],$d['mday']+13,$d['year']), 8 => mktime(0,0,0,$d['mon'],$d['mday']+20,$d['year']) );

Please Log in or Create an account to join the conversation.

Time to create page: 0.312 seconds
Powered by Kunena Forum